Skip to content

Commit

Permalink
exclude test files themselves from coverage
Browse files Browse the repository at this point in the history
Fix: #881
  • Loading branch information
isaacs committed Sep 10, 2023
1 parent aff25fc commit 1dcc6a7
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 11 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -22,7 +22,7 @@
"@11ty/eleventy-plugin-syntaxhighlight": "^5.0.0",
"@esbuild-kit/cjs-loader": "^2.4.2",
"@esbuild-kit/esm-loader": "^2.5.5",
"@tapjs/processinfo": "^3.0.2",
"@tapjs/processinfo": "^3.1.0",
"@types/diff": "^5.0.3",
"@types/ms": "^0.7.31",
"@types/mustache": "^4.2.2",
Expand Down
2 changes: 1 addition & 1 deletion src/core/package.json
Expand Up @@ -46,7 +46,7 @@
"coverage-map": "map.js"
},
"dependencies": {
"@tapjs/processinfo": "^3.0.2",
"@tapjs/processinfo": "^3.1.0",
"@tapjs/stack": "0.0.0-7",
"@tapjs/test": "0.0.0-21",
"async-hook-domain": "^4.0.1",
Expand Down
2 changes: 1 addition & 1 deletion src/run/package.json
Expand Up @@ -44,7 +44,7 @@
"@tapjs/after": "0.0.0-21",
"@tapjs/before": "0.0.0-21",
"@tapjs/config": "2.0.0-22",
"@tapjs/processinfo": "^3.0.2",
"@tapjs/processinfo": "^3.1.0",
"@tapjs/reporter": "0.0.0-23",
"@tapjs/spawn": "0.0.0-21",
"@tapjs/stdin": "0.0.0-21",
Expand Down
1 change: 1 addition & 0 deletions src/run/src/after.ts
Expand Up @@ -19,5 +19,6 @@ export const runAfter = (
)
})
)
return resolve(after)
}
}
1 change: 1 addition & 0 deletions src/run/src/before.ts
Expand Up @@ -22,5 +22,6 @@ export const runBefore = (t: TAP, argv: string[], config: LoadedConfig) => {
)
})
)
return resolve(before)
}
}
15 changes: 13 additions & 2 deletions src/run/src/run.ts
Expand Up @@ -49,6 +49,9 @@ export const run = async (args: string[], config: LoadedConfig) => {
const saveList = await readSave(config)
const map = await getCoverageMap(config)

const covExcludeFiles: (string | undefined)[] = []
let _TAPJS_PROCESSINFO_COV_EXCLUDE_FILES_: string | undefined = undefined

return executeTestSuite(
args,
config,
Expand Down Expand Up @@ -92,8 +95,8 @@ export const run = async (args: string[], config: LoadedConfig) => {
},

async t => {
runBefore(t, argv, config)
runAfter(t, argv, config)
covExcludeFiles.push(runBefore(t, argv, config))
covExcludeFiles.push(runAfter(t, argv, config))

// don't delete old coverage if only running subset of suites
if (!config.get('changed') && !saveList.length) {
Expand All @@ -105,6 +108,13 @@ export const run = async (args: string[], config: LoadedConfig) => {
},

async (t, file, files, hasReporter) => {
if (!_TAPJS_PROCESSINFO_COV_EXCLUDE_FILES_) {
_TAPJS_PROCESSINFO_COV_EXCLUDE_FILES_ = [
...covExcludeFiles.filter(f => typeof f === 'string'),
...files.map(f => resolve(config.globCwd, f)),
].join('\n')
}

/* c8 ignore start */
const stdio = hasReporter ? 'pipe' : 'inherit'
/* c8 ignore end */
Expand Down Expand Up @@ -152,6 +162,7 @@ export const run = async (args: string[], config: LoadedConfig) => {
...env,
_TAPJS_PROCESSINFO_COVERAGE_,
_TAPJS_PROCESSINFO_COV_FILES_,
_TAPJS_PROCESSINFO_COV_EXCLUDE_FILES_,
},
name,
cwd: config.globCwd,
Expand Down

0 comments on commit 1dcc6a7

Please sign in to comment.