Skip to content

Commit 4010c9a

Browse files
committed
Rewrite based on eshost
1 parent dad42e7 commit 4010c9a

39 files changed

+262
-2854
lines changed

index.js

Lines changed: 0 additions & 35 deletions
This file was deleted.

lib/agentPool.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
'use strict';
2+
const Rx = require('rx');
3+
const eshost = require('eshost');
4+
5+
module.exports = makePool;
6+
function makePool(agents, hostType, hostArgs, hostPath) {
7+
const pool = new Rx.Subject();
8+
9+
for (var i = 0; i < agents; i++) {
10+
eshost.createAgent(hostType, {
11+
hostArguments: hostArgs,
12+
hostPath: hostPath
13+
})
14+
.then(agent => {
15+
pool.onNext(agent);
16+
})
17+
.catch(e => {
18+
console.error('Error creating agent: ');
19+
console.error(e);
20+
process.exit(1);
21+
});
22+
}
23+
24+
pool.runTest = function (record) {
25+
const agent = record[0];
26+
const test = record[1];
27+
return agent.evalScript(test.contents)
28+
.then(result => {
29+
pool.onNext(agent);
30+
test.rawResult = result;
31+
return test;
32+
})
33+
.catch(err => {
34+
console.error('Error running test: ', err);
35+
process.exit(1);
36+
});
37+
}
38+
return pool;
39+
}

lib/cli.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const yargs = require('yargs');
2+
const yargv = yargs
3+
.usage('Usage: test262-harness [options] <test-file-glob>')
4+
.demand('hostType')
5+
.describe('hostType', 'eshost host type (chakra, d8, jsshell, chrome, firefox, etc.)')
6+
.describe('hostPath', 'path to eshost host binary')
7+
.describe('hostArgs', 'command-line arguments to pass to eshost host')
8+
.describe('test262Dir', 'test262 root directory')
9+
.describe('includesDir', 'directory where helper files are found')
10+
.describe('threads', 'number of threads to use')
11+
.default('threads', 1)
12+
.help('help')
13+
.example('test262-harness path/to/test.js')
14+
15+
exports.argv = yargv.argv;

lib/findTest262.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
'use strict';
2+
3+
const fs = require('fs');
4+
const Path = require('path');
5+
6+
module.exports = findTest262Dir;
7+
function findTest262Dir(globber) {
8+
const set = globber.minimatch.set;
9+
let baseDir;
10+
for (let i = 0; i < set.length; i++) {
11+
let base = [];
12+
13+
for (let j = 0; j < set[i].length; j++) {
14+
if (typeof set[i][j] !== 'string') {
15+
break;
16+
}
17+
18+
base.push(set[i][j]);
19+
}
20+
21+
baseDir = findTest262Root(base.join("/"));
22+
23+
if (baseDir) {
24+
break;
25+
}
26+
}
27+
28+
return baseDir;
29+
}
30+
31+
function findTest262Root(path) {
32+
const contents = fs.readdirSync(path)
33+
if (contents.indexOf('README.md') > -1
34+
&& contents.indexOf('test') > -1
35+
&& contents.indexOf('harness') > -1) {
36+
return path;
37+
}
38+
39+
const parent = Path.resolve(path, '../');
40+
41+
if (parent === path) {
42+
return null;
43+
}
44+
45+
return findTest262Root(parent);
46+
}

lib/globber.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
'use strict';
2+
const glob = require('glob');
3+
const Rx = require('rx');
4+
5+
function globber(g) {
6+
const Glob = glob.Glob;
7+
const fileEvents = new Glob(g);
8+
const paths = new Rx.Subject();
9+
10+
fileEvents.on('match', function (file) {
11+
paths.onNext(file);
12+
});
13+
14+
fileEvents.on('end', function () {
15+
paths.onCompleted();
16+
})
17+
18+
paths.fileEvents = fileEvents;
19+
return paths;
20+
}
21+
22+
module.exports = globber;

lib/helpers/$FAIL.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

lib/helpers/$INCLUDE.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

lib/helpers/$PRINT.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

lib/helpers/Date_constants.js

Lines changed: 0 additions & 80 deletions
This file was deleted.

0 commit comments

Comments
 (0)