fix(build): build/test on windows (#6431)

* build: build/test on windows

* chore(deps): bump @hyperjump/json-schema from 0.18.4 to 0.18.5
* chore(deps): add gulp-gzip 1.4.2
* build: migrate test scripts to gulp task (test_tasks.js)
* build: not to use the grep command
* build: normalize path

* fix: Modified based on review suggestions.
* Add JSDoc comment
* Line length <= 80 characters.
* Formatting test output as previously.
* Always continue even if a test unit fails.
* Suppress the gulp messages.
* Fix test_tasks.js to pass eslint.

* fix: Modified based on review suggestions.
* Change generator test output directory.
* Formatting test output as previously.

* fix: Formatting test output as previously.

* fix: Modified based on review suggestions.
This commit is contained in:
YAMADA Yutaka
2022-10-28 05:02:50 +09:00
committed by GitHub
parent c1fbcc5bed
commit 52879dd953
11 changed files with 604 additions and 209 deletions

View File

@@ -19,6 +19,7 @@ const licenseTasks = require('./scripts/gulpfiles/license_tasks');
const appengineTasks = require('./scripts/gulpfiles/appengine_tasks');
const releaseTasks = require('./scripts/gulpfiles/release_tasks');
const cleanupTasks = require('./scripts/gulpfiles/cleanup_tasks');
const testTasks = require('./scripts/gulpfiles/test_tasks');
module.exports = {
deployDemos: appengineTasks.deployDemos,
@@ -50,4 +51,6 @@ module.exports = {
publish: releaseTasks.publish,
publishBeta: releaseTasks.publishBeta,
sortRequires: cleanupTasks.sortRequires,
test: testTasks.test,
testGenerators: testTasks.generators,
};

219
package-lock.json generated
View File

@@ -12,10 +12,11 @@
"jsdom": "15.2.1"
},
"devDependencies": {
"@blockly/block-test": "^3.0.0",
"@blockly/dev-tools": "^5.0.0",
"@blockly/theme-modern": "^3.0.0",
"@hyperjump/json-schema": "^0.18.4",
"@hyperjump/json-schema": "^0.18.5",
"@microsoft/api-extractor": "^7.29.5",
"@typescript-eslint/eslint-plugin": "^5.33.1",
"@wdio/selenium-standalone-service": "^7.10.1",
@@ -31,6 +32,7 @@
"gulp": "^4.0.2",
"gulp-clang-format": "^1.0.27",
"gulp-concat": "^2.6.1",
"gulp-gzip": "^1.4.2",
"gulp-insert": "^0.5.0",
"gulp-rename": "^2.0.0",
"gulp-replace": "^1.0.0",
@@ -419,13 +421,13 @@
"dev": true
},
"node_modules/@hyperjump/json-pointer": {
"version": "0.9.2",
"resolved": "https://registry.npmjs.org/@hyperjump/json-pointer/-/json-pointer-0.9.2.tgz",
"integrity": "sha512-PGCyTWO+WTkNWhMdlgE7OiQYPVkme9/e6d7K2xiZxH1wMGxGgZEEDNCe8hox7rkuD1equ4eZM+K3eoPCexckmA==",
"version": "0.9.6",
"resolved": "https://registry.npmjs.org/@hyperjump/json-pointer/-/json-pointer-0.9.6.tgz",
"integrity": "sha512-3szMJLfz+1wtfPHnGi1sHzwFfFdZqIZLCCYtaD47vLZMAQCbtoBRVZn44jJgIQ6v37+8fom5rsxSSIMKWi0zbg==",
"dev": true,
"hasInstallScript": true,
"dependencies": {
"just-curry-it": "^3.2.1"
"just-curry-it": "^5.2.1"
},
"funding": {
"type": "github",
@@ -448,9 +450,9 @@
}
},
"node_modules/@hyperjump/json-schema-core": {
"version": "0.23.6",
"resolved": "https://registry.npmjs.org/@hyperjump/json-schema-core/-/json-schema-core-0.23.6.tgz",
"integrity": "sha512-X0IzGRi5K4c91awB3xNt5bvbs34UyHwOpRKKFFJ2nWDWW7e22VNGvibqo/S2rdFyta3wqOHTICFNTQjjcVdIZg==",
"version": "0.23.7",
"resolved": "https://registry.npmjs.org/@hyperjump/json-schema-core/-/json-schema-core-0.23.7.tgz",
"integrity": "sha512-64gBteTl+zAvI1D68l/+gH7ncuM+Cf0rGdm/YwtsYZlNfbybgFD5R5uuJCsPGJDm5ZYqqWMdPIq6Nh5jDENYRw==",
"dev": true,
"hasInstallScript": true,
"dependencies": {
@@ -467,9 +469,9 @@
}
},
"node_modules/@hyperjump/pact": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/@hyperjump/pact/-/pact-0.2.1.tgz",
"integrity": "sha512-imzl9j1UiqM/HC3kgfS0/TdXcEFGFkq5EwjyaztLfdmia8KLBXGy3rC96K+nnyY+2fA69yA9HtnDappub5VSQQ==",
"version": "0.2.4",
"resolved": "https://registry.npmjs.org/@hyperjump/pact/-/pact-0.2.4.tgz",
"integrity": "sha512-BGmyLaUSCMVyHrwXr67rMxgiQHPHwcmVCjROoY8q232EpMz9d9aFCkgGhdx//yEfHM7zgsm0zZ8RD/F89uPySg==",
"dev": true,
"hasInstallScript": true,
"dependencies": {
@@ -480,6 +482,12 @@
"url": "https://github.com/sponsors/jdesrosiers"
}
},
"node_modules/@hyperjump/pact/node_modules/just-curry-it": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/just-curry-it/-/just-curry-it-3.2.1.tgz",
"integrity": "sha512-Q8206k8pTY7krW32cdmPsP+DqqLgWx/hYPSj9/+7SYqSqz7UuwPbfSe07lQtvuuaVyiSJveXk0E5RydOuWwsEg==",
"dev": true
},
"node_modules/@microsoft/api-extractor": {
"version": "7.31.2",
"resolved": "https://registry.npmjs.org/@microsoft/api-extractor/-/api-extractor-7.31.2.tgz",
@@ -2078,6 +2086,12 @@
"node": ">=0.10.0"
}
},
"node_modules/any-promise": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz",
"integrity": "sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==",
"dev": true
},
"node_modules/anymatch": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz",
@@ -2733,6 +2747,15 @@
"integrity": "sha1-y5T662HIaWRR2zZTThQi+U8K7og=",
"dev": true
},
"node_modules/bytes": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
"integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",
"dev": true,
"engines": {
"node": ">= 0.8"
}
},
"node_modules/cac": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/cac/-/cac-3.0.4.tgz",
@@ -4258,15 +4281,6 @@
"uuid": "dist/bin/uuid"
}
},
"node_modules/diff": {
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/diff/-/diff-2.2.3.tgz",
"integrity": "sha1-YOr9DSjukG5Oj/ClLBIpUhAzv5k=",
"dev": true,
"engines": {
"node": ">=0.3.1"
}
},
"node_modules/dir-glob": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz",
@@ -6521,6 +6535,15 @@
"through2": "^2.0.0"
}
},
"node_modules/gulp-diff/node_modules/diff": {
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/diff/-/diff-2.2.3.tgz",
"integrity": "sha512-9wfm3RLzMp/PyTFWuw9liEzdlxsdGixCW0ZTU1XDmtlAkvpVXTPGF8KnfSs0hm3BPbg19OrUPPsRkHXoREpP1g==",
"dev": true,
"engines": {
"node": ">=0.3.1"
}
},
"node_modules/gulp-diff/node_modules/through2": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz",
@@ -6531,6 +6554,45 @@
"xtend": "~4.0.1"
}
},
"node_modules/gulp-gzip": {
"version": "1.4.2",
"resolved": "https://registry.npmjs.org/gulp-gzip/-/gulp-gzip-1.4.2.tgz",
"integrity": "sha512-ZIxfkUwk2XmZPTT9pPHrHUQlZMyp9nPhg2sfoeN27mBGpi7OaHnOD+WCN41NXjfJQ69lV1nQ9LLm1hYxx4h3UQ==",
"dev": true,
"dependencies": {
"ansi-colors": "^1.0.1",
"bytes": "^3.0.0",
"fancy-log": "^1.3.2",
"plugin-error": "^1.0.0",
"stream-to-array": "^2.3.0",
"through2": "^2.0.3"
},
"engines": {
"node": ">= 0.10.0"
}
},
"node_modules/gulp-gzip/node_modules/ansi-colors": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-1.1.0.tgz",
"integrity": "sha512-SFKX67auSNoVR38N3L+nvsPjOE0bybKTYbkf5tRvushrAPQ9V75huw0ZxBkKVeRU9kqH3d6HA4xTckbwZ4ixmA==",
"dev": true,
"dependencies": {
"ansi-wrap": "^0.1.0"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/gulp-gzip/node_modules/through2": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz",
"integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==",
"dev": true,
"dependencies": {
"readable-stream": "~2.3.6",
"xtend": "~4.0.1"
}
},
"node_modules/gulp-insert": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/gulp-insert/-/gulp-insert-0.5.0.tgz",
@@ -8006,9 +8068,9 @@
}
},
"node_modules/just-curry-it": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/just-curry-it/-/just-curry-it-3.2.1.tgz",
"integrity": "sha512-Q8206k8pTY7krW32cdmPsP+DqqLgWx/hYPSj9/+7SYqSqz7UuwPbfSe07lQtvuuaVyiSJveXk0E5RydOuWwsEg==",
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/just-curry-it/-/just-curry-it-5.2.1.tgz",
"integrity": "sha512-M8qhhO9WVNc3yZgf3qfiNxMIsQlHqFHJ3vMI8N/rkp852h1utOB/N3ebS8jeXGAwYSbkdd0K6zP9eZneUtjHwA==",
"dev": true
},
"node_modules/just-debounce": {
@@ -11919,6 +11981,15 @@
"integrity": "sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ==",
"dev": true
},
"node_modules/stream-to-array": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/stream-to-array/-/stream-to-array-2.3.0.tgz",
"integrity": "sha512-UsZtOYEn4tWU2RGLOXr/o/xjRBftZRlG3dEWoaHr8j4GuypJ3isitGbVyjQKAuMu+xbiop8q224TjiZWc4XTZA==",
"dev": true,
"dependencies": {
"any-promise": "^1.1.0"
}
},
"node_modules/streamqueue": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/streamqueue/-/streamqueue-0.0.6.tgz",
@@ -13988,12 +14059,12 @@
"dev": true
},
"@hyperjump/json-pointer": {
"version": "0.9.2",
"resolved": "https://registry.npmjs.org/@hyperjump/json-pointer/-/json-pointer-0.9.2.tgz",
"integrity": "sha512-PGCyTWO+WTkNWhMdlgE7OiQYPVkme9/e6d7K2xiZxH1wMGxGgZEEDNCe8hox7rkuD1equ4eZM+K3eoPCexckmA==",
"version": "0.9.6",
"resolved": "https://registry.npmjs.org/@hyperjump/json-pointer/-/json-pointer-0.9.6.tgz",
"integrity": "sha512-3szMJLfz+1wtfPHnGi1sHzwFfFdZqIZLCCYtaD47vLZMAQCbtoBRVZn44jJgIQ6v37+8fom5rsxSSIMKWi0zbg==",
"dev": true,
"requires": {
"just-curry-it": "^3.2.1"
"just-curry-it": "^5.2.1"
}
},
"@hyperjump/json-schema": {
@@ -14007,9 +14078,9 @@
}
},
"@hyperjump/json-schema-core": {
"version": "0.23.6",
"resolved": "https://registry.npmjs.org/@hyperjump/json-schema-core/-/json-schema-core-0.23.6.tgz",
"integrity": "sha512-X0IzGRi5K4c91awB3xNt5bvbs34UyHwOpRKKFFJ2nWDWW7e22VNGvibqo/S2rdFyta3wqOHTICFNTQjjcVdIZg==",
"version": "0.23.7",
"resolved": "https://registry.npmjs.org/@hyperjump/json-schema-core/-/json-schema-core-0.23.7.tgz",
"integrity": "sha512-64gBteTl+zAvI1D68l/+gH7ncuM+Cf0rGdm/YwtsYZlNfbybgFD5R5uuJCsPGJDm5ZYqqWMdPIq6Nh5jDENYRw==",
"dev": true,
"requires": {
"@hyperjump/json-pointer": "^0.9.1",
@@ -14021,12 +14092,20 @@
}
},
"@hyperjump/pact": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/@hyperjump/pact/-/pact-0.2.1.tgz",
"integrity": "sha512-imzl9j1UiqM/HC3kgfS0/TdXcEFGFkq5EwjyaztLfdmia8KLBXGy3rC96K+nnyY+2fA69yA9HtnDappub5VSQQ==",
"version": "0.2.4",
"resolved": "https://registry.npmjs.org/@hyperjump/pact/-/pact-0.2.4.tgz",
"integrity": "sha512-BGmyLaUSCMVyHrwXr67rMxgiQHPHwcmVCjROoY8q232EpMz9d9aFCkgGhdx//yEfHM7zgsm0zZ8RD/F89uPySg==",
"dev": true,
"requires": {
"just-curry-it": "^3.1.0"
},
"dependencies": {
"just-curry-it": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/just-curry-it/-/just-curry-it-3.2.1.tgz",
"integrity": "sha512-Q8206k8pTY7krW32cdmPsP+DqqLgWx/hYPSj9/+7SYqSqz7UuwPbfSe07lQtvuuaVyiSJveXk0E5RydOuWwsEg==",
"dev": true
}
}
},
"@microsoft/api-extractor": {
@@ -15266,6 +15345,12 @@
"integrity": "sha1-qCJQ3bABXponyoLoLqYDu/pF768=",
"dev": true
},
"any-promise": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz",
"integrity": "sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==",
"dev": true
},
"anymatch": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz",
@@ -15768,6 +15853,12 @@
"integrity": "sha1-y5T662HIaWRR2zZTThQi+U8K7og=",
"dev": true
},
"bytes": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
"integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",
"dev": true
},
"cac": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/cac/-/cac-3.0.4.tgz",
@@ -16966,12 +17057,6 @@
"integrity": "sha512-QeoiFUnCNlXusSIfCOov0bn9uGTx7Q+9Cj+vvNFzHym5OcJeXyFxXNtvWtFmDorlEnTJYL5S6wXv+kgAg1s/Zw==",
"dev": true
},
"diff": {
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/diff/-/diff-2.2.3.tgz",
"integrity": "sha1-YOr9DSjukG5Oj/ClLBIpUhAzv5k=",
"dev": true
},
"dir-glob": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz",
@@ -18788,6 +18873,47 @@
"through2": "^2.0.0"
},
"dependencies": {
"diff": {
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/diff/-/diff-2.2.3.tgz",
"integrity": "sha512-9wfm3RLzMp/PyTFWuw9liEzdlxsdGixCW0ZTU1XDmtlAkvpVXTPGF8KnfSs0hm3BPbg19OrUPPsRkHXoREpP1g==",
"dev": true
},
"through2": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz",
"integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==",
"dev": true,
"requires": {
"readable-stream": "~2.3.6",
"xtend": "~4.0.1"
}
}
}
},
"gulp-gzip": {
"version": "1.4.2",
"resolved": "https://registry.npmjs.org/gulp-gzip/-/gulp-gzip-1.4.2.tgz",
"integrity": "sha512-ZIxfkUwk2XmZPTT9pPHrHUQlZMyp9nPhg2sfoeN27mBGpi7OaHnOD+WCN41NXjfJQ69lV1nQ9LLm1hYxx4h3UQ==",
"dev": true,
"requires": {
"ansi-colors": "^1.0.1",
"bytes": "^3.0.0",
"fancy-log": "^1.3.2",
"plugin-error": "^1.0.0",
"stream-to-array": "^2.3.0",
"through2": "^2.0.3"
},
"dependencies": {
"ansi-colors": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-1.1.0.tgz",
"integrity": "sha512-SFKX67auSNoVR38N3L+nvsPjOE0bybKTYbkf5tRvushrAPQ9V75huw0ZxBkKVeRU9kqH3d6HA4xTckbwZ4ixmA==",
"dev": true,
"requires": {
"ansi-wrap": "^0.1.0"
}
},
"through2": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz",
@@ -19964,9 +20090,9 @@
}
},
"just-curry-it": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/just-curry-it/-/just-curry-it-3.2.1.tgz",
"integrity": "sha512-Q8206k8pTY7krW32cdmPsP+DqqLgWx/hYPSj9/+7SYqSqz7UuwPbfSe07lQtvuuaVyiSJveXk0E5RydOuWwsEg==",
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/just-curry-it/-/just-curry-it-5.2.1.tgz",
"integrity": "sha512-M8qhhO9WVNc3yZgf3qfiNxMIsQlHqFHJ3vMI8N/rkp852h1utOB/N3ebS8jeXGAwYSbkdd0K6zP9eZneUtjHwA==",
"dev": true
},
"just-debounce": {
@@ -23117,6 +23243,15 @@
"integrity": "sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ==",
"dev": true
},
"stream-to-array": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/stream-to-array/-/stream-to-array-2.3.0.tgz",
"integrity": "sha512-UsZtOYEn4tWU2RGLOXr/o/xjRBftZRlG3dEWoaHr8j4GuypJ3isitGbVyjQKAuMu+xbiop8q224TjiZWc4XTZA==",
"dev": true,
"requires": {
"any-promise": "^1.1.0"
}
},
"streamqueue": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/streamqueue/-/streamqueue-0.0.6.tgz",

