/
run.test.js
150 lines (137 loc) · 3.85 KB
/
run.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*global describe:true, it: true */
var assert = require('assert'),
utils = require('../utils'),
appjs = utils.appjs,
run = utils.run;
describe('nodemon fork', function () {
it('should not show user-signal', done => {
var p = run({ exec: 'bin/nodemon.js',
args: [ '-V', '-x', 'echo running && sleep 20' ] }, {
error: function (data) {
p.send('quit');
if (data.trim().indexOf('signal') !== -1) {
return done(new Error('Signal incorrectly shown'));
}
done(new Error(data));
},
output: function (data) {
if (data.trim().indexOf('signal') !== -1) {
done(new Error('Signal incorrectly shown'));
}
}
});
let started = false;
p.on('message', function (event) {
if (event.type === 'start') {
if (!started) {
p.send('restart');
started = true;
} else {
p.send('quit');
assert(true, 'nodemon started');
done();
}
}
});
});
it('should start a fork', function (done) {
var p = run(appjs, {
error: function (data) {
p.send('quit');
done(new Error(data));
}
});
p.on('message', function (event) {
if (event.type === 'start') {
p.send('quit');
assert(true, 'nodemon started');
done();
}
});
});
if (!process.env.TRAVIS) {
it('should start a fork exec with a space without args', function (done) {
var found = false;
var p = run({
exec: 'bin/nodemon.js',
// make nodemon verbose so we can check the filters being applied
args: ['-q', '--exec', 'test/fixtures/app\\ with\\ spaces.js']
}, {
error: function (data) {
p.send('quit');
done(new Error(data));
},
output: function (data) {
// process.stdout.write(data);
if (data.trim() === 'OK') {
found = true;
}
}
});
p.on('message', function (event) {
if (event.type === 'start') {
setTimeout(function () {
p.send('quit');
done();
assert(found, '"OK" message was found');
}, 500);
}
});
});
it('should start a fork exec with a space with args', function (done) {
var found = false;
var p = run({
exec: 'bin/nodemon.js',
// make nodemon verbose so we can check the filters being applied
args: ['-q', '--exec', '"test/fixtures/app with spaces.js" foo'],
}, {
error: function (data) {
p.send('quit');
done(new Error(data));
},
output: function (data) {
if (data.trim() === 'foo') {
found = true;
}
}
});
p.on('message', function (event) {
if (event.type === 'start') {
setTimeout(function () {
p.send('quit');
assert(found, '"foo" message found');
done();
}, 500);
}
});
});
}
it('should start a fork exec with a space with args (escaped)', function (done) {
var found = false;
var p = run({
exec: 'bin/nodemon.js',
// make nodemon verbose so we can check the filters being applied
args: ['-q', '--exec', 'test/fixtures/app\\ with\\ spaces.js foo']
}, {
error: function (data) {
p.send('quit');
done(new Error(data));
},
output: function (data) {
// process.stdout.write(data);
if (data.trim() === 'foo') {
found = true;
}
}
});
p.on('message', function (event) {
if (event.type === 'start') {
setTimeout(function () {
p.send('quit');
done();
assert(found, '"OK" message found');
}, 500);
}
});
});
});