mirror of
https://github.com/google/blockly.git
synced 2026-01-10 02:17:09 +01:00
Run generator tests and save a file with the generated js!
This commit is contained in:
@@ -259,6 +259,27 @@ function changeIndex() {
|
||||
demoWorkspace.options.oneBasedIndex = oneBasedIndex;
|
||||
demoWorkspace.toolbox_.flyout_.workspace_.options.oneBasedIndex = oneBasedIndex;
|
||||
}
|
||||
|
||||
//https://stackoverflow.com/a/18197341
|
||||
function download(filename, text) {
|
||||
var element = document.createElement('a');
|
||||
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
|
||||
element.setAttribute('download', filename);
|
||||
|
||||
element.style.display = 'none';
|
||||
document.body.appendChild(element);
|
||||
|
||||
element.click();
|
||||
|
||||
document.body.removeChild(element);
|
||||
}
|
||||
|
||||
function downloadOutputCode() {
|
||||
|
||||
console.log('clicked!');
|
||||
download('outputcode.js', outputCode);
|
||||
console.log('and done');
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
@@ -446,6 +467,9 @@ h1 {
|
||||
<br><a target="_blank" href="https://dartpad.dartlang.org/">interpreter</a>
|
||||
</div>
|
||||
</p>
|
||||
<p>
|
||||
<input type="button" value="download" onclick="downloadOutputCode()">
|
||||
</p>
|
||||
</td></tr><tr><td height="99%">
|
||||
<textarea id="importExport" readonly="readonly" wrap="off"></textarea>
|
||||
</td></tr></table>
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
* @fileoverview Node.js script to run JsUnit tests in Chrome, via webdriver.
|
||||
*/
|
||||
var webdriverio = require('webdriverio');
|
||||
var fs = require('fs');
|
||||
|
||||
/*
|
||||
* Notes
|
||||
@@ -98,6 +99,21 @@ function runJsGeneratorTestsInBrowser() {
|
||||
// }
|
||||
// })
|
||||
.pause(10000)
|
||||
.getValue("#importExport")
|
||||
.then(function(result) {
|
||||
fs.writeFile("test.js", result, function(err) {
|
||||
if (err) {
|
||||
return console.log(err);
|
||||
}
|
||||
//console.log("The file was saved!");
|
||||
});
|
||||
// console.log('start result')
|
||||
// console.log('======')
|
||||
// console.log(result)
|
||||
// console.log('======')
|
||||
// console.log('end result');
|
||||
})
|
||||
.pause(10000)
|
||||
.catch(function(e) {
|
||||
console.error('Error: ', e);
|
||||
|
||||
|
||||
@@ -56,7 +56,10 @@ run_test_command "test_setup" "tests/scripts/test_setup.sh"
|
||||
# run_test_command "eslint" "eslint ."
|
||||
|
||||
# Run JSUnit tests inside a browser.
|
||||
run_test_command "jsunit" "node tests/jsunit/run_jsunit_tests_in_browser.js"
|
||||
#run_test_command "jsunit" "node tests/jsunit/run_jsunit_tests_in_browser.js"
|
||||
run_test_command "generators" "node tests/generators/run_js_generator_tests_in_browser.js"
|
||||
#run_test_command "fs_test" "node tests/generators/fs_test.js"
|
||||
|
||||
# TODO: Make sure jsunit output is captured. Child process?
|
||||
|
||||
# # Attempt advanced compilation of a Blockly app.
|
||||
|
||||
Reference in New Issue
Block a user