Skip to content

Commit

Permalink
Workaround PATH casing issues on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Mercer committed Jun 29, 2022
1 parent 4792297 commit c156049
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
7 changes: 7 additions & 0 deletions lib/testing-utils.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/testing-utils.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/testing-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ export function setupTests(test: TestFn<any>) {
t.context.stderrWrite = processStderrWrite;
process.stderr.write = wrapOutput(t.context) as any;

// Workaround an issue in tests where the case insensitivity of the `$PATH`
// environment variable on Windows isn't preserved, i.e. `process.env.PATH`
// is not the same as `process.env.Path`.
const pathKeys = Object.keys(process.env).filter(
(k) => k.toLowerCase() === "path"
);
if (pathKeys.length > 0) {
process.env.PATH = process.env[pathKeys[0]];
}

// Many tests modify environment variables. Take a copy now so that
// we reset them after the test to keep tests independent of each other.
// process.env only has strings fields, so a shallow copy is fine.
Expand Down

0 comments on commit c156049

Please sign in to comment.