Skip to content

Commit

Permalink
fix: coverage reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzlopak committed Feb 15, 2024
1 parent edd22bc commit 90fab5a
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 13 deletions.
13 changes: 13 additions & 0 deletions .c8rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"all": true,
"reporter": [
"lcov",
"text",
"html",
"text-summary"
],
"include": [
"lib/**/*.js",
"index.js"
]
}
5 changes: 5 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ jobs:
post-test-steps: |
- name: Coverage Report
uses: codecov/codecov-action@v4
secrets:
test-secrets: |-
{
"NODE_V8_COVERAGE": "./coverage/tmp"
}
automerge:
if: >
github.event_name == 'pull_request' && github.event.pull_request.user.login == 'dependabot[bot]'
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,6 @@ fuzz-results-*.json
# Bundle output
undici-fetch.js
/test/imports/undici-import.js

# .npmrc has platform specific value for windows
.npmrc
32 changes: 19 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,27 +67,31 @@
"build:wasm": "node build/wasm.js --docker",
"lint": "standard | snazzy",
"lint:fix": "standard --fix | snazzy",
"test": "node scripts/generate-pem && npm run test:unit && npm run test:node-fetch && npm run test:fetch && npm run test:cookies && npm run test:eventsource && npm run test:wpt && npm run test:websocket && npm run test:jest && npm run test:typescript && npm run test:node-test",
"test:cookies": "borp --coverage -p \"test/cookie/*.js\"",
"test:node-fetch": "borp --coverage -p \"test/node-fetch/**/*.js\"",
"test:eventsource": "npm run build:node && borp --expose-gc --coverage -p \"test/eventsource/*.js\"",
"test:fetch": "npm run build:node && borp --expose-gc --coverage -p \"test/fetch/*.js\" && borp --coverage -p \"test/webidl/*.js\"",
"test:jest": "jest",
"test": "npm run test:javascript && npm run test:typescript",
"test:javascript": "node scripts/generate-pem && npm run test:unit && npm run test:node-fetch && npm run test:fetch && npm run test:cookies && npm run test:eventsource && npm run test:wpt && npm run test:websocket && npm run test:node-test && npm run test:jest",
"test:cookies": "borp -p \"test/cookie/*.js\"",
"test:node-fetch": "borp -p \"test/node-fetch/**/*.js\"",
"test:eventsource": "npm run build:node && borp --expose-gc -p \"test/eventsource/*.js\"",
"test:fetch": "npm run build:node && borp --expose-gc -p \"test/fetch/*.js\" && borp -p \"test/webidl/*.js\"",
"test:jest": "cross-env NODE_V8_COVERAGE= jest",
"test:unit": "borp --expose-gc -p \"test/*.js\"",
"test:node-test": "borp --coverage -p \"test/node-test/**/*.js\"",
"test:tdd": "borp --coverage --expose-gc -p \"test/*.js\"",
"test:node-test": "borp -p \"test/node-test/**/*.js\"",
"test:tdd": "borp --expose-gc -p \"test/*.js\"",
"test:tdd:node-test": "borp -p \"test/node-test/**/*.js\" -w",
"test:typescript": "tsd && tsc --skipLibCheck test/imports/undici-import.ts",
"test:websocket": "borp --coverage -p \"test/websocket/*.js\"",
"test:typescript": "cross-env NODE_V8_COVERAGE= tsd && tsc --skipLibCheck test/imports/undici-import.ts",
"test:websocket": "borp -p \"test/websocket/*.js\"",
"test:wpt": "node test/wpt/start-fetch.mjs && node test/wpt/start-FileAPI.mjs && node test/wpt/start-mimesniff.mjs && node test/wpt/start-xhr.mjs && node test/wpt/start-websockets.mjs && node test/wpt/start-cacheStorage.mjs && node test/wpt/start-eventsource.mjs",
"coverage": "nyc --reporter=text --reporter=html npm run test",
"coverage:ci": "nyc --reporter=lcov npm run test",
"coverage": "cross-env NODE_V8_COVERAGE=./coverage/tmp && npm run coverage:clean && npm run test && npm run coverage:report",
"coverage:ci": "npm run coverage:clean && npm run test && npm run coverage:report:ci",
"coverage:clean": "node ./scripts/clean-coverage.js",
"coverage:report": "cross-env NODE_V8_COVERAGE= c8 report",
"coverage:report:ci": "c8 report",
"bench": "PORT=3042 concurrently -k -s first npm:bench:server npm:bench:run",
"bench:server": "node benchmarks/server.js",
"prebench:run": "node benchmarks/wait.js",
"bench:run": "SAMPLES=100 CONNECTIONS=50 node benchmarks/benchmark.js",
"serve:website": "docsify serve .",
"prepare": "husky install",
"prepare": "husky install && node ./scripts/platform-shell.js",
"fuzz": "jsfuzz test/fuzzing/fuzz.js corpus"
},
"devDependencies": {
Expand All @@ -98,8 +102,10 @@
"abort-controller": "^3.0.0",
"axios": "^1.6.5",
"borp": "^0.9.1",
"c8": "^9.1.0",
"concurrently": "^8.0.1",
"cronometro": "^3.0.1",
"cross-env": "^7.0.3",
"dns-packet": "^5.4.0",
"docsify-cli": "^4.4.3",
"form-data": "^4.0.0",
Expand Down
14 changes: 14 additions & 0 deletions scripts/clean-coverage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict'

const { rmSync } = require('node:fs')
const { resolve } = require('node:path')

if (process.env.NODE_V8_COVERAGE) {
if (process.env.NODE_V8_COVERAGE.endsWith('/tmp')) {
rmSync(resolve(__dirname, process.env.NODE_V8_COVERAGE, '..'), { recursive: true, force: true })
} else {
rmSync(resolve(__dirname, process.env.NODE_V8_COVERAGE), { recursive: true, force: true })
}
} else {
rmSync(resolve(__dirname, 'coverage'), { recursive: true, force: true })
}
12 changes: 12 additions & 0 deletions scripts/platform-shell.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict'

const { platform } = require('node:os')
const { writeFileSync } = require('node:fs')
const { resolve } = require('node:path')

if (platform() === 'win32') {
writeFileSync(
resolve(__dirname, '.npmrc'),
'script-shell = "C:\\windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"\n'
)
}
3 changes: 3 additions & 0 deletions test/wpt/runner/runner.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ export class WPTRunner extends EventEmitter {
url.search = variant
}
const worker = new Worker(workerPath, {
env: {
NODE_V8_COVERAGE: process.env.NODE_V8_COVERAGE
},
workerData: {
// Code to load before the test harness and tests.
initScripts: this.#initScripts,
Expand Down

0 comments on commit 90fab5a

Please sign in to comment.