Skip to content

Commit 53cea6e

Browse files
committed
tests: run (and pass) on windows
Threw a kludge in there to run tap with lower coverage reqs on Windows.
1 parent 166cfc0 commit 53cea6e

File tree

3 files changed

+68
-1
lines changed

3 files changed

+68
-1
lines changed

.github/workflows/ci.yml

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
strategy:
8+
matrix:
9+
node-version: [10.x, 12.x, 14.x]
10+
platform:
11+
- os: ubuntu-latest
12+
shell: bash
13+
- os: macos-latest
14+
shell: bash
15+
- os: windows-latest
16+
shell: powershell
17+
18+
fail-fast: false
19+
20+
runs-on: ${{ matrix.platform.os }}
21+
defaults:
22+
run:
23+
shell: ${{ matrix.platform.shell }}
24+
25+
steps:
26+
# there are files here that make windows unhappy by default
27+
- name: Support longpaths
28+
run: git config --global core.longpaths true
29+
30+
- name: Checkout Repository
31+
uses: actions/[email protected]
32+
33+
- name: Use Nodejs ${{ matrix.node-version }}
34+
uses: actions/setup-node@v1
35+
with:
36+
node-version: ${{ matrix.node-version }}
37+
38+
- name: use latest npm
39+
run: npm i -g npm@latest
40+
41+
- name: Install dependencies
42+
run: npm install
43+
44+
- name: Run Tap Tests
45+
run: npm test -- -c -t0

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
"url": "https://github.com/npm/node-tar.git"
1212
},
1313
"scripts": {
14-
"test": "tap",
14+
"test:posix": "tap",
15+
"test:win32": "tap --lines=98 --branches=98 --statements=98 --functions=98",
16+
"test": "node test/fixtures/test.js",
1517
"preversion": "npm test",
1618
"postversion": "npm publish",
1719
"postpublish": "git push origin --follow-tags",

test/fixtures/test.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const platform = process.platform === 'win32' ? 'win32' : 'posix'
2+
const {spawn} = require('child_process')
3+
const c = spawn(process.execPath, [
4+
process.env.npm_execpath,
5+
'run',
6+
`test:${platform}`,
7+
'--',
8+
...process.argv.slice(2),
9+
], {
10+
stdio: 'inherit',
11+
})
12+
c.on('close', (code, signal) => {
13+
process.exitCode = code
14+
if (signal) {
15+
process.kill(process.pid, signal)
16+
setTimeout(() => {}, 200)
17+
}
18+
})
19+
process.on('SIGTERM', () => c.kill('SIGTERM'))
20+
process.on('SIGINT', () => c.kill('SIGINT'))

0 commit comments

Comments
 (0)