Skip to content

Commit

Permalink
tests: run (and pass) on windows
Browse files Browse the repository at this point in the history
Threw a kludge in there to run tap with lower coverage reqs on Windows.
  • Loading branch information
isaacs committed Aug 9, 2021
1 parent c2a0948 commit 9e018cf
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
14 changes: 5 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,8 @@ jobs:
shell: bash
- os: macos-latest
shell: bash

# TODO: make tests pass on windows. it works, but the tests have
# quite a lot of unixisms wrt modes and paths. mostly trivial
# stuff to fix, but a lot of it.
#
# - os: windows-latest
# shell: bash
# - os: windows-latest
# shell: powershell
- os: windows-latest
shell: powershell

fail-fast: false

Expand All @@ -42,6 +35,9 @@ jobs:
with:
node-version: ${{ matrix.node-version }}

- name: use latest npm
run: npm i -g npm@latest

- name: Install dependencies
run: npm install

Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"url": "https://github.com/npm/node-tar.git"
},
"scripts": {
"test": "tap",
"test:posix": "tap",
"test:win32": "tap --lines=98 --branches=98 --statements=98 --functions=98",
"test": "node test/fixtures/test.js",
"posttest": "npm run lint",
"eslint": "eslint",
"lint": "npm run eslint -- test lib",
Expand Down
20 changes: 20 additions & 0 deletions test/fixtures/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const platform = process.platform === 'win32' ? 'win32' : 'posix'
const {spawn} = require('child_process')
const c = spawn(process.execPath, [
process.env.npm_execpath,
'run',
`test:${platform}`,
'--',
...process.argv.slice(2),
], {
stdio: 'inherit',
})
c.on('close', (code, signal) => {
process.exitCode = code
if (signal) {
process.kill(process.pid, signal)
setTimeout(() => {}, 200)
}
})
process.on('SIGTERM', () => c.kill('SIGTERM'))
process.on('SIGINT', () => c.kill('SIGINT'))

0 comments on commit 9e018cf

Please sign in to comment.