Skip to content

Commit 9afc9bc

Browse files
committed
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 cfd8c2a commit 9afc9bc

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
@@ -20,26 +20,45 @@
2020
// USE OR OTHER DEALINGS IN THE SOFTWARE.
2121

2222
'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+
2429
const assert = require('assert');
2530
const fs = require('fs');
2631
const path = require('path');
2732

28-
// check for existence
33+
// Check for existence of `process.config`.
2934
assert(process.hasOwnProperty('config'));
3035

31-
// ensure that `process.config` is an Object
36+
// Ensure that `process.config` is an Object.
3237
assert.strictEqual(Object(process.config), process.config);
3338

3439
const configPath = path.resolve(__dirname, '..', '..', 'config.gypi');
40+
41+
if (!fs.existsSync(configPath)) {
42+
common.skip('config.gypi does not exist.');
43+
}
44+
3545
let config = fs.readFileSync(configPath, 'utf8');
3646

37-
// clean up comment at the first line
47+
// Clean up comment at the first line.
3848
config = config.split('\n').slice(1).join('\n').replace(/'/g, '"');
3949
config = JSON.parse(config, function(key, value) {
4050
if (value === 'true') return true;
4151
if (value === 'false') return false;
4252
return value;
4353
});
4454

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

Comments
 (0)