View File

@@ -49,8 +49,8 @@
"recompile": "gulp recompile",
"release": "gulp gitCreateRC",
"start": "concurrently -n tsc,server \"tsc --watch --preserveWatchOutput --outDir 'build/src' --declarationDir 'build/declarations'\" \"http-server ./ -s -o /tests/playground.html -c-1\"",
"test": "tests/run_all_tests.sh",
"test:generators": "tests/scripts/run_generators.sh",
"test": "gulp --silent test",
"test:generators": "gulp --silent testGenerators",
"test:mocha:interactive": "http-server ./ -o /tests/mocha/index.html -c-1",
"test:compile:advanced": "gulp buildAdvancedCompilationTest --debug",
"updateGithubPages": "gulp gitUpdateGithubPages"
@@ -69,7 +69,7 @@
"@blockly/block-test": "^3.0.0",
"@blockly/dev-tools": "^5.0.0",
"@blockly/theme-modern": "^3.0.0",
"@hyperjump/json-schema": "^0.18.4",
"@hyperjump/json-schema": "^0.18.5",
"@microsoft/api-extractor": "^7.29.5",
"@typescript-eslint/eslint-plugin": "^5.33.1",
"@wdio/selenium-standalone-service": "^7.10.1",
@@ -85,6 +85,7 @@
"gulp": "^4.0.2",
"gulp-clang-format": "^1.0.27",
"gulp-concat": "^2.6.1",
"gulp-gzip": "^1.4.2",
"gulp-insert": "^0.5.0",
"gulp-rename": "^2.0.0",
"gulp-replace": "^1.0.0",

