Add suite name to generator tests

This commit is contained in:
Rachel Fenichel
2018-10-18 17:47:58 -07:00
parent 5fcadc0a05
commit adb1921e21
16 changed files with 42 additions and 6 deletions

View File

@@ -60,6 +60,7 @@
</statement>
</block>
<block type="unittest_main" x="-5" y="49">
<field name="SUITE_NAME">Colour</field>
<statement name="DO">
<block type="procedures_callnoreturn">
<mutation name="test colour picker"></mutation>

View File

@@ -1,6 +1,7 @@
<xml xmlns="http://www.w3.org/1999/xhtml">
<!-- Do not include <variables> here to test backward compatibility. -->
<block type="unittest_main" x="0" y="1">
<field name="SUITE_NAME">Functions</field>
<statement name="DO">
<block type="procedures_callnoreturn">
<mutation name="test procedure"></mutation>

View File

@@ -1,5 +1,6 @@
<xml xmlns="http://www.w3.org/1999/xhtml">
<block type="unittest_main" x="13" y="13">
<field name="SUITE_NAME">Lists</field>
<statement name="DO">
<block type="procedures_callnoreturn">
<mutation name="test create"></mutation>
@@ -8281,4 +8282,4 @@
</block>
</statement>
</block>
</xml>
</xml>

View File

@@ -1,5 +1,6 @@
<xml xmlns="http://www.w3.org/1999/xhtml">
<block type="unittest_main" x="-13" y="-13">
<field name="SUITE_NAME">Logic</field>
<statement name="DO">
<block type="unittest_assertvalue" inline="false">
<field name="EXPECTED">TRUE</field>
@@ -1015,4 +1016,4 @@
</block>
</statement>
</block>
</xml>
</xml>

View File

@@ -1,5 +1,6 @@
<xml xmlns="http://www.w3.org/1999/xhtml">
<block type="unittest_main" x="33" y="140">
<field name="SUITE_NAME">Loops 1</field>
<statement name="DO">
<block type="procedures_callnoreturn">
<mutation name="test repeat"></mutation>

View File

@@ -1,5 +1,6 @@
<xml xmlns="http://www.w3.org/1999/xhtml">
<block type="unittest_main" x="66" y="-2">
<field name="SUITE_NAME">Loops 2</field>
<statement name="DO">
<block type="procedures_callnoreturn">
<mutation name="test count"></mutation>

View File

@@ -1,5 +1,6 @@
<xml xmlns="http://www.w3.org/1999/xhtml">
<block type="unittest_main" x="19" y="106">
<field name="SUITE_NAME">Loops 3</field>
<statement name="DO">
<block type="procedures_callnoreturn">
<mutation name="test break"></mutation>

View File

@@ -1,5 +1,6 @@
<xml xmlns="http://www.w3.org/1999/xhtml">
<block type="unittest_main" x="13" y="13">
<field name="SUITE_NAME">Math</field>
<statement name="DO">
<block type="procedures_callnoreturn">
<mutation name="test arithmetic"></mutation>
@@ -1946,4 +1947,4 @@
</block>
</statement>
</block>
</xml>
</xml>

View File

@@ -1,5 +1,6 @@
<xml xmlns="http://www.w3.org/1999/xhtml">
<block type="unittest_main" x="13" y="-63">
<field name="SUITE_NAME">Text</field>
<statement name="DO">
<block type="procedures_callnoreturn">
<mutation name="test length"></mutation>
@@ -4647,4 +4648,4 @@
</block>
</statement>
</block>
</xml>
</xml>

View File

@@ -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.');

View File

@@ -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');

View File

@@ -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');

View File

@@ -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');

View File

@@ -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');

View File

@@ -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');

View File

@@ -1,6 +1,7 @@
<xml xmlns="http://www.w3.org/1999/xhtml">
<!-- Do not include <variables> here to test backward compatibility. -->
<block type="unittest_main" x="0" y="0">
<field name="SUITE_NAME">Variables</field>
<statement name="DO">
<block type="variables_set" inline="false">
<field name="VAR">item</field>