mirror of
https://github.com/google/blockly.git
synced 2026-01-04 23:50:12 +01:00
Fix metadata tests
- Do not run npm install. - Do not re-run build that has already been run by a previous test. - Check files in built/ instead repo root. - Fix formatting, styleguide issues.
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Checks the size of generated files and verifies they aren't growing
|
||||
# unreasonably.
|
||||
# unreasonably. Assumes the compressed files have already been built.
|
||||
|
||||
# These values should be updated with each release
|
||||
# Location of the pre-built compressed files.
|
||||
readonly BUILD_DIR='built'
|
||||
|
||||
# These values should be updated with each release. (Note that the
|
||||
# historic values are tab-delimited.)
|
||||
|
||||
# Size of blockly_compressed.js
|
||||
# Q2 2019 2.20190722.0 812688
|
||||
@@ -12,9 +16,9 @@
|
||||
# Q1 2020 3.20200402.0 619341
|
||||
# Q2 2020 3.20200625.0 621811
|
||||
# Q3 2020 3.20200924.0 641216
|
||||
# Q4 2020 4.20201217.0 653624
|
||||
# Q1 2021 5.20210325.0 653957
|
||||
blockly_size_expected=653957
|
||||
# Q4 2020 4.20201217.0 653624
|
||||
# Q1 2021 5.20210325.0 653957
|
||||
readonly BLOCKLY_SIZE_EXPECTED=653957
|
||||
|
||||
# Size of blocks_compressed.js
|
||||
# Q2 2019 2.20190722.0 75618
|
||||
@@ -23,9 +27,9 @@ blockly_size_expected=653957
|
||||
# Q1 2020 3.20200402.0 75805
|
||||
# Q2 2020 3.20200625.0 76360
|
||||
# Q3 2020 3.20200924.0 76429
|
||||
# Q4 2020 4.20201217.0 76693
|
||||
# Q1 2021 5.20210325.0 76693
|
||||
blocks_size_expected=76693
|
||||
# Q4 2020 4.20201217.0 76693
|
||||
# Q1 2021 5.20210325.0 76693
|
||||
readonly BLOCKS_SIZE_EXPECTED=76693
|
||||
|
||||
# Size of blockly_compressed.js.gz
|
||||
# Q2 2019 2.20190722.0 180925
|
||||
@@ -34,9 +38,9 @@ blocks_size_expected=76693
|
||||
# Q1 2020 3.20200402.0 134133
|
||||
# Q2 2020 3.20200625.0 135181
|
||||
# Q3 2020 3.20200924.0 138003
|
||||
# Q4 2020 4.20201217.0 138115
|
||||
# Q1 2021 5.20210325.0 136118
|
||||
blockly_gz_size_expected=136118
|
||||
# Q4 2020 4.20201217.0 138115
|
||||
# Q1 2021 5.20210325.0 136118
|
||||
readonly BLOCKLY_GZ_SIZE_EXPECTED=136118
|
||||
|
||||
# Size of blocks_compressed.js.gz
|
||||
# Q2 2019 2.20190722.0 14552
|
||||
@@ -45,49 +49,46 @@ blockly_gz_size_expected=136118
|
||||
# Q1 2020 3.20200402.0 14966
|
||||
# Q2 2020 3.20200625.0 15195
|
||||
# Q3 2020 3.20200924.0 15231
|
||||
# Q4 2020 4.20201217.0 15224
|
||||
# Q1 2021 5.20210325.0 15285
|
||||
blocks_gz_size_expected=15285
|
||||
# Q4 2020 4.20201217.0 15224
|
||||
# Q1 2021 5.20210325.0 15285
|
||||
readonly BLOCKS_GZ_SIZE_EXPECTED=15285
|
||||
|
||||
# ANSI colors
|
||||
BOLD_GREEN='\033[1;32m'
|
||||
BOLD_RED='\033[1;31m'
|
||||
ANSI_RESET='\033[0m'
|
||||
readonly BOLD_GREEN='\033[1;32m'
|
||||
readonly BOLD_RED='\033[1;31m'
|
||||
readonly ANSI_RESET='\033[0m'
|
||||
|
||||
# Build the compressed files for core and blocks
|
||||
echo "Building files"
|
||||
npm install
|
||||
gulp buildCompressed
|
||||
gulp buildBlocks
|
||||
|
||||
# GZip them for additional size comparisons
|
||||
# GZip them for additional size comparisons (keep originals, force
|
||||
# overwite previously-gzipped copies).
|
||||
echo "Zipping the compressed files"
|
||||
gzip -c blockly_compressed.js > blockly_compressed.js.gz
|
||||
gzip -c blocks_compressed.js > blocks_compressed.js.gz
|
||||
gzip -kf "${BUILD_DIR}/blockly_compressed.js"
|
||||
gzip -kf "${BUILD_DIR}/blocks_compressed.js"
|
||||
|
||||
# Check the sizes of the files
|
||||
|
||||
has_failed=0
|
||||
|
||||
compare_size() {
|
||||
local name=$1
|
||||
local expected=$2
|
||||
local compare=$(echo "$expected * 1.1 / 1" | bc)
|
||||
local name="$1"
|
||||
local expected="$2"
|
||||
local compare=$(echo "${expected} * 1.1 / 1" | bc)
|
||||
|
||||
local size=$(wc -c <"$name")
|
||||
local size=$(wc -c <"${name}")
|
||||
|
||||
if (( $size > $compare))
|
||||
then
|
||||
echo -e "${BOLD_RED}Failed: Size of $name has grown more than 10%. $size vs $expected ${ANSI_RESET}" >&2
|
||||
has_failed=1
|
||||
else
|
||||
echo -e "${BOLD_GREEN}Size of $name at $size compared to previous $expected.${ANSI_RESET}"
|
||||
fi
|
||||
if (( $size > $compare))
|
||||
then
|
||||
echo -ne "${BOLD_RED}Failed: Size of ${name} has grown more than 10%. " >&2
|
||||
echo -e "${size} vs ${expected} ${ANSI_RESET}" >&2
|
||||
has_failed=1
|
||||
else
|
||||
echo -ne "${BOLD_GREEN}Size of ${name} at ${size} compared to previous " >&2
|
||||
echo -e "${expected}.${ANSI_RESET}"
|
||||
fi
|
||||
}
|
||||
|
||||
compare_size "blockly_compressed.js" $blockly_size_expected
|
||||
compare_size "blocks_compressed.js" $blocks_size_expected
|
||||
compare_size "blockly_compressed.js.gz" $blockly_gz_size_expected
|
||||
compare_size "blocks_compressed.js.gz" $blocks_gz_size_expected
|
||||
compare_size "${BUILD_DIR}/blockly_compressed.js" $BLOCKLY_SIZE_EXPECTED
|
||||
compare_size "${BUILD_DIR}/blocks_compressed.js" $BLOCKS_SIZE_EXPECTED
|
||||
compare_size "${BUILD_DIR}/blockly_compressed.js.gz" $BLOCKLY_GZ_SIZE_EXPECTED
|
||||
compare_size "${BUILD_DIR}/blocks_compressed.js.gz" $BLOCKS_GZ_SIZE_EXPECTED
|
||||
|
||||
exit $has_failed
|
||||
|
||||
Reference in New Issue
Block a user