Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
test: improve error message for policy failures
  • Loading branch information
bmeck authored and Trott committed Oct 18, 2020
commit 8c14f61f24208a4a18ece198bdcade399fd976f8
17 changes: 17 additions & 0 deletions test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,22 @@ function gcUntil(name, condition) {
});
}

function requireNoPackageJSONAbove() {
let possiblePackage = path.join(__dirname, '..', 'package.json');
let lastPackage = null;
while (possiblePackage !== lastPackage) {
if (fs.existsSync(possiblePackage)) {
throw new Error(
Comment thread
bmeck marked this conversation as resolved.
Outdated
'This test shouldn\'t load properties from a package.json above ' +
`it's file location. Found package.json at ${possiblePackage}, ` +
'in order to run this test properly ensure no package.json is above ' +
'the tests.');
Comment thread
bmeck marked this conversation as resolved.
Outdated
}
lastPackage = possiblePackage;
possiblePackage = path.join(possiblePackage, '..', '..', 'package.json');
}
}

const common = {
allowGlobals,
buildType,
Expand Down Expand Up @@ -736,6 +752,7 @@ const common = {
platformTimeout,
printSkipMessage,
pwdCommand,
requireNoPackageJSONAbove,
runWithInvalidFD,
skip,
skipIf32Bits,
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-policy-dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
common.requireNoPackageJSONAbove();

const fixtures = require('../common/fixtures');

Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-policy-dependency-conditions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
const common = require('../common');

if (!common.hasCrypto) common.skip('missing crypto');
common.requireNoPackageJSONAbove();

const Manifest = require('internal/policy/manifest').Manifest;

Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-policy-integrity-flag.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
common.requireNoPackageJSONAbove();

const fixtures = require('../common/fixtures');

Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-policy-parse-integrity.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const common = require('../common');
if (!common.hasCrypto) common.skip('missing crypto');
common.requireNoPackageJSONAbove();

const tmpdir = require('../common/tmpdir');
const assert = require('assert');
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-policy-scopes-integrity.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
const common = require('../common');

if (!common.hasCrypto) common.skip('missing crypto');
common.requireNoPackageJSONAbove();

const Manifest = require('internal/policy/manifest').Manifest;
const assert = require('assert');
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-policy-scopes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
common.requireNoPackageJSONAbove();

const fixtures = require('../common/fixtures');

Expand Down
1 change: 1 addition & 0 deletions test/pummel/test-policy-integrity.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const common = require('../common');
if (!common.hasCrypto) common.skip('missing crypto');
common.requireNoPackageJSONAbove();

const { debuglog } = require('util');
const debug = debuglog('test');
Expand Down