1 exec = require '../js/sync-exec'
6 now = (new Date).getTime()
7 unless res1 and res2 and t + 10000 <= now < t + 12000
8 throw new Error 'Timing error'
11 t = (new Date).getTime()
12 setTimeout delay_check, 10
14 process.stdout.write 'Test #1 (takes ~3 seconds) ... '
18 res1 = exec __dirname + '/sh/out.sh'
19 unless res1.stdout is '1\n' and res1.stderr is '' and res1.status is 0
20 throw new Error 'Result #1 error:\n' + JSON.stringify res1, null, 2
26 process.stdout.write 'Test #2 (takes ~3 seconds) ... '
27 res2 = exec __dirname + '/sh/err.sh'
28 unless res2.stdout is '2\n' and res2.stderr is '3\n' and res2.status is 1
29 throw new Error 'Result #2 error:\n' + JSON.stringify res2, null, 2
32 process.stdout.write 'Test #3 (takes ~1 second) ... '
34 exec __dirname + '/sh/out.sh', 1000
37 throw new Error 'Failed timeout'
40 process.stdout.write 'Test #4 (takes ~3 second) ... '
41 exec './out.sh', {cwd: __dirname + '/sh'}
44 process.stdout.write 'Test #5 ... ' # Timeout order test