mirror of
https://github.com/google/blockly.git
synced 2026-01-04 15:40:08 +01:00
Add a test for built file size (#3075)
* Add a test for built file size Adds a script test for building Blockly's compressed files and checking their size to prevent unexpected increases. * Update size for new changes * Add full stop
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -5,6 +5,7 @@ build-debug.log
|
||||
.DS_Store
|
||||
.settings
|
||||
.project
|
||||
*.gz
|
||||
*.pyc
|
||||
*.komodoproject
|
||||
/nbproject/private/
|
||||
|
||||
6921
package-lock.json
generated
Normal file
6921
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -67,6 +67,9 @@ run_test_command "generators" "tests/scripts/run_generators.sh"
|
||||
# Generate TypeScript typings and ensure there are no errors.
|
||||
run_test_command "typings" "tests/scripts/compile_typings.sh"
|
||||
|
||||
# Check the sizes of built files for unexpected growth.
|
||||
run_test_command "metadata" "tests/scripts/check_metadata.sh"
|
||||
|
||||
# # Attempt advanced compilation of a Blockly app.
|
||||
# run_test_command "compile" "tests/compile/compile.sh"
|
||||
|
||||
|
||||
57
tests/scripts/check_metadata.sh
Executable file
57
tests/scripts/check_metadata.sh
Executable file
@@ -0,0 +1,57 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Checks the size of generated files and verifies they aren't growing
|
||||
# unreasonably.
|
||||
|
||||
# These values should be updated with each release
|
||||
# Size of blockly_compressed.js
|
||||
blockly_size_expected=573000 # 813K in July 2019 release
|
||||
# Size of blocks_compressed.js
|
||||
blocks_size_expected=76500 # 75K in July 2019 release
|
||||
# Size of blockly_compressed.js.gz
|
||||
blockly_gz_size_expected=123000 # 180K in July 2019 release
|
||||
# Size of blocks_compressed.js.gz
|
||||
blocks_gz_size_expected=15200 # 14.5K in July 2019 release
|
||||
|
||||
# ANSI colors
|
||||
BOLD_GREEN='\033[1;32m'
|
||||
BOLD_RED='\033[1;31m'
|
||||
ANSI_RESET='\033[0m'
|
||||
|
||||
# Build the compressed files for core and blocks
|
||||
echo "Building files"
|
||||
npm install
|
||||
gulp build-core
|
||||
gulp build-blocks
|
||||
|
||||
# GZip them for additional size comparisons
|
||||
echo "Zipping the compressed files"
|
||||
gzip -c blockly_compressed.js > blockly_compressed.js.gz
|
||||
gzip -c blocks_compressed.js > blocks_compressed.js.gz
|
||||
|
||||
# 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 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
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
exit $has_failed
|
||||
Reference in New Issue
Block a user