Skip to content

Commit ffc04b4

Browse files
committed
Move coverage.mjs
1 parent cc6dd75 commit ffc04b4

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env zx --experimental
22

3-
cd(path.resolve(__dirname, '..'))
3+
const expected = 94
4+
cd(path.resolve(__dirname, '..', '..'))
45

56
await spinner('Running tests', async () => {
67
await $`go test -coverprofile=coverage.out -coverpkg=github.com/antonmedv/expr/... ./...`
@@ -12,4 +13,9 @@ await spinner('Running tests', async () => {
1213
await $`go tool cover -html=coverage.out -o coverage.html`
1314
})
1415

15-
await $`go tool cover -func=coverage.out`
16+
const cover = await $`go tool cover -func=coverage.out`
17+
const total = +cover.stdout.match(/total:\s+\(statements\)\s+(\d+\.\d+)%/)[1]
18+
if (total < expected) {
19+
echo(chalk.red(`Coverage is too low: ${total}% < ${expected}% (expected)`))
20+
process.exit(1)
21+
}

0 commit comments

Comments
 (0)