|
21 | 21 |
|
22 | 22 | var assert = require('assert');
|
23 | 23 |
|
24 |
| -var common = require('../common'); |
25 |
| - |
26 | 24 | /*
|
27 | 25 | * The goal of this test is to make sure that:
|
28 | 26 | *
|
@@ -141,27 +139,59 @@ if (process.argv[2] === 'child') {
|
141 | 139 | });
|
142 | 140 |
|
143 | 141 | child.on('exit', function onChildExited(exitCode, signal) {
|
| 142 | + var expectedExitCode = 0; |
| 143 | + // We use an array of values since the actual signal can differ across |
| 144 | + // compilers. |
| 145 | + var expectedSignal = [null]; |
| 146 | + |
144 | 147 | // When throwing errors from the top-level domain error handler
|
145 | 148 | // outside of a try/catch block, the process should not exit gracefully
|
146 | 149 | if (!options.useTryCatch && options.throwInDomainErrHandler) {
|
147 | 150 | // If the top-level domain's error handler does not throw,
|
148 | 151 | // the process must exit gracefully, whether or not
|
149 | 152 | // --abort_on_uncaught_exception was passed on the command line
|
| 153 | + expectedExitCode = 7; |
150 | 154 | if (cmdLineOption === '--abort_on_uncaught_exception') {
|
151 |
| - assert(common.nodeProcessAborted(exitCode, signal), |
152 |
| - 'process should have aborted, but did not'); |
153 |
| - } else { |
154 |
| - // By default, uncaught exceptions make node exit with an exit |
155 |
| - // code of 7. |
156 |
| - assert.equal(exitCode, 7); |
157 |
| - assert.equal(signal, null); |
| 155 | + // If the top-level domain's error handler throws, and only if |
| 156 | + // --abort_on_uncaught_exception is passed on the command line, |
| 157 | + // the process must abort. |
| 158 | + // |
| 159 | + // We use an array of values since the actual exit code can differ |
| 160 | + // across compilers. |
| 161 | + expectedExitCode = [132, 134]; |
| 162 | + |
| 163 | + // On Linux, v8 raises SIGTRAP when aborting because |
| 164 | + // the "debug break" flag is on by default |
| 165 | + if (process.platform === 'linux') |
| 166 | + expectedExitCode.push(133); |
| 167 | + |
| 168 | + // On some platforms with KSH being the default shell |
| 169 | + // (like SmartOS), when a process aborts, KSH exits with an exit |
| 170 | + // code that is greater than 256, and thus the exit code emitted |
| 171 | + // with the 'exit' event is null and the signal is set to either |
| 172 | + // SIGABRT or SIGILL. |
| 173 | + if (process.platform === 'sunos') { |
| 174 | + expectedExitCode = null; |
| 175 | + expectedSignal = ['SIGABRT', 'SIGILL']; |
| 176 | + } |
| 177 | + |
| 178 | + // On Windows, v8's base::OS::Abort also triggers a debug breakpoint |
| 179 | + // which makes the process exit with code -2147483645 |
| 180 | + if (process.platform === 'win32') |
| 181 | + expectedExitCode = [-2147483645, 3221225477]; |
158 | 182 | }
|
| 183 | + } |
| 184 | + |
| 185 | + if (Array.isArray(expectedSignal)) { |
| 186 | + assert.ok(expectedSignal.indexOf(signal) > -1); |
159 | 187 | } else {
|
160 |
| - // If the top-level domain's error handler does not throw, |
161 |
| - // the process must exit gracefully, whether or not |
162 |
| - // --abort_on_uncaught_exception was passed on the command line |
163 |
| - assert.equal(exitCode, 0); |
164 |
| - assert.equal(signal, null); |
| 188 | + assert.equal(signal, expectedSignal); |
| 189 | + } |
| 190 | + |
| 191 | + if (Array.isArray(expectedExitCode)) { |
| 192 | + assert.ok(expectedExitCode.indexOf(exitCode) > -1); |
| 193 | + } else { |
| 194 | + assert.equal(exitCode, expectedExitCode); |
165 | 195 | }
|
166 | 196 | });
|
167 | 197 | }
|
|
0 commit comments