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

Add Windows to CI #1

Merged
merged 8 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ on:

jobs:
test:
runs-on: ubuntu-latest
runs-on: ${{matrix.os}}

strategy:
matrix:
node-version: [18.x, 20.x, 21.x]
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v3

Expand Down
8 changes: 7 additions & 1 deletion borp.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { tap, spec } from 'node:test/reporters'
import { mkdtemp, rm } from 'node:fs/promises'
import { finished } from 'node:stream/promises'
import { join, relative } from 'node:path'
import posix from 'node:path/posix'
import runWithTypeScript from './lib/run.js'
import { Report } from 'c8'

Expand Down Expand Up @@ -55,6 +56,10 @@ const config = {
try {
const stream = await runWithTypeScript(config)

stream.on('test:fail', () => {
process.exitCode = 1
})

stream.compose(reporter).pipe(process.stdout)

await finished(stream)
Expand All @@ -66,8 +71,9 @@ try {
exclude = undefined
} else if (config.prefix) {
const localPrefix = relative(process.cwd(), config.prefix)
exclude = exclude.map((file) => join(localPrefix, file))
exclude = exclude.map((file) => posix.join(localPrefix, file))
}
console.log('>> Excluding from coverage:', exclude)
const report = Report({
reporter: ['text'],
tempDirectory: covDir,
Expand Down
6 changes: 6 additions & 0 deletions fixtures/fails/test/wrong.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { strictEqual } from 'node:assert'
import { test } from 'node:test'

test('this will fail', () => {
strictEqual(1, 2)
})
7 changes: 4 additions & 3 deletions lib/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export default async function runWithTypeScript (config) {
}

let files = config.files || []
const ignore = join('node_modules', '**')
if (files.length > 0) {
if (prefix) {
files = files.map((file) => join(prefix, file.replace(/ts$/, 'js')))
Expand All @@ -123,11 +124,11 @@ export default async function runWithTypeScript (config) {
if (prefix) {
config.pattern = join(prefix, config.pattern)
}
files = await glob(config.pattern, { ignore: 'node_modules/**', cwd })
files = await glob(config.pattern, { ignore, cwd, windowsPathsNoEscape: true })
} else if (prefix) {
files = await glob(join(prefix, 'test/**/*.test.{cjs,mjs,js}'), { ignore: 'node_modules/**', cwd })
files = await glob(join(prefix, join('test', '**', '*.test.{cjs,mjs,js}')), { ignore, cwd, windowsPathsNoEscape: true })
} else {
files = await glob('test/**/*.test.{cjs,mjs,js}', { ignore: 'node_modules/**', cwd })
files = await glob(join('test', '**', '*.test.{cjs,mjs,js}'), { ignore, cwd, windowsPathsNoEscape: true })
}

config.files = files
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"scripts": {
"clean": "rm -rf fixtures/*/dist .test-* coverage-*",
"lint": "standard | snazzy",
"unit": "./borp.js --concurrency=1 --coverage --coverage-exclude 'fixtures/**/*,test/**/*'",
"unit": "node borp.js --concurrency=1 --coverage --coverage-exclude \"fixtures/**/*,test/**/*\"",
"test": "npm run clean ; npm run lint && npm run unit"
},
"keywords": [],
Expand Down
10 changes: 10 additions & 0 deletions test/cli.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { test } from 'node:test'
import { execa } from 'execa'
import { join } from 'desm'
import { rejects } from 'node:assert'

const borp = join(import.meta.url, '..', 'borp.js')

Expand All @@ -13,3 +14,12 @@ test('limit concurrency', async () => {
cwd: join(import.meta.url, '..', 'fixtures', 'ts-esm')
})
})

test('failing test set correct status code', async () => {
// execa rejects if status code is not 0
await rejects(execa('node', [
borp
], {
cwd: join(import.meta.url, '..', 'fixtures', 'fails')
}))
})
Loading