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 166cfc0 commit 53cea6e
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 1 deletion.
45 changes: 45 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: CI

on: [push, pull_request]

jobs:
build:
strategy:
matrix:
node-version: [10.x, 12.x, 14.x]
platform:
- os: ubuntu-latest
shell: bash
- os: macos-latest
shell: bash
- os: windows-latest
shell: powershell

fail-fast: false

runs-on: ${{ matrix.platform.os }}
defaults:
run:
shell: ${{ matrix.platform.shell }}

steps:
# there are files here that make windows unhappy by default
- name: Support longpaths
run: git config --global core.longpaths true

- name: Checkout Repository
uses: actions/checkout@v1.1.0

- name: Use Nodejs ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

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

- name: Install dependencies
run: npm install

- name: Run Tap Tests
run: npm test -- -c -t0
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,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",
"preversion": "npm test",
"postversion": "npm publish",
"postpublish": "git push origin --follow-tags",
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 53cea6e

Please sign in to comment.