Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 27d7588

Browse filesBrowse files
richardlautargos
authored andcommitted
test: add ancestor package.json checks for tmpdir
Policy tests can fail if a `package.json` exists in any of the parent directories above the test. The existing checks are done for the ancestors of the test directory but some tests execute from the tmpdir. PR-URL: #38285 Refs: #38088 Refs: #35600 Refs: #35633 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 0e88ae7 commit 27d7588
Copy full SHA for 27d7588

File tree

Expand file treeCollapse file tree

3 files changed

+8
-5
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+8
-5
lines changed
Open diff view settings
Collapse file

‎test/common/README.md‎

Copy file name to clipboardExpand all lines: test/common/README.md
+5-3Lines changed: 5 additions & 3 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -370,10 +370,12 @@ const { spawn } = require('child_process');
370370
spawn(...common.pwdCommand, { stdio: ['pipe'] });
371371
```
372372

373-
### `requireNoPackageJSONAbove()`
373+
### `requireNoPackageJSONAbove([dir])`
374374

375-
Throws an `AssertionError` if a `package.json` file is in any ancestor
376-
directory. Such files may interfere with proper test functionality.
375+
* `dir` [&lt;string>][] default = \_\_dirname
376+
377+
Throws an `AssertionError` if a `package.json` file exists in any ancestor
378+
directory above `dir`. Such files may interfere with proper test functionality.
377379

378380
### `runWithInvalidFD(func)`
379381

Collapse file

‎test/common/index.js‎

Copy file name to clipboardExpand all lines: test/common/index.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -708,8 +708,8 @@ function gcUntil(name, condition) {
708708
});
709709
}
710710

711-
function requireNoPackageJSONAbove() {
712-
let possiblePackage = path.join(__dirname, '..', 'package.json');
711+
function requireNoPackageJSONAbove(dir = __dirname) {
712+
let possiblePackage = path.join(dir, '..', 'package.json');
713713
let lastPackage = null;
714714
while (possiblePackage !== lastPackage) {
715715
if (fs.existsSync(possiblePackage)) {
Collapse file

‎test/pummel/test-policy-integrity.js‎

Copy file name to clipboardExpand all lines: test/pummel/test-policy-integrity.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ function newTestId() {
7676
return nextTestId++;
7777
}
7878
tmpdir.refresh();
79+
common.requireNoPackageJSONAbove(tmpdir.path);
7980

8081
let spawned = 0;
8182
const toSpawn = [];

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.