@@ -58,88 +58,76 @@ async function runTest(config, command) {
58
58
killSignal : 'SIGKILL'
59
59
} ,
60
60
async ( error , code , stderr ) => {
61
- if ( config . after ) {
62
- await config . after ( error , code , stderr ) ;
63
- }
64
- if ( error && ! error . killed ) {
65
- if ( config . error ) {
66
- if ( ! config . error ( error ) ) {
67
- return resolve ( ) ;
61
+ try {
62
+ if ( config . after ) {
63
+ await config . after ( error , code , stderr ) ;
64
+ }
65
+ if ( error && ! error . killed ) {
66
+ if ( config . error ) {
67
+ if ( ! config . error ( error ) ) {
68
+ return resolve ( ) ;
69
+ }
70
+ } else {
71
+ return reject ( error ) ;
68
72
}
69
- } else {
70
- return reject ( error ) ;
71
73
}
72
- }
73
- if ( childProcess . signalCode === 'SIGKILL' ) {
74
- return reject ( new Error ( 'Test aborted due to timeout.' ) ) ;
75
- }
74
+ if ( childProcess . signalCode === 'SIGKILL' ) {
75
+ return reject ( new Error ( 'Test aborted due to timeout.' ) ) ;
76
+ }
76
77
77
- if ( 'stderr' in config ) {
78
- const shouldContinue = config . stderr ( stderr ) ;
79
- if ( ! shouldContinue ) return resolve ( ) ;
80
- } else if ( stderr ) {
81
- console . error ( stderr ) ;
82
- }
78
+ if ( 'stderr' in config ) {
79
+ const shouldContinue = config . stderr ( stderr ) ;
80
+ if ( ! shouldContinue ) return resolve ( ) ;
81
+ } else if ( stderr ) {
82
+ console . error ( stderr ) ;
83
+ }
83
84
84
- let unintendedError ;
85
+ let unintendedError ;
85
86
86
- if ( config . execute ) {
87
- try {
88
- const function_ = new Function ( 'require' , 'module' , 'exports' , 'assert' , code ) ;
89
- const module = {
90
- exports : { }
91
- } ;
92
- function_ ( require , module , module . exports , assert ) ;
87
+ if ( config . execute ) {
88
+ try {
89
+ const function_ = new Function ( 'require' , 'module' , 'exports' , 'assert' , code ) ;
90
+ const module = {
91
+ exports : { }
92
+ } ;
93
+ function_ ( require , module , module . exports , assert ) ;
93
94
94
- if ( config . error ) {
95
- unintendedError = new Error ( 'Expected an error while executing output' ) ;
96
- }
95
+ if ( config . error ) {
96
+ unintendedError = new Error ( 'Expected an error while executing output' ) ;
97
+ }
97
98
98
- if ( config . exports ) {
99
- await config . exports ( module . exports ) ;
99
+ if ( config . exports ) {
100
+ config . exports ( module . exports ) ;
101
+ }
102
+ } catch ( error ) {
103
+ if ( config . error ) {
104
+ config . error ( error ) ;
105
+ } else {
106
+ unintendedError = error ;
107
+ }
100
108
}
101
- } catch ( error ) {
102
- if ( config . error ) {
103
- config . error ( error ) ;
104
- } else {
105
- unintendedError = error ;
106
- }
107
- }
108
109
109
- if ( config . show || unintendedError ) {
110
- console . log ( code + '\n\n\n' ) ;
111
- }
110
+ if ( config . show || unintendedError ) {
111
+ console . log ( code + '\n\n\n' ) ;
112
+ }
112
113
113
- if ( config . solo ) console . groupEnd ( ) ;
114
+ if ( config . solo ) console . groupEnd ( ) ;
114
115
115
- return unintendedError ? reject ( unintendedError ) : resolve ( ) ;
116
- }
117
- if ( config . result ) {
118
- try {
116
+ return unintendedError ? reject ( unintendedError ) : resolve ( ) ;
117
+ }
118
+ if ( config . result ) {
119
119
config . result ( code ) ;
120
120
return resolve ( ) ;
121
- } catch ( error ) {
122
- return reject ( error ) ;
123
121
}
124
- }
125
- if ( config . test ) {
126
- try {
122
+ if ( config . test ) {
127
123
config . test ( ) ;
128
124
return resolve ( ) ;
129
- } catch ( error ) {
130
- return reject ( error ) ;
131
125
}
132
- }
133
- if ( existsSync ( '_expected' ) && statSync ( '_expected' ) . isDirectory ( ) ) {
134
- try {
126
+ if ( existsSync ( '_expected' ) && statSync ( '_expected' ) . isDirectory ( ) ) {
135
127
assertDirectoriesAreEqual ( '_actual' , '_expected' ) ;
136
128
return resolve ( ) ;
137
- } catch ( error ) {
138
- return reject ( error ) ;
139
129
}
140
- }
141
- const expected = readFileSync ( '_expected.js' , 'utf8' ) ;
142
- try {
130
+ const expected = readFileSync ( '_expected.js' , 'utf8' ) ;
143
131
assert . equal ( normaliseOutput ( code ) , normaliseOutput ( expected ) ) ;
144
132
return resolve ( ) ;
145
133
} catch ( error ) {
0 commit comments