Skip to content

Commit 583e7eb

Browse files
Tests: Always pretty-print token streams (#2421)
1 parent 4ff555b commit 583e7eb

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

test-suite.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,8 @@ <h2 id="writing-tests-explaining-the-simplified-token-stream">Explaining the sim
125125
<li>All strings that are either empty or only contain whitespace, are removed from the token stream.</li>
126126
<li>All empty structures are removed.</li>
127127
</ul>
128-
<p>To get a pretty-printed version of the simplified token stream of a failed test, add the <code>--pretty</code> 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.)</p>
129128

130-
<pre><code class="language-bash">npm run test:languages -- --pretty</code></pre>
129+
<p>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.)</p>
131130

132131
<p>For further information: reading the tests of the test runner (<code>tests/testrunner-tests.js</code>) will help you understand the transformation.</p>
133132
</section>

tests/helper/test-case.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,8 @@ module.exports = {
4949
*
5050
* @param {string} languageIdentifier
5151
* @param {string} filePath
52-
* @param {boolean} [pretty=false]
5352
*/
54-
runTestCase(languageIdentifier, filePath, pretty = false) {
53+
runTestCase(languageIdentifier, filePath) {
5554
const testCase = this.parseTestCaseFile(filePath);
5655
const usedLanguages = this.parseLanguageNames(languageIdentifier);
5756

@@ -79,7 +78,7 @@ module.exports = {
7978
const columnNumber = expectedJsonLines.pop().length + 1;
8079
const lineNumber = testCase.expectedLineOffset + expectedJsonLines.length;
8180

82-
const tokenStreamStr = pretty ? TokenStreamTransformer.prettyprint(simplifiedTokenStream) : actual;
81+
const tokenStreamStr = TokenStreamTransformer.prettyprint(simplifiedTokenStream);
8382
const message = "\n\nActual Token Stream:" +
8483
"\n-----------------------------------------\n" +
8584
tokenStreamStr +

tests/run.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const testSuite =
1111
? TestDiscovery.loadSomeTests(__dirname + "/languages", argv.language)
1212
// load complete test suite
1313
: TestDiscovery.loadAllTests(__dirname + "/languages");
14-
const pretty = 'pretty' in argv;
1514

1615
// define tests for all tests in all languages in the test suite
1716
for (const language in testSuite) {
@@ -28,7 +27,7 @@ for (const language in testSuite) {
2827

2928
it("– should pass test case '" + fileName + "'", function () {
3029
if (path.extname(filePath) === '.test') {
31-
TestCase.runTestCase(language, filePath, pretty);
30+
TestCase.runTestCase(language, filePath);
3231
} else {
3332
TestCase.runTestsWithHooks(language, require(filePath));
3433
}

0 commit comments

Comments
 (0)