Skip to content

Commit 7d93da5

Browse files
gibfahnMylesBorins
authored andcommitted
test: skip test-process-config if no config.gypi
If you run the tests in a different machine to the one you built on, this test will fail. Avoid this by skipping if the file doesn't exist. We shouldn't need to check that the file exists in this test, as the build won't pass without a config.gypi anyway. Also adds console.logs, so you can see what the actual difference between the objects was, as `assert.deepStrictEqual()` only shows you the first three lines. PR-URL: #16436 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 5c20164 commit 7d93da5

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

test/parallel/test-process-config.js

+24-5
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,43 @@
11
'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+
38
const assert = require('assert');
49
const fs = require('fs');
510
const path = require('path');
611

7-
// check for existence
12+
// Check for existence of `process.config`.
813
assert(process.hasOwnProperty('config'));
914

10-
// ensure that `process.config` is an Object
15+
// Ensure that `process.config` is an Object.
1116
assert.strictEqual(Object(process.config), process.config);
1217

1318
const configPath = path.resolve(__dirname, '..', '..', 'config.gypi');
19+
20+
if (!fs.existsSync(configPath)) {
21+
common.skip('config.gypi does not exist.');
22+
}
23+
1424
let config = fs.readFileSync(configPath, 'utf8');
1525

16-
// clean up comment at the first line
26+
// Clean up comment at the first line.
1727
config = config.split('\n').slice(1).join('\n').replace(/'/g, '"');
1828
config = JSON.parse(config, function(key, value) {
1929
if (value === 'true') return true;
2030
if (value === 'false') return false;
2131
return value;
2232
});
2333

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

Comments
 (0)