From ce6c6d1ba0ba04309d722835eba5ad7bb695104b Mon Sep 17 00:00:00 2001 From: RunDevelopment Date: Mon, 15 Jun 2020 23:55:07 +0200 Subject: [PATCH 1/2] Tests: Pretty-printed token stream by default --- test-suite.html | 3 +-- tests/helper/test-case.js | 5 ++--- tests/run.js | 3 +-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/test-suite.html b/test-suite.html index 4d4105482f..e95a5d4546 100644 --- a/test-suite.html +++ b/test-suite.html @@ -125,9 +125,8 @@

Explaining the sim
  • All strings that are either empty or only contain whitespace, are removed from the token stream.
  • All empty structures are removed.
  • -

    To get a pretty-printed version of the simplified token stream of a failed test, add the --pretty modifier. Keep in mind that the pretty-printed token stream is indented using spaces, you may need to convert these to tabs. (Most editors today have an option which handles the conversion for you.)

    -
    npm run test:languages -- --pretty
    +

    Note: The pretty-printed simplified token stream is indented using 4 spaces. You have to convert these to tabs after you copy-pasted the JSON. (Most editors today have an option that handles the conversion for you.)

    For further information: reading the tests of the test runner (tests/testrunner-tests.js) will help you understand the transformation.

    diff --git a/tests/helper/test-case.js b/tests/helper/test-case.js index 7fe1062afb..30d26ca72e 100644 --- a/tests/helper/test-case.js +++ b/tests/helper/test-case.js @@ -49,9 +49,8 @@ module.exports = { * * @param {string} languageIdentifier * @param {string} filePath - * @param {boolean} [pretty=false] */ - runTestCase(languageIdentifier, filePath, pretty = false) { + runTestCase(languageIdentifier, filePath) { const testCase = this.parseTestCaseFile(filePath); const usedLanguages = this.parseLanguageNames(languageIdentifier); @@ -79,7 +78,7 @@ module.exports = { const columnNumber = expectedJsonLines.pop().length + 1; const lineNumber = testCase.expectedLineOffset + expectedJsonLines.length; - const tokenStreamStr = pretty ? TokenStreamTransformer.prettyprint(simplifiedTokenStream) : actual; + const tokenStreamStr = TokenStreamTransformer.prettyprint(simplifiedTokenStream); const message = "\n\nActual Token Stream:" + "\n-----------------------------------------\n" + tokenStreamStr + diff --git a/tests/run.js b/tests/run.js index 11c036d956..70afb438a0 100644 --- a/tests/run.js +++ b/tests/run.js @@ -11,7 +11,6 @@ const testSuite = ? TestDiscovery.loadSomeTests(__dirname + "/languages", argv.language) // load complete test suite : TestDiscovery.loadAllTests(__dirname + "/languages"); -const pretty = 'pretty' in argv; // define tests for all tests in all languages in the test suite for (const language in testSuite) { @@ -28,7 +27,7 @@ for (const language in testSuite) { it("– should pass test case '" + fileName + "'", function () { if (path.extname(filePath) === '.test') { - TestCase.runTestCase(language, filePath, pretty); + TestCase.runTestCase(language, filePath, true); } else { TestCase.runTestsWithHooks(language, require(filePath)); } From d4b26875386861c70c8af83f1171e43d8a71bdea Mon Sep 17 00:00:00 2001 From: Michael Schmidt Date: Sat, 20 Jun 2020 14:11:59 +0200 Subject: [PATCH 2/2] Removed unnecessary parameter --- tests/run.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/run.js b/tests/run.js index 70afb438a0..b9c8893ffe 100644 --- a/tests/run.js +++ b/tests/run.js @@ -27,7 +27,7 @@ for (const language in testSuite) { it("– should pass test case '" + fileName + "'", function () { if (path.extname(filePath) === '.test') { - TestCase.runTestCase(language, filePath, true); + TestCase.runTestCase(language, filePath); } else { TestCase.runTestsWithHooks(language, require(filePath)); }