From 74fa505fccc3e376be83ada68fcb414cd0c39702 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Wed, 28 Sep 2016 20:14:23 +0200 Subject: [PATCH] test: enable addons test to pass with debug build Currently when running configure with the --debug option in combination with the tests (./configure --debug && make -j8 test) there are a few addon tests that fail with error messages similar to this: === release test === Path: addons/load-long-path/test fs.js:558 return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode); ^ Error: ENOENT: no such file or directory, open '/nodejs/node/test/addons/load-long-path/build/Release/binding.node' at Object.fs.openSync (fs.js:558:18) at Object.fs.readFileSync (fs.js:468:33) at Object. (/nodejs/node/test/addons/load-long-path/test.js:28:19) at Module._compile (module.js:560:32) at Object.Module._extensions..js (module.js:569:10) at Module.load (module.js:477:32) at tryModuleLoad (module.js:436:12) at Function.Module._load (module.js:428:3) at Module.runMain (module.js:594:10) at run (bootstrap_node.js:382:7) Command: out/Release/node /nodejs/node/test/addons/load-long-path/test.js This commit allows for the tests to pass even if the configured build type is of type debug. PR-URL: https://github.com/nodejs/node/pull/8836 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Ben Noordhuis Reviewed-By: Ilkka Myller Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig --- test/addons/async-hello-world/test.js | 2 +- test/addons/at-exit/test.js | 4 ++-- test/addons/buffer-free-callback/test.js | 4 ++-- test/addons/heap-profiler/test.js | 4 ++-- test/addons/hello-world-function-export/test.js | 4 ++-- test/addons/hello-world/test.js | 4 ++-- test/addons/load-long-path/test.js | 5 ++++- test/addons/make-callback-recurse/test.js | 2 +- test/addons/make-callback/test.js | 2 +- test/addons/null-buffer-neuter/test.js | 4 ++-- test/addons/openssl-binding/test.js | 4 ++-- test/addons/parse-encoding/test.js | 4 ++-- .../test-stringbytes-external-at-max.js | 2 +- .../test-stringbytes-external-exceed-max-by-1-ascii.js | 2 +- .../test-stringbytes-external-exceed-max-by-1-base64.js | 2 +- .../test-stringbytes-external-exceed-max-by-1-binary.js | 2 +- .../test-stringbytes-external-exceed-max-by-1-hex.js | 2 +- .../test-stringbytes-external-exceed-max-by-1-utf8.js | 2 +- .../test-stringbytes-external-exceed-max-by-2.js | 2 +- .../test-stringbytes-external-exceed-max.js | 2 +- test/addons/symlinked-module/test.js | 2 +- test/addons/zlib-binding/test.js | 4 ++-- test/common.js | 1 + tools/doc/addon-verify.js | 4 ++-- 24 files changed, 37 insertions(+), 33 deletions(-) diff --git a/test/addons/async-hello-world/test.js b/test/addons/async-hello-world/test.js index 2ed003e4445d5d..bbc81bfbf8c9cb 100644 --- a/test/addons/async-hello-world/test.js +++ b/test/addons/async-hello-world/test.js @@ -1,7 +1,7 @@ 'use strict'; const common = require('../../common'); var assert = require('assert'); -var binding = require('./build/Release/binding'); +const binding = require(`./build/${common.buildType}/binding`); binding(5, common.mustCall(function(err, val) { assert.equal(null, err); diff --git a/test/addons/at-exit/test.js b/test/addons/at-exit/test.js index c94453cb3b05a4..4e2ca810f01c87 100644 --- a/test/addons/at-exit/test.js +++ b/test/addons/at-exit/test.js @@ -1,3 +1,3 @@ 'use strict'; -require('../../common'); -require('./build/Release/binding'); +const common = require('../../common'); +require(`./build/${common.buildType}/binding`); diff --git a/test/addons/buffer-free-callback/test.js b/test/addons/buffer-free-callback/test.js index 73222b288cbf82..8dbc2d57725c56 100644 --- a/test/addons/buffer-free-callback/test.js +++ b/test/addons/buffer-free-callback/test.js @@ -1,8 +1,8 @@ 'use strict'; // Flags: --expose-gc -require('../../common'); -var binding = require('./build/Release/binding'); +const common = require('../../common'); +const binding = require(`./build/${common.buildType}/binding`); function check(size, alignment, offset) { var buf = binding.alloc(size, alignment, offset); diff --git a/test/addons/heap-profiler/test.js b/test/addons/heap-profiler/test.js index 3fa00e9b86afad..32b32ddb6e6581 100644 --- a/test/addons/heap-profiler/test.js +++ b/test/addons/heap-profiler/test.js @@ -1,8 +1,8 @@ 'use strict'; -require('../../common'); +const common = require('../../common'); -const binding = require('./build/Release/binding'); +const binding = require(`./build/${common.buildType}/binding`); // Create an AsyncWrap object. const timer = setTimeout(function() {}, 1); diff --git a/test/addons/hello-world-function-export/test.js b/test/addons/hello-world-function-export/test.js index 6dcdf39ce1c413..89127fc787c94e 100644 --- a/test/addons/hello-world-function-export/test.js +++ b/test/addons/hello-world-function-export/test.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../common'); +const common = require('../../common'); var assert = require('assert'); -var binding = require('./build/Release/binding'); +const binding = require(`./build/${common.buildType}/binding`); assert.equal('world', binding()); console.log('binding.hello() =', binding()); diff --git a/test/addons/hello-world/test.js b/test/addons/hello-world/test.js index 5637e9e6e93a3e..8d5c1238770064 100644 --- a/test/addons/hello-world/test.js +++ b/test/addons/hello-world/test.js @@ -1,6 +1,6 @@ 'use strict'; -require('../../common'); +const common = require('../../common'); var assert = require('assert'); -var binding = require('./build/Release/binding'); +const binding = require(`./build/${common.buildType}/binding`); assert.equal('world', binding.hello()); console.log('binding.hello() =', binding.hello()); diff --git a/test/addons/load-long-path/test.js b/test/addons/load-long-path/test.js index 36eb2199e7a63e..2f09f2b3ff005c 100644 --- a/test/addons/load-long-path/test.js +++ b/test/addons/load-long-path/test.js @@ -21,7 +21,10 @@ for (var i = 0; i < 10; i++) { fs.mkdirSync(addonDestinationDir); } -const addonPath = path.join(__dirname, 'build', 'Release', 'binding.node'); +const addonPath = path.join(__dirname, + 'build', + common.buildType, + 'binding.node'); const addonDestinationPath = path.join(addonDestinationDir, 'binding.node'); // Copy binary to long path destination diff --git a/test/addons/make-callback-recurse/test.js b/test/addons/make-callback-recurse/test.js index 0b7f17dfefb688..67cc479c5af474 100644 --- a/test/addons/make-callback-recurse/test.js +++ b/test/addons/make-callback-recurse/test.js @@ -3,7 +3,7 @@ const common = require('../../common'); const assert = require('assert'); const domain = require('domain'); -const binding = require('./build/Release/binding'); +const binding = require(`./build/${common.buildType}/binding`); const makeCallback = binding.makeCallback; // Make sure this is run in the future. diff --git a/test/addons/make-callback/test.js b/test/addons/make-callback/test.js index f3c98770ef335a..43ad014c4af478 100644 --- a/test/addons/make-callback/test.js +++ b/test/addons/make-callback/test.js @@ -3,7 +3,7 @@ const common = require('../../common'); const assert = require('assert'); const vm = require('vm'); -const binding = require('./build/Release/binding'); +const binding = require(`./build/${common.buildType}/binding`); const makeCallback = binding.makeCallback; assert.strictEqual(42, makeCallback(process, common.mustCall(function() { diff --git a/test/addons/null-buffer-neuter/test.js b/test/addons/null-buffer-neuter/test.js index bca76e27afa4c5..3fc335914c9a44 100644 --- a/test/addons/null-buffer-neuter/test.js +++ b/test/addons/null-buffer-neuter/test.js @@ -1,7 +1,7 @@ 'use strict'; // Flags: --expose-gc -require('../../common'); -var binding = require('./build/Release/binding'); +const common = require('../../common'); +const binding = require(`./build/${common.buildType}/binding`); binding.run(); diff --git a/test/addons/openssl-binding/test.js b/test/addons/openssl-binding/test.js index aa515bac9a5c45..a146ffe5c68f1b 100644 --- a/test/addons/openssl-binding/test.js +++ b/test/addons/openssl-binding/test.js @@ -1,8 +1,8 @@ 'use strict'; -require('../../common'); +const common = require('../../common'); const assert = require('assert'); -const binding = require('./build/Release/binding'); +const binding = require(`./build/${common.buildType}/binding`); const bytes = new Uint8Array(1024); assert(binding.randomBytes(bytes)); assert(bytes.reduce((v, a) => v + a) > 0); diff --git a/test/addons/parse-encoding/test.js b/test/addons/parse-encoding/test.js index 6c32374ca63307..412346650fa217 100644 --- a/test/addons/parse-encoding/test.js +++ b/test/addons/parse-encoding/test.js @@ -1,8 +1,8 @@ 'use strict'; -require('../../common'); +const common = require('../../common'); const assert = require('assert'); -const { parseEncoding } = require('./build/Release/binding'); +const { parseEncoding } = require(`./build/${common.buildType}/binding`); assert.strictEqual(parseEncoding(''), 'UNKNOWN'); diff --git a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-at-max.js b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-at-max.js index ebf6a01a0a01d0..bd71f05d61bf2c 100644 --- a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-at-max.js +++ b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-at-max.js @@ -1,7 +1,7 @@ 'use strict'; const common = require('../../common'); -const binding = require('./build/Release/binding'); +const binding = require(`./build/${common.buildType}/binding`); const assert = require('assert'); // v8 fails silently if string length > v8::String::kMaxLength diff --git a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-ascii.js b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-ascii.js index 0fc21d610239b2..4be525d79fa39e 100644 --- a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-ascii.js +++ b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-ascii.js @@ -1,7 +1,7 @@ 'use strict'; const common = require('../../common'); -const binding = require('./build/Release/binding'); +const binding = require(`./build/${common.buildType}/binding`); const assert = require('assert'); const skipMessage = 'intensive toString tests due to memory confinements'; diff --git a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-base64.js b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-base64.js index 53639a9f17531c..47426bf6352bbb 100644 --- a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-base64.js +++ b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-base64.js @@ -1,7 +1,7 @@ 'use strict'; const common = require('../../common'); -const binding = require('./build/Release/binding'); +const binding = require(`./build/${common.buildType}/binding`); const assert = require('assert'); const skipMessage = 'intensive toString tests due to memory confinements'; diff --git a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-binary.js b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-binary.js index 0fa4bca7232b78..c54706fd46c599 100644 --- a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-binary.js +++ b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-binary.js @@ -1,7 +1,7 @@ 'use strict'; const common = require('../../common'); -const binding = require('./build/Release/binding'); +const binding = require(`./build/${common.buildType}/binding`); const assert = require('assert'); const skipMessage = 'intensive toString tests due to memory confinements'; diff --git a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-hex.js b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-hex.js index ccbe7233410599..ae6966d0545194 100644 --- a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-hex.js +++ b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-hex.js @@ -1,7 +1,7 @@ 'use strict'; const common = require('../../common'); -const binding = require('./build/Release/binding'); +const binding = require(`./build/${common.buildType}/binding`); const assert = require('assert'); const skipMessage = 'intensive toString tests due to memory confinements'; diff --git a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-utf8.js b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-utf8.js index e20e0f5d191ae7..cea175aa93ab5c 100644 --- a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-utf8.js +++ b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-utf8.js @@ -1,7 +1,7 @@ 'use strict'; const common = require('../../common'); -const binding = require('./build/Release/binding'); +const binding = require(`./build/${common.buildType}/binding`); const assert = require('assert'); const skipMessage = 'intensive toString tests due to memory confinements'; diff --git a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-2.js b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-2.js index abe0ac5731e141..11f23ff1bf7627 100644 --- a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-2.js +++ b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-2.js @@ -1,7 +1,7 @@ 'use strict'; const common = require('../../common'); -const binding = require('./build/Release/binding'); +const binding = require(`./build/${common.buildType}/binding`); const assert = require('assert'); const skipMessage = 'intensive toString tests due to memory confinements'; diff --git a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max.js b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max.js index 5cc4a49df75ba2..f984179525abeb 100644 --- a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max.js +++ b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max.js @@ -1,7 +1,7 @@ 'use strict'; const common = require('../../common'); -const binding = require('./build/Release/binding'); +const binding = require(`./build/${common.buildType}/binding`); const assert = require('assert'); const skipMessage = 'intensive toString tests due to memory confinements'; diff --git a/test/addons/symlinked-module/test.js b/test/addons/symlinked-module/test.js index 8d3ced56e133db..d2025c54e4360b 100644 --- a/test/addons/symlinked-module/test.js +++ b/test/addons/symlinked-module/test.js @@ -14,7 +14,7 @@ const assert = require('assert'); common.refreshTmpDir(); -const addonPath = path.join(__dirname, 'build', 'Release'); +const addonPath = path.join(__dirname, 'build', common.buildType); const addonLink = path.join(common.tmpDir, 'addon'); try { diff --git a/test/addons/zlib-binding/test.js b/test/addons/zlib-binding/test.js index 1bd014507b760e..b50817aa5d4687 100644 --- a/test/addons/zlib-binding/test.js +++ b/test/addons/zlib-binding/test.js @@ -1,9 +1,9 @@ 'use strict'; -require('../../common'); +const common = require('../../common'); const assert = require('assert'); const zlib = require('zlib'); -const binding = require('./build/Release/binding'); +const binding = require(`./build/${common.buildType}/binding`); const input = Buffer.from('Hello, World!'); diff --git a/test/common.js b/test/common.js index 1c363882216c63..8a5a5f14c1cba0 100644 --- a/test/common.js +++ b/test/common.js @@ -36,6 +36,7 @@ const cpus = os.cpus(); exports.enoughTestCpu = cpus.length > 1 || cpus[0].speed > 999; exports.rootDir = exports.isWindows ? 'c:\\' : '/'; +exports.buildType = process.config.target_defaults.default_configuration; function rimrafSync(p) { try { diff --git a/tools/doc/addon-verify.js b/tools/doc/addon-verify.js index 299d4847ef3eb3..86a81935892745 100644 --- a/tools/doc/addon-verify.js +++ b/tools/doc/addon-verify.js @@ -65,8 +65,8 @@ function verifyFiles(files, blockName, onprogress, ondone) { files = Object.keys(files).map(function(name) { if (name === 'test.js') { files[name] = `'use strict'; -require('../../common'); -${files[name]} +const common = require('../../common'); +${files[name].replace('Release', "' + common.buildType + '")} `; } return {