diff --git a/tests/generators/colour.xml b/tests/generators/colour.xml index 747e54941..273b372c9 100644 --- a/tests/generators/colour.xml +++ b/tests/generators/colour.xml @@ -60,6 +60,7 @@ + Colour diff --git a/tests/generators/functions.xml b/tests/generators/functions.xml index a3489325d..e43dc7dd5 100644 --- a/tests/generators/functions.xml +++ b/tests/generators/functions.xml @@ -1,6 +1,7 @@ + Functions diff --git a/tests/generators/index.html b/tests/generators/index.html index 4a73a3bd6..e1e5a1720 100644 --- a/tests/generators/index.html +++ b/tests/generators/index.html @@ -91,7 +91,7 @@ function start() { } /* - * Run this test to load all of the test files in all_test_names. The contents + * Run this test to load all of the tests in the selected suites. The contents * will be loaded into the workspace in order. To test the generators: * - select your language from the buttons above the text area * - copy all of the generated code @@ -101,20 +101,26 @@ function start() { * If some tests are failing, load test suites individually to continue * debugging. */ -function loadAll() { +function loadSelected() { var output = document.getElementById('importExport'); output.style.background = 'gray'; var loadingElem = document.getElementById('loading'); loadingElem.textContent = 'loading...'; - var options = document.getElementById('testUrl').options; - for (var i = 0; i < options.length; i++) { - var testUrl = options[i].value; - if (testUrl) { - var xmlText = fetchFile(testUrl); - if (xmlText !== null) { - fromXml(testUrl, xmlText, /* opt_append */ true); + // Clear before adding all of the blocks. + demoWorkspace.clear(); + + var boxList = document.getElementById('checkboxes'); + var inputChildren = boxList.getElementsByTagName('input'); + for (var i = 0; i < inputChildren.length; i++) { + if (inputChildren[i].checked) { + var testUrl = inputChildren[i].value; + if (testUrl) { + var xmlText = fetchFile(testUrl); + if (xmlText !== null) { + fromXml(testUrl, xmlText, /* opt_append */ true); + } } } } @@ -122,14 +128,13 @@ function loadAll() { loadingElem.textContent = 'done'; } -function loadXml() { - var dropdown = document.getElementById('testUrl'); - var url = dropdown.options[dropdown.selectedIndex].value; +/** + * Ask the user for a file name, then load that file's contents. + */ +function loadOther() { + var url = window.prompt('Enter URL of test file.'); if (!url) { - url = window.prompt('Enter URL of test file.'); - if (!url) { - return; - } + return; } var xmlText = fetchFile(url); if (xmlText !== null) { @@ -189,6 +194,22 @@ function fromXml(filename, xmlText, opt_append) { } } +function checkAll() { + var boxList = document.getElementById('checkboxes'); + var inputChildren = boxList.getElementsByTagName('input'); + for (var i = 0; i < inputChildren.length; i++) { + inputChildren[i].checked = true; + } +} + +function uncheckAll() { + var boxList = document.getElementById('checkboxes'); + var inputChildren = boxList.getElementsByTagName('input'); + for (var i = 0; i < inputChildren.length; i++) { + inputChildren[i].checked = false; + } +} + function setOutput(text) { var output = document.getElementById('importExport'); output.value = text; @@ -369,26 +390,28 @@ h1 {

See the docs for details on running the tests. -

- - -

+ +
+ +
+ Logic
+ Loops 1 (repeat, while, foreach)
+ Loops 2 (count)
+ Loops 3 (continue, break)
+ Math
+ Text
+ Lists
+ Colour
+ Variables
+ Functions
+

- - + + +

+

+

diff --git a/tests/generators/lists.xml b/tests/generators/lists.xml index aae25dfe6..32fb6aae7 100644 --- a/tests/generators/lists.xml +++ b/tests/generators/lists.xml @@ -1,5 +1,6 @@ + Lists @@ -8281,4 +8282,4 @@ - \ No newline at end of file + diff --git a/tests/generators/logic.xml b/tests/generators/logic.xml index 9737fb812..8131de259 100644 --- a/tests/generators/logic.xml +++ b/tests/generators/logic.xml @@ -1,5 +1,6 @@ + Logic TRUE @@ -1015,4 +1016,4 @@ - \ No newline at end of file + diff --git a/tests/generators/loops1.xml b/tests/generators/loops1.xml index 41dd3b633..41ba34ee2 100644 --- a/tests/generators/loops1.xml +++ b/tests/generators/loops1.xml @@ -1,5 +1,6 @@ + Loops 1 diff --git a/tests/generators/loops2.xml b/tests/generators/loops2.xml index c35623a5d..0f0411c67 100644 --- a/tests/generators/loops2.xml +++ b/tests/generators/loops2.xml @@ -1,5 +1,6 @@ + Loops 2 diff --git a/tests/generators/loops3.xml b/tests/generators/loops3.xml index 508b88729..30f0a2f52 100644 --- a/tests/generators/loops3.xml +++ b/tests/generators/loops3.xml @@ -1,5 +1,6 @@ + Loops 3 diff --git a/tests/generators/math.xml b/tests/generators/math.xml index 3988ebd6e..ae0001375 100644 --- a/tests/generators/math.xml +++ b/tests/generators/math.xml @@ -1,5 +1,6 @@ + Math @@ -1946,4 +1947,4 @@ - \ No newline at end of file + diff --git a/tests/generators/text.xml b/tests/generators/text.xml index 32887ec93..597b3931d 100644 --- a/tests/generators/text.xml +++ b/tests/generators/text.xml @@ -1,5 +1,6 @@ + Text @@ -4647,4 +4648,4 @@ - \ No newline at end of file + diff --git a/tests/generators/unittest.js b/tests/generators/unittest.js index 6b7378210..96bea3342 100644 --- a/tests/generators/unittest.js +++ b/tests/generators/unittest.js @@ -29,7 +29,8 @@ Blockly.Blocks['unittest_main'] = { init: function() { this.setColour(65); this.appendDummyInput() - .appendField('run tests'); + .appendField('run test suite') + .appendField(new Blockly.FieldTextInput(''), 'SUITE_NAME'); this.appendStatementInput('DO'); this.setTooltip('Executes the enclosed unit tests,\n' + 'then prints a summary.'); diff --git a/tests/generators/unittest_dart.js b/tests/generators/unittest_dart.js index 436bcff63..28b14e670 100644 --- a/tests/generators/unittest_dart.js +++ b/tests/generators/unittest_dart.js @@ -59,6 +59,11 @@ Blockly.Dart['unittest_main'] = function(block) { '}']); // Setup global to hold test results. var code = resultsVar + ' = [];\n'; + // Say which test suite this is. + code += 'print(\'\\n====================\\n\\n' + + 'Running suite: ' + + block.getFieldValue('SUITE_NAME') + + '\');\n'; // Run tests (unindented). code += Blockly.Dart.statementToCode(block, 'DO') .replace(/^ /, '').replace(/\n /g, '\n'); diff --git a/tests/generators/unittest_javascript.js b/tests/generators/unittest_javascript.js index 92d8a2913..e483be1b8 100644 --- a/tests/generators/unittest_javascript.js +++ b/tests/generators/unittest_javascript.js @@ -60,6 +60,11 @@ Blockly.JavaScript['unittest_main'] = function(block) { '}']); // Setup global to hold test results. var code = resultsVar + ' = [];\n'; + // Say which test suite this is. + code += 'console.log(\'\\n====================\\n\\n' + + 'Running suite: ' + + block.getFieldValue('SUITE_NAME') + + '\')\n'; // Run tests (unindented). code += Blockly.JavaScript.statementToCode(block, 'DO') .replace(/^ /, '').replace(/\n /g, '\n'); diff --git a/tests/generators/unittest_lua.js b/tests/generators/unittest_lua.js index 2a9015c10..1d0860bdc 100644 --- a/tests/generators/unittest_lua.js +++ b/tests/generators/unittest_lua.js @@ -58,6 +58,11 @@ Blockly.Lua['unittest_main'] = function(block) { 'end']); // Setup global to hold test results. var code = resultsVar + ' = {}\n'; + // Say which test suite this is. + code += 'print(\'\\n====================\\n\\n' + + 'Running suite: ' + + block.getFieldValue('SUITE_NAME') + + '\')\n'; // Run tests (unindented). code += Blockly.Lua.statementToCode(block, 'DO') .replace(/^ /, '').replace(/\n /g, '\n'); diff --git a/tests/generators/unittest_php.js b/tests/generators/unittest_php.js index 54d7e4e97..4d030ea83 100644 --- a/tests/generators/unittest_php.js +++ b/tests/generators/unittest_php.js @@ -52,7 +52,7 @@ Blockly.PHP['unittest_main'] = function(block) { ' array_push($report, "Number of tests run: " . count(' + resultsVar + '));', ' array_push($report, "");', ' if ($fails) {', - ' array_push($report, "FAILED (failures=" . $fails + ")");', + ' array_push($report, "FAILED (failures=" . $fails . ")");', ' } else {', ' array_push($report, "OK");', ' }', @@ -60,6 +60,11 @@ Blockly.PHP['unittest_main'] = function(block) { '}']); // Setup global to hold test results. var code = resultsVar + ' = array();\n'; + // Say which test suite this is. + code += 'print("\\n====================\\n\\n' + + 'Running suite: ' + + block.getFieldValue('SUITE_NAME') + + '\\n");\n'; // Run tests (unindented). code += Blockly.PHP.statementToCode(block, 'DO') .replace(/^ /, '').replace(/\n /g, '\n'); diff --git a/tests/generators/unittest_python.js b/tests/generators/unittest_python.js index 91fabd179..70f6773e1 100644 --- a/tests/generators/unittest_python.js +++ b/tests/generators/unittest_python.js @@ -56,6 +56,11 @@ Blockly.Python['unittest_main'] = function(block) { // Setup global to hold test results. var code = resultsVar + ' = []\n'; + // Say which test suite this is. + code += 'print(\'\\n====================\\n\\n' + + 'Running suite: ' + + block.getFieldValue('SUITE_NAME') + + '\')\n'; // Run tests (unindented). code += Blockly.Python.statementToCode(block, 'DO') .replace(/^ /, '').replace(/\n /g, '\n'); diff --git a/tests/generators/variables.xml b/tests/generators/variables.xml index a3e5848a4..9bc507602 100644 --- a/tests/generators/variables.xml +++ b/tests/generators/variables.xml @@ -1,6 +1,7 @@ + Variables item