fix: Fix the compiler test, and check if it worked. (#6638)

* 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.
This commit is contained in:
Neil Fraser
2022-11-25 20:45:00 +01:00
committed by GitHub
parent be4b8323c5
commit 5a64a9a7f7
14 changed files with 349 additions and 154 deletions

View File

@@ -19,7 +19,6 @@
<script src="../bootstrap.js"></script>
<script>
var demoWorkspace = null;
var outputCode = '';
function start() {
demoWorkspace = Blockly.inject('blocklyDiv', {
@@ -172,31 +171,26 @@ function toJavaScript() {
var code = '\'use strict\';\n\n'
code += javascriptGenerator.workspaceToCode(demoWorkspace);
setOutput(code);
outputCode = code;
}
function toPython() {
var code = pythonGenerator.workspaceToCode(demoWorkspace);
setOutput(code);
outputCode = code;
}
function toPhp() {
var code = phpGenerator.workspaceToCode(demoWorkspace);
setOutput(code);
outputCode = code;
}
function toLua() {
var code = luaGenerator.workspaceToCode(demoWorkspace);
setOutput(code);
outputCode = code;
}
function toDart() {
var code = dartGenerator.workspaceToCode(demoWorkspace);
setOutput(code);
outputCode = code;
}
function changeIndex() {
@@ -205,7 +199,7 @@ function changeIndex() {
demoWorkspace.getToolbox().flyout_.workspace_.options.oneBasedIndex = oneBasedIndex;
}
</script>
<script type=module>
<script type="module">
// Wait for Blockly to finish loading before running tests.
import '../bootstrap_done.mjs';

View File

@@ -5,13 +5,12 @@
*/
/**
* @fileoverview Node.js script to run generator tests in Firefox, via webdriver.
* @fileoverview Node.js script to run generator tests in Chrome, via webdriver.
*/
var webdriverio = require('webdriverio');
var fs = require('fs');
var path = require('path');
module.exports = runGeneratorsInBrowser;
/**
* Run the generator for a given language and save the results to a file.
@@ -36,8 +35,8 @@ 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.
* @param {string} outputDir Output directory.
* @return The Thenable managing the processing of the browser tests.
*/
async function runGeneratorsInBrowser(outputDir) {
var options = {
@@ -66,7 +65,7 @@ async function runGeneratorsInBrowser(outputDir) {
console.log('Starting webdriverio...');
const browser = await webdriverio.remote(options);
console.log('Initialized.\nLoading url: ' + url);
console.log('Loading url: ' + url);
await browser.url(url);
await browser.execute(function() {
@@ -112,3 +111,5 @@ if (require.main === module) {
}
});
}
module.exports = {runGeneratorsInBrowser};