diff options
author | Gibson Fahnestock <gibfahn@gmail.com> | 2017-10-20 14:33:29 +0100 |
---|---|---|
committer | Gibson Fahnestock <gibfahn@gmail.com> | 2017-10-27 16:16:30 +0100 |
commit | 502563b277914bf259f2ce6a29fe826cf1f7656e (patch) | |
tree | a3afbe4b75156e4bd8ac988d42c42be998990056 /test/parallel/test-process-config.js | |
parent | ee76f3153b51c60c74e7e4b0882a99f3a3745294 (diff) | |
download | android-node-v8-502563b277914bf259f2ce6a29fe826cf1f7656e.tar.gz android-node-v8-502563b277914bf259f2ce6a29fe826cf1f7656e.tar.bz2 android-node-v8-502563b277914bf259f2ce6a29fe826cf1f7656e.zip |
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: https://github.com/nodejs/node/pull/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>
Diffstat (limited to 'test/parallel/test-process-config.js')
-rw-r--r-- | test/parallel/test-process-config.js | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/test/parallel/test-process-config.js b/test/parallel/test-process-config.js index cd9462dd13..05616480e0 100644 --- a/test/parallel/test-process-config.js +++ b/test/parallel/test-process-config.js @@ -20,21 +20,31 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -require('../common'); + +const common = require('../common'); + +// Checks that the internal process.config is equivalent to the config.gypi file +// created when we run configure. + const assert = require('assert'); const fs = require('fs'); const path = require('path'); -// check for existence +// Check for existence of `process.config`. assert(process.hasOwnProperty('config')); -// ensure that `process.config` is an Object +// Ensure that `process.config` is an Object. assert.strictEqual(Object(process.config), process.config); const configPath = path.resolve(__dirname, '..', '..', 'config.gypi'); + +if (!fs.existsSync(configPath)) { + common.skip('config.gypi does not exist.'); +} + let config = fs.readFileSync(configPath, 'utf8'); -// clean up comment at the first line +// Clean up comment at the first line. config = config.split('\n').slice(1).join('\n').replace(/'/g, '"'); config = JSON.parse(config, function(key, value) { if (value === 'true') return true; @@ -42,4 +52,13 @@ config = JSON.parse(config, function(key, value) { return value; }); -assert.deepStrictEqual(config, process.config); +try { + assert.deepStrictEqual(config, process.config); +} catch (e) { + // If the assert fails, it only shows 3 lines. We need all the output to + // compare. + console.log('config:', config); + console.log('process.config:', process.config); + + throw e; +} |