From 39986fa426d0ef40ddcae05778f2ba307fa9fdeb Mon Sep 17 00:00:00 2001 From: Kenvin Davies Date: Thu, 26 Aug 2021 22:23:33 -0700 Subject: [PATCH] test: run tests with opts to prefix bld root path PR-URL: https://github.com/nodejs/node-addon-api/pull/1055 Reviewed-By: Michael Dawson --- package.json | 1 + test/common/index.js | 17 +++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index b93cc90..4bd6c20 100644 --- a/package.json +++ b/package.json @@ -318,6 +318,7 @@ "bindings": "^1.5.0", "clang-format": "^1.4.0", "fs-extra": "^9.0.1", + "path": "^0.12.7", "pre-commit": "^1.2.2", "safe-buffer": "^5.1.1" }, diff --git a/test/common/index.js b/test/common/index.js index 2863925..1109799 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -1,6 +1,7 @@ /* Test helpers ported from test/common/index.js in Node.js project. */ 'use strict'; const assert = require('assert'); +const path = require('path'); const noop = () => {}; @@ -75,13 +76,13 @@ exports.mustNotCall = function(msg) { }; }; -exports.runTest = async function(test, buildType) { +exports.runTest = async function(test, buildType, buildPathRoot = process.env.REL_BUILD_PATH || '') { buildType = buildType || process.config.target_defaults.default_configuration || 'Release'; const bindings = [ - `../build/${buildType}/binding.node`, - `../build/${buildType}/binding_noexcept.node`, - `../build/${buildType}/binding_noexcept_maybe.node`, + path.join(buildPathRoot, `../build/${buildType}/binding.node`), + path.join(buildPathRoot, `../build/${buildType}/binding_noexcept.node`), + path.join(buildPathRoot, `../build/${buildType}/binding_noexcept_maybe.node`), ].map(it => require.resolve(it)); for (const item of bindings) { @@ -90,13 +91,13 @@ exports.runTest = async function(test, buildType) { } } -exports.runTestWithBindingPath = async function(test, buildType) { +exports.runTestWithBindingPath = async function(test, buildType, buildPathRoot = process.env.REL_BUILD_PATH || '') { buildType = buildType || process.config.target_defaults.default_configuration || 'Release'; const bindings = [ - `../build/${buildType}/binding.node`, - `../build/${buildType}/binding_noexcept.node`, - `../build/${buildType}/binding_noexcept_maybe.node`, + path.join(buildPathRoot, `../build/${buildType}/binding.node`), + path.join(buildPathRoot, `../build/${buildType}/binding_noexcept.node`), + path.join(buildPathRoot, `../build/${buildType}/binding_noexcept_maybe.node`), ].map(it => require.resolve(it)); for (const item of bindings) {