/
run.js
40 lines (33 loc) · 1.13 KB
/
run.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// @ts-check
'use strict';
const TestDiscovery = require('./helper/test-discovery');
const TestCase = require('./helper/test-case');
const path = require('path');
const { argv } = require('yargs');
const testSuite =
(argv.language)
? TestDiscovery.loadSomeTests(__dirname + '/languages', argv.language)
// load complete test suite
: TestDiscovery.loadAllTests(__dirname + '/languages');
const update = !!argv.update;
// define tests for all tests in all languages in the test suite
for (const language in testSuite) {
if (!testSuite.hasOwnProperty(language)) {
continue;
}
(function (language, testFiles) {
describe("Testing language '" + language + "'", function () {
this.timeout(10000);
for (const filePath of testFiles) {
const fileName = path.basename(filePath, path.extname(filePath));
it("– should pass test case '" + fileName + "'", function () {
if (path.extname(filePath) === '.test') {
TestCase.runTestCase(language, filePath, update ? 'update' : 'insert');
} else {
TestCase.runTestsWithHooks(language, require(filePath));
}
});
}
});
}(language, testSuite[language]));
}