|
1 | 1 | 'use strict';
|
2 |
| -require('../common'); |
| 2 | + |
| 3 | +const common = require('../common'); |
| 4 | + |
| 5 | +// Checks that the internal process.config is equivalent to the config.gypi file |
| 6 | +// created when we run configure. |
| 7 | + |
3 | 8 | const assert = require('assert');
|
4 | 9 | const fs = require('fs');
|
5 | 10 | const path = require('path');
|
6 | 11 |
|
7 |
| -// check for existence |
| 12 | +// Check for existence of `process.config`. |
8 | 13 | assert(process.hasOwnProperty('config'));
|
9 | 14 |
|
10 |
| -// ensure that `process.config` is an Object |
| 15 | +// Ensure that `process.config` is an Object. |
11 | 16 | assert.strictEqual(Object(process.config), process.config);
|
12 | 17 |
|
13 | 18 | const configPath = path.resolve(__dirname, '..', '..', 'config.gypi');
|
| 19 | + |
| 20 | +if (!fs.existsSync(configPath)) { |
| 21 | + common.skip('config.gypi does not exist.'); |
| 22 | +} |
| 23 | + |
14 | 24 | let config = fs.readFileSync(configPath, 'utf8');
|
15 | 25 |
|
16 |
| -// clean up comment at the first line |
| 26 | +// Clean up comment at the first line. |
17 | 27 | config = config.split('\n').slice(1).join('\n').replace(/'/g, '"');
|
18 | 28 | config = JSON.parse(config, function(key, value) {
|
19 | 29 | if (value === 'true') return true;
|
20 | 30 | if (value === 'false') return false;
|
21 | 31 | return value;
|
22 | 32 | });
|
23 | 33 |
|
24 |
| -assert.deepStrictEqual(config, process.config); |
| 34 | +try { |
| 35 | + assert.deepStrictEqual(config, process.config); |
| 36 | +} catch (e) { |
| 37 | + // If the assert fails, it only shows 3 lines. We need all the output to |
| 38 | + // compare. |
| 39 | + console.log('config:', config); |
| 40 | + console.log('process.config:', process.config); |
| 41 | + |
| 42 | + throw e; |
| 43 | +} |
0 commit comments