diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 47fcefd6..4c186735 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 diff --git a/package.json b/package.json index fbde61ed..2f19a1e1 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/test/fixtures/test.js b/test/fixtures/test.js new file mode 100644 index 00000000..e1a34da7 --- /dev/null +++ b/test/fixtures/test.js @@ -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'))