|
1 | 1 | var Runner = require('../runner'); |
2 | 2 | var ConsoleRunner = require('./console'); |
3 | 3 | var cp = require('child_process'); |
| 4 | +var _ = require('highland'); |
4 | 5 |
|
5 | 6 | module.exports = NodeRunner; |
6 | 7 |
|
7 | 8 | function NodeRunner(args) { |
8 | | - args.consoleCommand = 'dummy'; |
| 9 | + args.consoleCommand = args.consoleCommand || "node.exe"; |
9 | 10 | var runner = this; |
| 11 | + |
10 | 12 | ConsoleRunner.apply(this, arguments); |
| 13 | + |
11 | 14 | this.deps = []; // all env deps provided by nodehost.js |
12 | 15 |
|
13 | | - this._instance = cp.fork(__dirname + '/nodehost.js') |
14 | | - this._instance.on('message', function(result) { |
15 | | - runner.validateResult(runner._test, result) |
16 | | - runner._testDone(); |
| 16 | + this._instance = cp.spawn(args.consoleCommand, [__dirname + '/nodehost.js']); |
| 17 | + |
| 18 | + |
| 19 | + var results = { log: [] }; |
| 20 | + |
| 21 | + _(this._instance.stdout).flatMap(function(data) { |
| 22 | + return _(data.toString().split(/\r?\n/g)); |
| 23 | + }).each(function(line) { |
| 24 | + results.log.push(line); |
| 25 | + switch(line) { |
| 26 | + case 'test262/done': |
| 27 | + runner.validateResult(runner._test, results); |
| 28 | + results = { log: [] }; |
| 29 | + |
| 30 | + runner._testDone(); |
| 31 | + break; |
| 32 | + } |
17 | 33 | }) |
18 | 34 | } |
19 | 35 | NodeRunner.prototype = Object.create(ConsoleRunner.prototype); |
20 | 36 | NodeRunner.prototype.execute = function(test, cb) { |
21 | 37 | this._test = test; |
22 | 38 | this._testDone = cb; |
23 | | - this._instance.send(test.contents); |
| 39 | + this._instance.stdin.write(test.contents); |
24 | 40 | } |
25 | 41 |
|
26 | 42 | NodeRunner.prototype.end = function() { |
27 | | - this._instance.disconnect(); |
| 43 | + this._instance.stdin.end(); |
28 | 44 | } |
0 commit comments