View File

@@ -28,6 +28,8 @@ var rimraf = require('rimraf');
var {BUILD_DIR, DEPS_FILE, TEST_DEPS_FILE, TSC_OUTPUT_DIR, TYPINGS_BUILD_DIR} = require('./config');
var {getPackageJson} = require('./helper_tasks');
var {posixPath} = require('../helpers');
////////////////////////////////////////////////////////////
// Build //
////////////////////////////////////////////////////////////
@@ -102,7 +104,9 @@ const NAMESPACE_PROPERTY = '__namespace__';
const chunks = [
{
name: 'blockly',
entry: path.join(CORE_DIR, 'main.js'),
entry: posixPath((argv.compileTs) ?
path.join(TSC_OUTPUT_DIR, CORE_DIR, 'main.js') :
path.join(CORE_DIR, 'main.js')),
exports: 'module$build$src$core$blockly',
reexport: 'Blockly',
},
@@ -337,6 +341,18 @@ function buildDeps(done) {
'tests/mocha'
];
/**
* Extracts lines that contain the specified keyword.
* @param {string} text output text
* @param {string} keyword extract lines with this keyword
* @returns {string} modified text
*/
function extractOutputs(text, keyword) {
return text.split('\n')
.filter((line) => line.includes(keyword))
.join('\n');
}
function filterErrors(text) {
return text.split('\n')
.filter(
@@ -349,29 +365,29 @@ function buildDeps(done) {
new Promise((resolve, reject) => {
const args = roots.map(root => `--root '${root}' `).join('');
exec(
`closure-make-deps ${args} >'${DEPS_FILE}'`,
{stdio: ['inherit', 'inherit', 'pipe']},
`closure-make-deps ${args}`,
(error, stdout, stderr) => {
console.warn(filterErrors(stderr));
if (error) {
reject(error);
} else {
fs.writeFileSync(DEPS_FILE, stdout);
resolve();
}
});
}).then(() => new Promise((resolve, reject) => {
// Use grep to filter out the entries that are already in deps.js.
// Filter out the entries that are already in deps.js.
const testArgs =
testRoots.map(root => `--root '${root}' `).join('');
exec(
`closure-make-deps ${testArgs} 2>/dev/null\
| grep 'tests/mocha' > '${TEST_DEPS_FILE}'`,
{stdio: ['inherit', 'inherit', 'pipe']},
`closure-make-deps ${testArgs}`,
(error, stdout, stderr) => {
console.warn(filterErrors(stderr));
if (error) {
reject(error);
} else {
fs.writeFileSync(TEST_DEPS_FILE,
extractOutputs(stdout, 'tests/mocha'));
resolve();
}
});
@@ -520,9 +536,6 @@ return ${chunk.exports};
* closure-calculate-chunks.
*/
function getChunkOptions() {
if (argv.compileTs) {
chunks[0].entry = path.join(TSC_OUTPUT_DIR, chunks[0].entry);
}
const basePath =
path.join(TSC_OUTPUT_DIR, 'closure', 'goog', 'base_minimal.js');
const cccArgs = [
@@ -560,7 +573,9 @@ function getChunkOptions() {
// chunk depends on any chunk but the first), so we look for
// one of the entrypoints amongst the files in each chunk.
const chunkByNickname = Object.create(null);
const jsFiles = rawOptions.js.slice(); // Will be modified via .splice!
// Copy and convert to posix js file paths.
// Result will be modified via `.splice`!
const jsFiles = rawOptions.js.map(p => posixPath(p));
const chunkList = rawOptions.chunk.map((element) => {
const [nickname, numJsFiles, parentNick] = element.split(':');

View File

@@ -0,0 +1,350 @@
/**
* @license
* Copyright 2022 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Gulp tasks to test.
*/
/* eslint-env node */
const gulp = require('gulp');
const gzip = require('gulp-gzip');
const fs = require('fs');
const path = require('path');
const {execSync} = require('child_process');
const rimraf = require('rimraf');
const {BUILD_DIR} = require('./config');
const runMochaTestsInBrowser =
require('../../tests/mocha/run_mocha_tests_in_browser.js');
const runGeneratorsInBrowser =
require('../../tests/generators/run_generators_in_browser.js');
const OUTPUT_DIR = 'build/generators/';
const GOLDEN_DIR = 'tests/generators/golden/';
const BOLD_GREEN = '\x1b[1;32m';
const BOLD_RED = '\x1b[1;31m';
const ANSI_RESET = '\x1b[0m';
let failerCount = 0;
/**
* Helper method for running test code block.
* @param {string} id test id
* @param {function} block test code block
* @return {Promise} asynchronous result
*/
function runTestBlock(id, block) {
return new Promise((resolve) => {
console.log('=======================================');
console.log(`== ${id}`);
if (process.env.CI) console.log('::group::');
block()
.then((result) => {
if (process.env.CI) console.log('::endgroup::');
console.log(`${BOLD_GREEN}SUCCESS:${ANSI_RESET} ${id}`);
resolve(result);
})
.catch((err) => {
failerCount++;
console.error(err.message);
if (process.env.CI) console.log('::endgroup::');
console.log(`${BOLD_RED}FAILED:${ANSI_RESET} ${id}`);
// Always continue.
resolve(err);
});
});
}
/**
* Helper method for running test command.
* @param {string} id test id
* @param {string} command command line to run
* @return {Promise} asynchronous result
*/
function runTestCommand(id, command) {
return runTestBlock(id, async() => {
return execSync(command, {stdio: 'inherit'});
}, false);
}
/**
* Lint the codebase.
* Skip for CI environments, because linting is run separately.
* @return {Promise} asynchronous result
*/
function eslint() {
if (process.env.CI) {
console.log('Skip linting.');
return Promise.resolve();
}
return runTestCommand('eslint', 'eslint .');
}
/**
* Run the full usual build process, checking to ensure there are no
* closure compiler warnings / errors.
* @return {Promise} asynchronous result
*/
function buildDebug() {
return runTestCommand('build-debug', 'npm run build-debug');
}
/**
* Run renaming validation test.
* @return {Promise} asynchronous result
*/
function renamings() {
return runTestCommand('renamings', 'node tests/migration/validate-renamings.js');
}
/**
* Helper method for gzipping file.
* @param {string} file target file
* @return {Promise} asynchronous result
*/
function gzipFile(file) {
return new Promise((resolve) => {
const name = path.posix.join('build', file);
const stream = gulp.src(name)
.pipe(gzip())
.pipe(gulp.dest('build'));
stream.on('end', () => {
resolve();
});
});
}
/**
* Helper method for comparing file size.
* @param {string} file target file
* @param {number} expected expected size
* @return {number} 0: success / 1: failed
*/
function compareSize(file, expected) {
const name = path.posix.join(BUILD_DIR, file);
const compare = Math.floor(expected * 1.1);
const stat = fs.statSync(name);
const size = stat.size;
if (size > compare) {
const message = `Failed: ` +
`Size of ${name} has grown more than 10%. ${size} vs ${expected} `;
console.log(`${BOLD_RED}${message}${ANSI_RESET}`);
return 1;
} else {
const message =
`Size of ${name} at ${size} compared to previous ${expected}`;
console.log(`${BOLD_GREEN}${message}${ANSI_RESET}`);
return 0;
}
}
/**
* Helper method for zipping the compressed files.
* @return {Promise} asynchronous result
*/
function zippingFiles() {
// GZip them for additional size comparisons (keep originals, force
// overwite previously-gzipped copies).
console.log('Zipping the compressed files');
const gzip1 = gzipFile('blockly_compressed.js');
const gzip2 = gzipFile('blocks_compressed.js');
return Promise.all([gzip1, gzip2]);
}
/**
* Check the sizes of built files for unexpected growth.
* @return {Promise} asynchronous result
*/
function metadata() {
return runTestBlock('metadata', async() => {
// Zipping the compressed files.
await zippingFiles();
// Read expected size from script.
const contents = fs.readFileSync('tests/scripts/check_metadata.sh')
.toString();
const pattern = /^readonly (?<key>[A-Z_]+)=(?<value>\d+)$/gm;
const matches = contents.matchAll(pattern);
const expected = {};
for (const match of matches) {
expected[match.groups.key] = match.groups.value;
}
// Check the sizes of the files.
let failed = 0;
failed += compareSize('blockly_compressed.js',
expected.BLOCKLY_SIZE_EXPECTED);
failed += compareSize('blocks_compressed.js',
expected.BLOCKS_SIZE_EXPECTED);
failed += compareSize('blockly_compressed.js.gz',
expected.BLOCKLY_GZ_SIZE_EXPECTED);
failed += compareSize('blocks_compressed.js.gz',
expected.BLOCKS_GZ_SIZE_EXPECTED);
if (failed > 0) {
throw new Error('Unexpected growth was detected.');
}
});
}
/**
* Run Mocha tests inside a browser.
* @return {Promise} asynchronous result
*/
function mocha() {
return runTestBlock('mocha', async() => {
const result = await runMochaTestsInBrowser().catch(e => {
throw e;
});
if (result) {
throw new Error('Mocha tests failed');
}
console.log('Mocha tests passed');
});
}
/**
* Helper method for comparison file.
* @param {string} file1 first target file
* @param {string} file2 second target file
* @return {boolean} comparison result (true: same / false: different)
*/
function compareFile(file1, file2) {
const buf1 = fs.readFileSync(file1);
const buf2 = fs.readFileSync(file2);
// Normalize the line feed.
const code1 = buf1.toString().replace(/(?:\r\n|\r|\n)/g, '\n');
const code2 = buf2.toString().replace(/(?:\r\n|\r|\n)/g, '\n');
const result = (code1 === code2);
return result;
}
/**
* Helper method for checking the result of generator.
* @param {string} suffix target suffix
* @return {number} check result (0: success / 1: failed)
*/
function checkResult(suffix) {
const fileName = `generated.${suffix}`;
const resultFileName = path.posix.join(OUTPUT_DIR, fileName);
const SUCCESS_PREFIX = `${BOLD_GREEN}SUCCESS:${ANSI_RESET}`;
const FAILURE_PREFIX = `${BOLD_RED}FAILED:${ANSI_RESET}`;
if (fs.existsSync(resultFileName)) {
const goldenFileName = path.posix.join(GOLDEN_DIR, fileName);
if (fs.existsSync(goldenFileName)) {
if (compareFile(resultFileName, goldenFileName)) {
console.log(`${SUCCESS_PREFIX} ${suffix}: ` +
`${resultFileName} matches ${goldenFileName}`);
return 0;
} else {
console.log(
`${FAILURE_PREFIX} ${suffix}: ` +
`${resultFileName} does not match ${goldenFileName}`);
}
} else {
console.log(`File ${goldenFileName} not found!`);
}
} else {
console.log(`File ${resultFileName} not found!`);
}
return 1;
}
/**
* Run generator tests inside a browser and check the results.
* @return {Promise} asynchronous result
*/
function generators() {
return runTestBlock('generators', async() => {
// Clean up.
rimraf.sync(OUTPUT_DIR);
fs.mkdirSync(OUTPUT_DIR);
await runGeneratorsInBrowser(OUTPUT_DIR).catch(() => {});
const generatorSuffixes = ['js', 'py', 'dart', 'lua', 'php'];
let failed = 0;
generatorSuffixes.forEach((suffix) => {
failed += checkResult(suffix);
});
if (failed === 0) {
console.log(`${BOLD_GREEN}All generator tests passed.${ANSI_RESET}`);
} else {
console.log(
`${BOLD_RED}Failures in ${failed} generator tests.${ANSI_RESET}`);
throw new Error('Generator tests failed.');
}
});
}
/**
* Run the package build process, as Node tests depend on it.
* @return {Promise} asynchronous result
*/
function package() {
return runTestCommand('package', 'npm run package');
}
/**
* Run Node tests.
* @return {Promise} asynchronous result
*/
function node() {
return runTestCommand('node', 'mocha tests/node --config tests/node/.mocharc.js');
}
/**
* Attempt advanced compilation of a Blockly app.
* @return {Promise} asynchronous result
*/
function advancedCompile() {
return runTestCommand('advanced_compile', 'npm run test:compile:advanced');
}
/**
* Report test result.
* @return {Promise} asynchronous result
*/
function reportTestResult() {
console.log('=======================================');
// Check result.
if (failerCount === 0) {
console.log(`${BOLD_GREEN}All tests passed.${ANSI_RESET}`);
return Promise.resolve();
} else {
console.log(`${BOLD_RED}Failures in ${failerCount} test groups.${ANSI_RESET}`);
return Promise.reject();
}
}
// Indivisual tasks.
const testTasks = [
eslint,
buildDebug,
renamings,
metadata,
mocha,
generators,
package,
node,
advancedCompile,
reportTestResult,
];
// Run all tests in sequence.
const test = gulp.series(...testTasks);
module.exports = {
test,
generators,
};

35
scripts/helpers.js Normal file
View File

@@ -0,0 +1,35 @@
/**
* @license
* Copyright 2022 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Helper functions for build/test.
*/
/* eslint-env node */
const path = require('path');
/**
* Escape regular expression pattern
* @param {string} pattern regular expression pattern
* @return {string} escaped regular expression pattern
*/
function escapeRegex(pattern) {
return pattern.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
}
/**
* Replaces OS-specific path with POSIX style path.
* @param {string} target target path
* @return {string} posix path
*/
function posixPath(target) {
const osSpecificSep = new RegExp(escapeRegex(path.sep), 'g');
return target.replace(osSpecificSep, path.posix.sep);
}
module.exports = {
posixPath,
};

View File

@@ -9,6 +9,7 @@
*/
var webdriverio = require('webdriverio');
var fs = require('fs');
var path = require('path');
module.exports = runGeneratorsInBrowser;
@@ -35,9 +36,10 @@ async function runLangGeneratorInBrowser(browser, filename, codegenFn) {
* Runs the generator tests in Chrome. It uses webdriverio to
* launch Chrome and load index.html. Outputs a summary of the test results
* to the console and outputs files for later validation.
* @param {string} outputDir output directory
* @return the Thenable managing the processing of the browser tests.
*/
async function runGeneratorsInBrowser() {
async function runGeneratorsInBrowser(outputDir) {
var options = {
capabilities: {
browserName: 'chrome',
@@ -60,7 +62,7 @@ async function runGeneratorsInBrowser() {
}
var url = 'file://' + __dirname + '/index.html';
var prefix = 'tests/generators/tmp/generated';
var prefix = path.join(outputDir, 'generated');
console.log('Starting webdriverio...');
const browser = await webdriverio.remote(options);
@@ -97,7 +99,7 @@ async function runGeneratorsInBrowser() {
}
if (require.main === module) {
runGeneratorsInBrowser().catch(e => {
runGeneratorsInBrowser('tests/generators/tmp').catch(e => {
console.error(e);
process.exit(1);
}).then(function(result) {

3
tests/migration/validate-renamings.js Executable file → Normal file
View File

@@ -17,6 +17,7 @@ const JsonSchema = require('@hyperjump/json-schema');
const JSON5 = require('json5');
const fs = require('fs');
const path = require('path');
const {posixPath} = require('../../scripts/helpers');
/**
@@ -35,7 +36,7 @@ const RENAMINGS_FILENAME =
// Can't use top-level await outside a module, and can't use require
// in a module, so use an IIAFE.
(async function() {
const schemaUrl = 'file://' + path.resolve(SCHEMA_FILENAME);
const schemaUrl = 'file://' + posixPath(path.resolve(SCHEMA_FILENAME));
const schema = await JsonSchema.get(schemaUrl);
const renamingsJson5 = fs.readFileSync(RENAMINGS_FILENAME);

View File

@@ -8,6 +8,7 @@
* @fileoverview Node.js script to run Mocha tests in Chrome, via webdriver.
*/
var webdriverio = require('webdriverio');
var {posixPath} = require('../../scripts/helpers');
module.exports = runMochaTestsInBrowser;
@@ -44,7 +45,7 @@ async function runMochaTestsInBrowser() {
};
}
var url = 'file://' + __dirname + '/index.html';
var url = 'file://' + posixPath(__dirname) + '/index.html';
console.log('Starting webdriverio...');
const browser = await webdriverio.remote(options);
console.log('Initialized.\nLoading url: ' + url);

View File

@@ -1,91 +0,0 @@
#!/bin/bash
if [ ! -z $CI ]; then echo "Executing run_all_tests.sh from $(pwd)"; fi
# ANSI colors
BOLD_GREEN='\033[1;32m'
BOLD_RED='\033[1;31m'
ANSI_RESET='\033[0m'
gh_actions_fold () {
local startOrEnd=$1 # Either "start" or "end"
if [ ! -z $CI ]; then
echo "::$startOrEnd::"
fi
}
# Find the Blockly project root if pwd is the root
# or if pwd is the directory containing this script.
if [ -f ./run_all_tests.js ]; then
BLOCKLY_ROOT=".."
elif [ -f tests/run_all_tests.sh ]; then
BLOCKLY_ROOT="."
else
echo -e "${BOLD_RED}ERROR: Cannot determine BLOCKLY_ROOT${ANSI_RESET}" 1>&2;
exit 1
fi
pushd $BLOCKLY_ROOT
echo "pwd: $(pwd)"
FAILURE_COUNT=0
run_test_command () {
local test_id=$1 # The id to use for folds and similar. No spaces.
local command=$2 # The command to run.
echo "======================================="
echo "== $test_id"
gh_actions_fold group
$command
local test_result=$?
gh_actions_fold endgroup
if [ $test_result -eq 0 ]; then
echo -e "${BOLD_GREEN}SUCCESS:${ANSI_RESET} ${test_id}"
else
echo -e "${BOLD_RED}FAILED:${ANSI_RESET} ${test_id}"
FAILURE_COUNT=$((FAILURE_COUNT+1))
fi
}
# Lint the codebase.
# Skip for CI environments, because linting is run separately.
if [ -z $CI ]; then
run_test_command "eslint" "eslint ."
fi
# Run the full usual build process, checking to ensure there are no
# closure compiler warnings / errors.
run_test_command "build-debug" "npm run build-debug"
# Run renaming validation test.
run_test_command "renamings" "tests/migration/validate-renamings.js"
# Check the sizes of built files for unexpected growth.
run_test_command "metadata" "tests/scripts/check_metadata.sh"
# Run Mocha tests inside a browser.
run_test_command "mocha" "node tests/mocha/run_mocha_tests_in_browser.js"
# Run generator tests inside a browser and check the results.
run_test_command "generators" "tests/scripts/run_generators.sh"
# Run the package build process, as Node tests depend on it.
run_test_command "package" "npm run package"
# Run Node tests.
run_test_command "node" "./node_modules/.bin/mocha tests/node --config tests/node/.mocharc.js"
# Attempt advanced compilation of a Blockly app.
run_test_command "advanced_compile" "npm run test:compile:advanced"
# End of tests.
popd
echo "======================================="
if [ "$FAILURE_COUNT" -eq "0" ]; then
echo -e "${BOLD_GREEN}All tests passed.${ANSI_RESET}"
exit 0
else
echo -e "${BOLD_RED}Failures in ${FAILURE_COUNT} test groups.${ANSI_RESET}"
exit 1
fi

View File

@@ -1,57 +0,0 @@
#!/bin/bash
# ANSI colors
BOLD_GREEN='\033[1;32m'
BOLD_RED='\033[1;31m'
ANSI_RESET='\033[0m'
SUCCESS_PREFIX="${BOLD_GREEN}SUCCESS:${ANSI_RESET}"
FAILURE_PREFIX="${BOLD_RED}FAILED:${ANSI_RESET}"
TMP_DIR="tests/generators/tmp/"
GOLDEN_DIR="tests/generators/golden/"
FAILURE_COUNT=0
check_result() {
local suffix=$1 # One of: js, py, dart, lua, php
local tmp_filename="${TMP_DIR}generated.$suffix"
if [ -f $tmp_filename ]; then
local golden_filename="${GOLDEN_DIR}generated.$suffix"
if [ -f $golden_filename ]; then
if cmp $tmp_filename $golden_filename; then
echo -e "$SUCCESS_PREFIX $suffix: $tmp_filename matches $golden_filename"
else
echo -e "$FAILURE_PREFIX $suffix: $tmp_filename does not match $golden_filename"
FAILURE_COUNT=$((FAILURE_COUNT+1))
fi
else
echo "File $golden_filename not found!"
FAILURE_COUNT=$((FAILURE_COUNT+1))
fi
else
echo "File $tmp_filename not found!"
FAILURE_COUNT=$((FAILURE_COUNT+1))
fi
}
mkdir $TMP_DIR
node tests/generators/run_generators_in_browser.js
generator_suffixes=( "js" "py" "dart" "lua" "php" )
for i in "${generator_suffixes[@]}"
do
check_result "$i"
done
# Clean up.
rm -r $TMP_DIR
if [ "$FAILURE_COUNT" -eq "0" ]; then
echo -e "${BOLD_GREEN}All generator tests passed.${ANSI_RESET}"
exit 0
else
echo -e "${BOLD_RED}Failures in ${FAILURE_COUNT} generator tests.${ANSI_RESET}"
exit 1
fi