Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace PATH_KEY with pathKey(), delete fixtureEnv #3

Merged
merged 2 commits into from
Dec 28, 2023
Merged

Conversation

mbland
Copy link
Owner

@mbland mbland commented Dec 28, 2023

The original motivation was the loss of branch coverage from the PATH_KEY initialization expression only ever following one branch. But it also made the getPath.test.js tests more self-documenting.

The same goes for hoisting the logic of the former fixtureEnv() helper into the getPath test fixture itself. Also, today I learned two things:

  1. Forward slashes are legal Windows path separators, per: https://stackoverflow.com/a/63251716

  2. Node's path.join() will convert any forward slashes in any of its arguments to backslashes on Windows:

    > node -e "console.log(path.join('foo/bar\baz/quux', 'xyzzy/plugh'))"
    foo\baaz\quux\xyzzy\plugh

Hence the replacement of path.join(...) with plain 'usr/local/bin', etc.

The original motivation was the loss of branch coverage from the
PATH_KEY initialization expression only ever following one branch. But
it also made the getPath.test.js tests more self-documenting.

The same goes for hoisting the logic of the former fixtureEnv() helper
into the getPath test fixture itself. Also, today I learned two things:

1. Forward slashes are legal Windows path separators, per:
   https://stackoverflow.com/a/63251716

2. Node's path.join() will convert any forward slashes in any of its
   arguments to backslashes on Windows:

   ```pwsh
   > node -e "console.log(path.join('foo/bar\baz/quux', 'xyzzy/plugh'))"
   foo\baaz\quux\xyzzy\plugh
   ```

Hence the replacement of path.join(...) with plain 'usr/local/bin', etc.
@mbland mbland self-assigned this Dec 28, 2023
On Windows, the "rejects when command isn't found" case failed because
the message contained "nonexistent.CMD" instead of plain "nonexistent".

In the process of fixing it, I decided to add the makeEnv() test helper
to make the test cases a little more concise and readable.
@mbland mbland merged commit 83d0a16 into main Dec 28, 2023
2 checks passed
@mbland mbland deleted the replace-path-key branch December 28, 2023 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant