aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-08-06 17:57:13 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-08-06 17:57:44 -0700
commit04925bb94c12a7c961bb758d2e2f3ecbe091fff0 (patch)
treebd14b819c1f0049daac4ef74d6bd15a4a3b5bac4
parent3185ca2d9599de18bbdd18069d411c1d775d1535 (diff)
downloadbun-04925bb94c12a7c961bb758d2e2f3ecbe091fff0.tar.gz
bun-04925bb94c12a7c961bb758d2e2f3ecbe091fff0.tar.zst
bun-04925bb94c12a7c961bb758d2e2f3ecbe091fff0.zip
Fixes #4020
-rw-r--r--src/bunfig.zig4
-rw-r--r--src/cli/test_command.zig3
2 files changed, 6 insertions, 1 deletions
diff --git a/src/bunfig.zig b/src/bunfig.zig
index e1f1ca4b0..050c603de 100644
--- a/src/bunfig.zig
+++ b/src/bunfig.zig
@@ -253,6 +253,7 @@ pub const Bunfig = struct {
this.ctx.test_options.coverage.fractions.functions = expr.data.e_number.value;
this.ctx.test_options.coverage.fractions.lines = expr.data.e_number.value;
this.ctx.test_options.coverage.fractions.stmts = expr.data.e_number.value;
+ this.ctx.test_options.coverage.fail_on_low_coverage = true;
break :outer;
}
@@ -260,16 +261,19 @@ pub const Bunfig = struct {
if (expr.get("functions")) |functions| {
try this.expect(functions, .e_number);
this.ctx.test_options.coverage.fractions.functions = functions.data.e_number.value;
+ this.ctx.test_options.coverage.fail_on_low_coverage = true;
}
if (expr.get("lines")) |lines| {
try this.expect(lines, .e_number);
this.ctx.test_options.coverage.fractions.lines = lines.data.e_number.value;
+ this.ctx.test_options.coverage.fail_on_low_coverage = true;
}
if (expr.get("statements")) |stmts| {
try this.expect(stmts, .e_number);
this.ctx.test_options.coverage.fractions.stmts = stmts.data.e_number.value;
+ this.ctx.test_options.coverage.fail_on_low_coverage = true;
}
}
diff --git a/src/cli/test_command.zig b/src/cli/test_command.zig
index c4d78f4d5..3a9411e08 100644
--- a/src/cli/test_command.zig
+++ b/src/cli/test_command.zig
@@ -557,6 +557,7 @@ pub const TestCommand = struct {
fractions: bun.sourcemap.CoverageFraction = .{},
ignore_sourcemap: bool = false,
enabled: bool = false,
+ fail_on_low_coverage: bool = false,
};
pub fn exec(ctx: Command.Context) !void {
@@ -842,7 +843,7 @@ pub const TestCommand = struct {
}
}
- if (reporter.summary.fail > 0 or (coverage.enabled and coverage.fractions.failing)) {
+ if (reporter.summary.fail > 0 or (coverage.enabled and coverage.fractions.failing and coverage.fail_on_low_coverage)) {
Global.exit(1);
}
}