@@ -10,19 +10,52 @@ test('main', async t => {
10
10
t . is ( exitCode , 0 ) ;
11
11
} ) ;
12
12
13
+ test ( 'main with exitCode' , async t => {
14
+ try {
15
+ await execa ( process . execPath , [ './fixtures/sync-exit-code.js' ] ) ;
16
+ t . fail ( ) ;
17
+ } catch ( { stdout, stderr, exitCode} ) {
18
+ t . is ( stdout , 'foo\nbar' ) ;
19
+ t . is ( stderr , '' ) ;
20
+ t . is ( exitCode , 1 ) ;
21
+ }
22
+ } ) ;
23
+
13
24
test ( 'main-empty' , async t => {
14
25
const { stderr, exitCode} = await execa ( process . execPath , [ './fixtures/empty.js' ] ) ;
15
26
t . is ( stderr , '' ) ;
16
27
t . is ( exitCode , 0 ) ;
17
28
} ) ;
18
29
30
+ test ( 'main-empty with exitCode' , async t => {
31
+ try {
32
+ await execa ( process . execPath , [ './fixtures/empty-exit-code.js' ] ) ;
33
+ t . fail ( ) ;
34
+ } catch ( { stdout, stderr, exitCode} ) {
35
+ t . is ( stdout , '' ) ;
36
+ t . is ( stderr , '' ) ;
37
+ t . is ( exitCode , 1 ) ;
38
+ }
39
+ } ) ;
40
+
19
41
test ( 'main-async' , async t => {
20
42
const { stdout, stderr, exitCode} = await execa ( process . execPath , [ './fixtures/async.js' ] ) ;
21
43
t . is ( stdout , 'foo\nbar\nquux' ) ;
22
44
t . is ( stderr , '' ) ;
23
45
t . is ( exitCode , 0 ) ;
24
46
} ) ;
25
47
48
+ test ( 'main-async with exitCode' , async t => {
49
+ try {
50
+ await execa ( process . execPath , [ './fixtures/async-exit-code.js' ] ) ;
51
+ t . fail ( ) ;
52
+ } catch ( { stdout, stderr, exitCode} ) {
53
+ t . is ( stdout , 'foo\nbar\nquux' ) ;
54
+ t . is ( stderr , '' ) ;
55
+ t . is ( exitCode , 1 ) ;
56
+ }
57
+ } ) ;
58
+
26
59
test ( 'main-async-notice' , async t => {
27
60
const { stdout, stderr, exitCode} = await execa ( process . execPath , [ './fixtures/async.js' ] , {
28
61
env : {
@@ -34,6 +67,21 @@ test('main-async-notice', async t => {
34
67
t . is ( exitCode , 0 ) ;
35
68
} ) ;
36
69
70
+ test ( 'main-async-notice with exitCode' , async t => {
71
+ try {
72
+ await execa ( process . execPath , [ './fixtures/async-exit-code.js' ] , {
73
+ env : {
74
+ EXIT_HOOK_SYNC : '1' ,
75
+ } ,
76
+ } ) ;
77
+ t . fail ( ) ;
78
+ } catch ( { stdout, stderr, exitCode} ) {
79
+ t . is ( stdout , 'foo\nbar' ) ;
80
+ t . regex ( stderr , / S Y N C H R O N O U S T E R M I N A T I O N N O T I C E / ) ;
81
+ t . is ( exitCode , 1 ) ;
82
+ }
83
+ } ) ;
84
+
37
85
test ( 'listener count' , t => {
38
86
t . is ( process . listenerCount ( 'exit' ) , 0 ) ;
39
87
0 commit comments