1 | "use strict";
|
2 |
|
3 | var TestDiscovery = require("./helper/test-discovery");
|
4 | var path = require("path");
|
5 | var argv = require("yargs").argv;
|
6 | var child_process = require("child_process");
|
7 |
|
8 | var testSuite;
|
9 | if (argv.language) {
|
10 | testSuite = TestDiscovery.loadSomeTests(__dirname + "/languages", argv.language);
|
11 | } else {
|
12 |
|
13 | testSuite = TestDiscovery.loadAllTests(__dirname + "/languages");
|
14 | }
|
15 |
|
16 |
|
17 | for (var language in testSuite) {
|
18 | if (!testSuite.hasOwnProperty(language)) {
|
19 | continue;
|
20 | }
|
21 |
|
22 | (function (language, testFiles) {
|
23 | describe("Testing language '" + language + "'", function () {
|
24 | this.timeout(10000);
|
25 |
|
26 |
|
27 | var child;
|
28 | before(function () {
|
29 | child = child_process.fork(__dirname + "/run-child.js", ['--language=' + language], {
|
30 | stdio: 'inherit'
|
31 | });
|
32 | });
|
33 |
|
34 | after(function () {
|
35 | child.kill();
|
36 | });
|
37 |
|
38 | testFiles.forEach(
|
39 | function (filePath) {
|
40 | var fileName = path.basename(filePath, path.extname(filePath));
|
41 |
|
42 | it("– should pass test case '" + fileName + "'",
|
43 | function (done) {
|
44 |
|
45 | child.removeAllListeners('message');
|
46 | child.on('message', function (o) {
|
47 |
|
48 |
|
49 |
|
50 | setTimeout(function() {
|
51 | if (o.error) {
|
52 | throw JSON.parse(o.error);
|
53 | } else if (o.success) {
|
54 | done();
|
55 | }
|
56 | }, 1);
|
57 | });
|
58 | child.send({
|
59 | filePath: filePath
|
60 | });
|
61 | }
|
62 | );
|
63 | }
|
64 | );
|
65 | });
|
66 | })(language, testSuite[language]);
|
67 | } |
\ | No newline at end of file |