|
20 | 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21 | 21 |
|
22 | 22 | 'use strict';
|
23 |
| -require('../common'); |
| 23 | + |
| 24 | +const common = require('../common'); |
| 25 | + |
| 26 | +// Checks that the internal process.config is equivalent to the config.gypi file |
| 27 | +// created when we run configure. |
| 28 | + |
24 | 29 | const assert = require('assert');
|
25 | 30 | const fs = require('fs');
|
26 | 31 | const path = require('path');
|
27 | 32 |
|
28 |
| -// check for existence |
| 33 | +// Check for existence of `process.config`. |
29 | 34 | assert(process.hasOwnProperty('config'));
|
30 | 35 |
|
31 |
| -// ensure that `process.config` is an Object |
| 36 | +// Ensure that `process.config` is an Object. |
32 | 37 | assert.strictEqual(Object(process.config), process.config);
|
33 | 38 |
|
34 | 39 | const configPath = path.resolve(__dirname, '..', '..', 'config.gypi');
|
| 40 | + |
| 41 | +if (!fs.existsSync(configPath)) { |
| 42 | + common.skip('config.gypi does not exist.'); |
| 43 | +} |
| 44 | + |
35 | 45 | let config = fs.readFileSync(configPath, 'utf8');
|
36 | 46 |
|
37 |
| -// clean up comment at the first line |
| 47 | +// Clean up comment at the first line. |
38 | 48 | config = config.split('\n').slice(1).join('\n').replace(/'/g, '"');
|
39 | 49 | config = JSON.parse(config, function(key, value) {
|
40 | 50 | if (value === 'true') return true;
|
41 | 51 | if (value === 'false') return false;
|
42 | 52 | return value;
|
43 | 53 | });
|
44 | 54 |
|
45 |
| -assert.deepStrictEqual(config, process.config); |
| 55 | +try { |
| 56 | + assert.deepStrictEqual(config, process.config); |
| 57 | +} catch (e) { |
| 58 | + // If the assert fails, it only shows 3 lines. We need all the output to |
| 59 | + // compare. |
| 60 | + console.log('config:', config); |
| 61 | + console.log('process.config:', process.config); |
| 62 | + |
| 63 | + throw e; |
| 64 | +} |
0 commit comments