mirror of
https://github.com/google/blockly.git
synced 2026-01-04 15:40:08 +01:00
* 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.
83 lines
2.2 KiB
JavaScript
83 lines
2.2 KiB
JavaScript
/**
|
|
* @license
|
|
* Copyright 2022 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
/**
|
|
* @fileoverview Node.js script to check the health of the compile test in
|
|
* Chrome, via webdriver.
|
|
*/
|
|
const webdriverio = require('webdriverio');
|
|
|
|
|
|
/**
|
|
* Run the generator for a given language and save the results to a file.
|
|
* @param {Thenable} browser A Thenable managing the processing of the browser
|
|
* tests.
|
|
*/
|
|
async function runHealthCheckInBrowser(browser) {
|
|
const result = await browser.execute(() => {
|
|
return healthCheck();
|
|
})
|
|
if (!result) throw Error('Health check failed in advanced compilation test.');
|
|
console.log('Health check completed successfully.');
|
|
}
|
|
|
|
/**
|
|
* 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.
|
|
* @return the Thenable managing the processing of the browser tests.
|
|
*/
|
|
async function runCompileCheckInBrowser() {
|
|
const options = {
|
|
capabilities: {
|
|
browserName: 'chrome',
|
|
},
|
|
logLevel: 'warn',
|
|
services: ['selenium-standalone']
|
|
};
|
|
// Run in headless mode on Github Actions.
|
|
if (process.env.CI) {
|
|
options.capabilities['goog:chromeOptions'] = {
|
|
args: ['--headless', '--no-sandbox', '--disable-dev-shm-usage']
|
|
};
|
|
} else {
|
|
// --disable-gpu is needed to prevent Chrome from hanging on Linux with
|
|
// NVIDIA drivers older than v295.20. See
|
|
// https://github.com/google/blockly/issues/5345 for details.
|
|
options.capabilities['goog:chromeOptions'] = {
|
|
args: ['--disable-gpu']
|
|
};
|
|
}
|
|
|
|
const url = 'file://' + __dirname + '/index.html';
|
|
|
|
console.log('Starting webdriverio...');
|
|
const browser = await webdriverio.remote(options);
|
|
console.log('Loading url: ' + url);
|
|
await browser.url(url);
|
|
|
|
await runHealthCheckInBrowser(browser);
|
|
|
|
await browser.deleteSession();
|
|
}
|
|
|
|
if (require.main === module) {
|
|
runCompileCheckInBrowser().catch(e => {
|
|
console.error(e);
|
|
process.exit(1);
|
|
}).then(function(result) {
|
|
if (result) {
|
|
console.log('Compile test failed');
|
|
process.exit(1);
|
|
} else {
|
|
console.log('Compile test passed');
|
|
process.exit(0);
|
|
}
|
|
});
|
|
}
|
|
|
|
module.exports = {runCompileCheckInBrowser};
|