* feat: added `tests/typescript` to test supported TS examples
* fix: update the test name, description, and output
* chore: remove unused imports in `test_tasks.js`
* fix: wrap README line at 80 characters
* fix: implemented `different_user_input.ts` feedback
* fix: correct mistaken comments
* chore: rename `./eslintrc.json` to `./eslintrc.js`
* feat: added linting for tests/typescript
* chore: cleanup eslintrc lines over 80 characters
* fix: updated `.eslintrc.js` to provide an override for linting itself
* fix: updated tests to build to the `build` directory
* feat: updated `gulp format` to handle formatting `.eslintrc.js`
* fix: updated `.eslintrc.js` to align with both formatter and linter
* fix: updated config comment wording
* fix: removed quotes for valid identifiers
* Revert "fix: removed quotes for valid identifiers"
This reverts commit 03eff91aea1468e503bc79a90fb139914d3f39d2.
* Add tsick.js to rewrite enums.
tsc generates JavaScript which is incompatible with the Closure Compiler's advanced optimizations.
* Remove unused 'outputCode' variable.
* Rename 'run_X_in_browser.js' to 'webdriver.js'
The Mocha and generator tests can both be run either manually or via our webdriver. In all cases they run in a browser. These two 'run_X_in_browser.js' files only apply to webdriver, thus they are confusingly named.
Also delete completely unused (and broken) `run_all_tests.sh`
* Linting improvements to mocha/webdriver.js
Still not at 100%. Complains about require/module/process/__dirname not being defined in multiple places.
* runTestBlock -> runTestFunction
'Block' means something very different in Blockly.
* Removal of `var` from scripts.
* Add webdriver test to verify compile test worked.
* Resolve conficts with 'develop'.
* Address PR comments.
* refactor(tests): Move and rename prepare.js, blockly.mjs
Since prepare.js and blockly.mjs are going to be needed for running
all tests in uncompiled mode (not just the playgrounds), move them
tests/. Further, rename prepare.js to bootstrap.js to better reflect
its purpose.
* feat(tests): Introduce BLOCKLY_BOOTSTRAP_OPTIONS
Provide a mechanism for web pages that use bootstrap.js to control
what is loaded and how.
* fix(tests): Use the blockly repository path for all script src= URLs
Previously the (non-advanced) playground was only correctly loadging
on localhost because you can put an arbitrary number of "../"s in front
of a relative URL and it just takes you to the root directory.
* fix(tests): Don't use template literals in bootstrap.js
This is necessary (but not necessarily sufficient) to be able to
load the file in IE 11.
* fix(tests): Throw error if attempting to bootstrap in node.js
* feat(tests): Make bootstrap.js more configurable.
* Terminology change: use "compressed" and "uncompressed" to describe
what Closure Compiler calls "compiled" and "uncompiled", to reduce
confusion with the compilation that will be done by tsc.
* Get the list of modules to bootstrap (in compressed mode), or
scripts to load (in compressed mode) from BLOCKLY_BOOTSTRAP_OPTIONS,
to allow calling scripts to to specify exactly what to load.
* feat(tests): Use a proper quote function
We need to generate string literals. Best to use a quote function
instead of concatenating on quote marks withou escaping. Copy a
well-tested one from Code City.
* feat(tests): Support an additionalScripts option
This is a list of scripts to load (in order) once the required modules
have been bootstrapped.
We do this using goog.addDependency to make the first script depend
on the required modules, then each subsequent script depend on the
previous one, and then finally goog.bootstrapping the last such script.
* refactor(tests): Remove special handling of msg/messages.js
* refactor(tests): Use additionalScripts for all script loading
Use additionalScripts option for all script loading in
playground.html and advanced_playground.html.
* refactor(tests): Use bootstrap instead of uncompressed in Mocha tests
Use tests/bootstrap.js instead of blockly_uncompressed.js to load
blockly in uncompressed mode in the Mocha tests.
This entails adding a new item, despFiles, to BLOCKLY_BOOTSTRAP_OPTIONS,
to allow tests/deps.mocha.js to be loaded at the appropriate point.
Mention of blockly_uncompressed.js is removed from
tests/mocah/.mocharc.js; it's not clear to me what effect the "file:"
directive in this file might have previously had and I was not able to
find documentation for it on mochajs.org, but in any case removing it
appears to have had no ill effect.
* refactor(tests): Use bootstrap instead of uncompressed in generator tests
This entails adding an additional check in bootstrap so as to load
uncompressed when loading from a file: URL, since these are not
localhost URLs - though in fact the generator tests run equally well
in compressed mode, albeit against (for now) the previously-check-in
build products rather than the live code.
* refactor(test): Use bootstrap.js in multi_playground.html
This removes the last use of load_all.js, so remove it.
* chore(tests): Delete blockly_uncompressed.js
Its function has now been entirely subsumed by tests/bootstrap.js,
so remove it and update any remaining mentions of it.
Also fix formatting and positions of some comments in playground.html.
* fix(tests): Rewrite bootstrap sequencing code
An earlier commit modified the generated <script> to use
goog.addDependency to trick the debug module loader into loading
.additionalScripts (via goog.bootstrap), but it turns out there is
a small problem: scripts like msg/messages.js have undeclared
dependencies on the Blockly module, and without a call to
goog.require('Blockly') in them they can end up being run before
the Blockly module is fully loaded.
(This problem only occurs when there are ES Modules, rather than
merely goog.modules, in the mix.)
Fix this by adding a script, bootstrap_helper.js, to be loaded
options.requires and any options.additionalScripts that makes an
explicit call to goog.require for each of option.requires.
Also refactor the code so that instead of generating a loop which
calls goog.addDependency, we generate the addDependency calls
directly. This makes debugging a bit easer as we can use the browser's
dev tools to inspect the generated calls in the DOM tree.
* fix(tests): Prevent spurious transpilation warnings
For some reason when the debug module loader encounters ES modules
it starts to complain about being unable to transpile some ES202x
features in other (non-ESM) modules, even though it doesn't normally
try to transpile those.
Since uncompressed-mode testing is almost exclusively on modern
browsers we don't care about transpiling these features, so suppress
the warnings instead.
* refactor(tests): Rename blockly.mjs to bootstrap_done.mjs; simplify
Since blockly.mjs is no longer returning just the exports object
from core/blockly.js (see PR #5995), it might be better named after
its actual purpose: to wait for bootstrapping to be done.
Remove all the code that was used to pass the blockly.js exports
object along from the bootstrap callback to the blockly.mjs export,
since there's no reason to go to a lot of trouble to set a local
variable named Blockly to the same value as a global variable named
Blockly.
(Something like this may be needed again in future, but certainly in
a different form.)
* chore(tests): Use freshly-build files in compressed mode.
Use the freshly-built build/*_compresssed.js files when bootstrapping
in compressed mode, rather than using the checked-in files in the
repository root.
This helps ensure that compressed and uncompressed mode will be
testing (as closely as possible) the same code.
* chore(tests): Rename BlocklyLoader to blocklyLoader; record compressed
- Rename the BlocklyLoader global to blocklyLoader (since it is not
a class constructor).
- Create it regardless of whether we are bootstrapping in
uncompressed or loading compressed via <script> tags.
- Record which we are doing as .compressed, and use this property
to choose playground background colour.
* chore(tests): Resolve comments for PR #6214
Mostly documentation changes, but notably renaming blocklyLoader to
bootstrapInfo.
* Revert "chore(tests): Use freshly-build files in compressed mode."
This reverts commit de8d356838.
* chore(deps): Update closure/goog/base.js, add goog.js
- Update base.js from the latest version (20220502.0.0).
- Also copy over goog.js, which provides access to a suitable subset
of goog.* via an importable module).
* chore(build): Split gulpfiles/config.js exports object
This makes it possible for entries to depend on each other.
* chore(build): build config consistency
- Reorder entries in gulpfiles.config.js to better match order they
are used.
- Have update_metadata.sh reference config.js and vice versa.
* refactor(build): Move deps.js (+ deps.mocha.js) from test/ to build/
Once we start using tsc, deps.js will be created based on the ouptut
of tsc rather than the raw source in core/. Since tsc will need to
be run before running closure-make-deps and also before trying to
load blockly_uncompressed.js, it doesn't really make sense to check
in deps.js; it's better to re-create as needed.
To reduce inconvenience, a new "prepare" script is added to
package.json which will run the buildDeps gulp target automaticaly
when one runs npm install.
* refactor(build): Always build from TypeScript sources
- Add buildJavaScript gulp task to use tsc to compile any .ts files
in core/ into build/src/core/ (and also copy any .js files that
are not yet migrated to TypeScript, which for now is all of them.
- Remove closure/goog from explicit inputs to tsc; it will find
the files it needs (e.g., goog.js) automatically.
- Have buildDeps, the playground, and all the tests that run in
uncompiled mode use build/src/core/ instead of core/ as their
input directory.
* feat(build): Add buildJavaScriptAndDeps gulp task
Have npm run build:deps (and npm run prepare) use a new gulp task,
buildJavaScriptAndDeps, to run tsc followed by closure-make-deps,
ensuring that deps.js is calculated based on the most recent code
in core/.
* fix(build): Fix implementation of flattenCorePaths
Even though this function is going away I want to remove it in
a separate PR so that we can revert easily if desired. But the
previous checked-in code was totally wrong. This version works.
* fix(build): Don't let checkinBuilt copy build/src/**
Now that we are putting a lot more stuff in build/ (specifically,
all the tsc output in build/src/), modify checkinBuilt so that it
only copies the specific things we want to check in (for now):
- _compressed.js build artifacts and their accompanying .js.maps
- the generated build/msg/js/*.js language files.
Unrelatedly, also fix safety-quoting of arguments for one execSync
call.
* chore(build): add a script to run the ts compiler and send the new files to closure compiler
* chore(build): clean up tsconfig
* chore: apply suggestions from code review
Cleanup from Chris
Co-authored-by: Christopher Allen <cpcallen+github@gmail.com>
Co-authored-by: Christopher Allen <cpcallen+github@gmail.com>
I had forgotten that I needed to change the value of BUILD_DIR
in several different places.
Added comments warning future editors about this as well as filing
issue #5007 to track fixing this properly.
Despite being misconfigured and therefore failing, the typescript
and metadata test scripts were exiting with status 0, indicating
successful completion. These have been fixed so they should fail
on any error, including misconfiguration.
I have verified that
npm run build && npm run package
produces an identical dist/ directory compared to the one produced prior
to this and the previous commit.
Make the destination directories for certain build/package/release
steps more easily (and centrally) configurable.
This only deals with building *_compressed* files;
blockly_uncompressed.js and the various msg/js/*.js files are not
affected by this commit.