summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/common/README.md5
-rw-r--r--test/common/index.js15
-rw-r--r--test/parallel/test-policy-dependencies.js1
-rw-r--r--test/parallel/test-policy-dependency-conditions.js1
-rw-r--r--test/parallel/test-policy-integrity-flag.js1
-rw-r--r--test/parallel/test-policy-parse-integrity.js1
-rw-r--r--test/parallel/test-policy-scopes-dependencies.js1
-rw-r--r--test/parallel/test-policy-scopes-integrity.js1
-rw-r--r--test/parallel/test-policy-scopes.js1
-rw-r--r--test/pummel/test-policy-integrity.js1
10 files changed, 28 insertions, 0 deletions
diff --git a/test/common/README.md b/test/common/README.md
index 31d37d7abd..5ce7473cb5 100644
--- a/test/common/README.md
+++ b/test/common/README.md
@@ -378,6 +378,11 @@ const { spawn } = require('child_process');
spawn(...common.pwdCommand, { stdio: ['pipe'] });
```
+### `requireNoPackageJSONAbove()`
+
+Throws an `AssertionError` if a `package.json` file is in any ancestor
+directory. Such files may interfere with proper test functionality.
+
### `runWithInvalidFD(func)`
* `func` [<Function>][]
diff --git a/test/common/index.js b/test/common/index.js
index b75c5441d2..4ec68cf585 100644
--- a/test/common/index.js
+++ b/test/common/index.js
@@ -697,6 +697,20 @@ function gcUntil(name, condition) {
});
}
+function requireNoPackageJSONAbove() {
+ let possiblePackage = path.join(__dirname, '..', 'package.json');
+ let lastPackage = null;
+ while (possiblePackage !== lastPackage) {
+ if (fs.existsSync(possiblePackage)) {
+ assert.fail(
+ 'This test shouldn\'t load properties from a package.json above ' +
+ `its file location. Found package.json at ${possiblePackage}.`);
+ }
+ lastPackage = possiblePackage;
+ possiblePackage = path.join(possiblePackage, '..', '..', 'package.json');
+ }
+}
+
const common = {
allowGlobals,
buildType,
@@ -736,6 +750,7 @@ const common = {
platformTimeout,
printSkipMessage,
pwdCommand,
+ requireNoPackageJSONAbove,
runWithInvalidFD,
skip,
skipIf32Bits,
diff --git a/test/parallel/test-policy-dependencies.js b/test/parallel/test-policy-dependencies.js
index e7b2289714..4486e0f8aa 100644
--- a/test/parallel/test-policy-dependencies.js
+++ b/test/parallel/test-policy-dependencies.js
@@ -3,6 +3,7 @@
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
+common.requireNoPackageJSONAbove();
const fixtures = require('../common/fixtures');
diff --git a/test/parallel/test-policy-dependency-conditions.js b/test/parallel/test-policy-dependency-conditions.js
index c9db95929d..dec17aa229 100644
--- a/test/parallel/test-policy-dependency-conditions.js
+++ b/test/parallel/test-policy-dependency-conditions.js
@@ -4,6 +4,7 @@
const common = require('../common');
if (!common.hasCrypto) common.skip('missing crypto');
+common.requireNoPackageJSONAbove();
const Manifest = require('internal/policy/manifest').Manifest;
diff --git a/test/parallel/test-policy-integrity-flag.js b/test/parallel/test-policy-integrity-flag.js
index d97ef86cbe..ddcd02236d 100644
--- a/test/parallel/test-policy-integrity-flag.js
+++ b/test/parallel/test-policy-integrity-flag.js
@@ -3,6 +3,7 @@
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
+common.requireNoPackageJSONAbove();
const fixtures = require('../common/fixtures');
diff --git a/test/parallel/test-policy-parse-integrity.js b/test/parallel/test-policy-parse-integrity.js
index d042ccee0a..3a31d0d57f 100644
--- a/test/parallel/test-policy-parse-integrity.js
+++ b/test/parallel/test-policy-parse-integrity.js
@@ -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');
diff --git a/test/parallel/test-policy-scopes-dependencies.js b/test/parallel/test-policy-scopes-dependencies.js
index 202e6459a6..a5a9302ac6 100644
--- a/test/parallel/test-policy-scopes-dependencies.js
+++ b/test/parallel/test-policy-scopes-dependencies.js
@@ -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');
diff --git a/test/parallel/test-policy-scopes-integrity.js b/test/parallel/test-policy-scopes-integrity.js
index b61fc3199c..8c91cea142 100644
--- a/test/parallel/test-policy-scopes-integrity.js
+++ b/test/parallel/test-policy-scopes-integrity.js
@@ -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');
diff --git a/test/parallel/test-policy-scopes.js b/test/parallel/test-policy-scopes.js
index b1ba160bdd..129287c73c 100644
--- a/test/parallel/test-policy-scopes.js
+++ b/test/parallel/test-policy-scopes.js
@@ -3,6 +3,7 @@
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
+common.requireNoPackageJSONAbove();
const fixtures = require('../common/fixtures');
diff --git a/test/pummel/test-policy-integrity.js b/test/pummel/test-policy-integrity.js
index 57625268fa..15124aefd4 100644
--- a/test/pummel/test-policy-integrity.js
+++ b/test/pummel/test-policy-integrity.js
@@ -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');