-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtest.js
57 lines (46 loc) · 1.31 KB
/
test.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
var spawn = require('child_process').spawn;
var test = require('tap').test;
test('success', function(t){
var src = 'require("tap").test(function(t){t.ok(1);t.end()});';
src += src;
var runner = spawn('node', ['-e', src]);
var bail = spawn('./bin/tap-bail.js');
runner.stderr.pipe(process.stderr);
bail.stderr.pipe(process.stderr);
var runnerOut = '';
runner.stdout.on('data', function(chunk){
runnerOut += chunk.toString();
});
var bailOut = '';
bail.stdout.on('data', function(chunk){
bailOut += chunk.toString();
});
runner.stdout.pipe(bail.stdin);
bail.on('exit', function(code){
t.equal(code, 0);
t.equal(runnerOut, bailOut);
t.end();
});
});
test('fail', function(t){
var src = 'require("tap").test("NAME", function(t){t.ok(0);t.end()});';
src += src;
var runner = spawn('node', ['-e', src]);
var bail = spawn('./bin/tap-bail.js');
runner.stderr.pipe(process.stderr);
bail.stderr.pipe(process.stderr);
var runnerOut = '';
runner.stdout.on('data', function(chunk){
runnerOut += chunk.toString();
});
var bailOut = '';
bail.stdout.on('data', function(chunk){
bailOut += chunk.toString();
});
runner.stdout.pipe(bail.stdin);
bail.on('exit', function(code){
t.equal(code, 1);
t.ok(runnerOut.length > bailOut.length);
t.end();
});
});