refactor(tests): Migrate generator tests to import shims; delete bootstrap.js (#7414)

* refactor(tests): Use shims instead of bootstrap to load Blockly

  - Modify tests/generators/index.html to import the test shims
    instead of using bootstrap.js to load Blockly.

  - Modify test/generators/webdriver.js to have it wait for the
    workspace to exist before calling loadSelected().  There was
    previously a race which index.html had been winning, but
    now webdriver.js is winning (and the tests failing because
    there is no workspace yet when start() is called.

* chore(tests): Delete bootstrap.js etc.

  - Delete bootstrap.js, bootstrap_helper.js, and bootstrap_done.mjs.
  - Remove remaining references to bootstrap.js

* refactor(build): Remove deps npm script

  buildDeps is now only needed by buildCompiled, not ever for
  runnning in uncompressed mode, so:

  - Remove the deps gulp task (and the deps npm script.
  - Have the minify task run buildJavaScript and buildDeps directly.

  Additionally, the buildAdvanceCompilationTest target hasn't
  needed deps.js for some time (if ever), so skip having it run
  buildDeps entirely.

* refactor(build): Repatriate DEPS_FILE to build_tasks.js

  Since this is no longer used anywhere else it doesn't need to
  live in common.js.

* fix(scripts): Remove vestigial references to deps.mocha.js

* docs(tests): Add additional explanatory note
This commit is contained in:
Christopher Allen
2023-08-31 01:02:58 +02:00
committed by GitHub
parent 7e9d1eb3ba
commit be809d9d98
11 changed files with 50 additions and 409 deletions

View File

@@ -4,20 +4,12 @@
<meta charset="utf-8">
<title>Blockly Generator Tests</title>
<script>
var BLOCKLY_BOOTSTRAP_OPTIONS = {
scripts: [
'build/msg/en.js',
'tests/generators/unittest_javascript.js',
'tests/generators/unittest_python.js',
'tests/generators/unittest_php.js',
'tests/generators/unittest_lua.js',
'tests/generators/unittest_dart.js',
'tests/generators/unittest.js',
],
}
</script>
<script src="../bootstrap.js"></script>
<script>
// N.B.: This script depends on the following (module) script to load
// Blockly, the code generators, and the unittest*.js scripts. The
// module script actually gets executed after this one, so although
// Blockly will be available when the defined global functions are
// called it isn't yet available when this script runs.
var demoWorkspace = null;
function start() {
@@ -199,9 +191,31 @@ function changeIndex() {
demoWorkspace.getToolbox().flyout_.workspace_.options.oneBasedIndex = oneBasedIndex;
}
</script>
<script type="module">
// Wait for Blockly to finish loading before running tests.
import '../bootstrap_done.mjs';
import {loadScript} from '../scripts/load.mjs';
import * as Blockly from '../../build/blockly.loader.mjs';
import '../../build/blocks.loader.mjs';
import {dartGenerator} from '../../build/dart.loader.mjs';
import {luaGenerator} from '../../build/lua.loader.mjs';
import {javascriptGenerator} from '../../build/javascript.loader.mjs';
import {phpGenerator} from '../../build/php.loader.mjs';
import {pythonGenerator} from '../../build/python.loader.mjs';
globalThis.dartGenerator = dartGenerator;
globalThis.luaGenerator = luaGenerator;
globalThis.javascriptGenerator = javascriptGenerator;
globalThis.phpGenerator = phpGenerator;
globalThis.pythonGenerator = pythonGenerator;
await loadScript('../../build/msg/en.js');
await loadScript('./unittest_javascript.js');
await loadScript('./unittest_python.js');
await loadScript('./unittest_php.js');
await loadScript('./unittest_lua.js');
await loadScript('./unittest_dart.js');
await loadScript('./unittest.js');
start();
</script>

View File

@@ -73,6 +73,10 @@ async function runGeneratorsInBrowser(outputDir) {
console.log('Loading url: ' + url);
await browser.url(url);
await browser
.$('.blocklySvg .blocklyWorkspace > .blocklyBlockCanvas')
.waitForExist({timeout: 2000});
await browser.execute(function() {
checkAll();
loadSelected();