1
1
'use strict' ;
2
2
const common = require ( '../common' ) ;
3
3
4
+ function returnOnExitEnvToValue ( env ) {
5
+ const envValue = env . RETURN_ON_EXIT ;
6
+ if ( envValue === undefined ) {
7
+ return undefined ;
8
+ }
9
+
10
+ return envValue === 'true' ;
11
+ }
12
+
4
13
if ( process . argv [ 2 ] === 'wasi-child-preview1' ) {
5
14
// Test version set to preview1
6
15
const assert = require ( 'assert' ) ;
@@ -23,6 +32,7 @@ if (process.argv[2] === 'wasi-child-preview1') {
23
32
'/sandbox' : fixtures . path ( 'wasi' ) ,
24
33
'/tmp' : tmpdir . path ,
25
34
} ,
35
+ returnOnExit : returnOnExitEnvToValue ( process . env ) ,
26
36
} ) ;
27
37
28
38
// Validate the getImportObject helper
@@ -56,6 +66,10 @@ if (process.argv[2] === 'wasi-child-preview1') {
56
66
if ( options . stdin !== undefined )
57
67
opts . input = options . stdin ;
58
68
69
+ if ( 'returnOnExit' in options ) {
70
+ opts . env . RETURN_ON_EXIT = options . returnOnExit ;
71
+ }
72
+
59
73
const child = cp . spawnSync ( process . execPath , [
60
74
...args ,
61
75
__filename ,
@@ -79,7 +93,9 @@ if (process.argv[2] === 'wasi-child-preview1') {
79
93
if ( ! common . isIBMi ) {
80
94
runWASI ( { test : 'clock_getres' } ) ;
81
95
}
82
- runWASI ( { test : 'exitcode' , exitCode : 120 } ) ;
96
+ runWASI ( { test : 'exitcode' } ) ;
97
+ runWASI ( { test : 'exitcode' , returnOnExit : true } ) ;
98
+ runWASI ( { test : 'exitcode' , exitCode : 120 , returnOnExit : false } ) ;
83
99
runWASI ( { test : 'fd_prestat_get_refresh' } ) ;
84
100
runWASI ( { test : 'freopen' , stdout : `hello from input2.txt${ checkoutEOL } ` } ) ;
85
101
runWASI ( { test : 'ftruncate' } ) ;
0 commit comments