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

Fix path parsing and tests on windows #602

Merged
4 commits merged into from
Jan 10, 2024

Commits on Jan 7, 2024

  1. [Fix] stack trace path parsing on windows

    Source files which are located in the current working directory, have a part of their path replaced by `path.sep + '$CWD'`. However, this causes the regular expression for stack trace lines to not match on windows.
    
    Example of a stack trace line, after replacement (`console.log(lineWithTokens)` in lib/test.js):
    
    ```
       at Test.assert [as _assert] (\$CWD\example\my-test.js:483:11)
    ```
    
    The part of the regexp that fails is `(?:\/|[a-zA-Z]:\\)`. I fixed this by allowing the path to start with a backslash. So instead of `\/`, the regexp uses `[/\\]`.
    
    This issue is already covered by existing test cases that are currently failing when they are ran on windows. For example: `.\node_modules\.bin\tap test/*.js`
    Joris-van-der-Wel authored and ljharb committed Jan 7, 2024
    Configuration menu
    Copy the full SHA
    9cbae8a View commit details
    Browse the repository at this point in the history
  2. [Fix] bin/tape: ignore options on windows

    The current version of `glob` returns paths always with forward slashes, even on windows. This causes the `dotignore` `Matcher` to never match the paths on windows, because it expects backslashes on windows. This means that the `--ignore` and `--ignore-pattern` options do not work properly on windows.
    
    This is fixed in a newer version of glob (not sure which specific version). However, we can not upgrade because it drops support for older node versions that we still want to support in tape. So instead, a workaround is to correct the slashes ourselves.
    
    This issue is already covered by existing test cases (test/ignore-pattern.js), that are currently failing when they are ran on windows. For example: `.\node_modules\.bin\tap test/*.js`. However, an additional fix is needed to make these tests pass (see next commit).
    Joris-van-der-Wel authored and ljharb committed Jan 7, 2024
    Configuration menu
    Copy the full SHA
    a2b74f9 View commit details
    Browse the repository at this point in the history
  3. [Tests] Spawn processes during tests using execPath so that the tests…

    … pass on windows
    
    In some parts of the code the `bin/tape` script was executed directly. This does not always work on windows, causing those tests to fail. So instead `process.execPath` is executed (which is the path to the node binary), and the script is passed as an argument. In other parts of the code, argv[0] was used. This has been made consistent so that execPath is used everywhere.
    Joris-van-der-Wel authored and ljharb committed Jan 7, 2024
    Configuration menu
    Copy the full SHA
    4a57fbe View commit details
    Browse the repository at this point in the history
  4. [Tests] fix npm test on windows

    The version of "nyc" (v9) that is being used does not support launching binaries from node_modules/.bin on windows. As a workaround the path to tap's run.js is specified. Newer version of nyc fix this issue, however those versions drop support for older node versions that we still want to support here.
    
    Also, the windows shell does not understand single quotes.
    Joris-van-der-Wel authored and ljharb committed Jan 7, 2024
    Configuration menu
    Copy the full SHA
    bcf6ce7 View commit details
    Browse the repository at this point in the history