-
Notifications
You must be signed in to change notification settings - Fork 2
fix: throw error when benchmarks fail instead of silently dropping results #45
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,13 +10,15 @@ import { | |
| } from "@vitest/runner"; | ||
| import Debug from "debug"; | ||
| import {Benchmark, BenchmarkOpts, BenchmarkResults} from "../types.ts"; | ||
| import {consoleError} from "../utils/output.ts"; | ||
| import {store} from "./globalState.ts"; | ||
| import {BenchmarkReporter} from "./reporter.ts"; | ||
|
|
||
| const debug = Debug("@chainsafe/benchmark/runner"); | ||
|
|
||
| export class BenchmarkRunner implements VitestRunner { | ||
| readonly triggerGC: boolean; | ||
| failedCount = 0; | ||
| readonly config: VitestRunnerConfig; | ||
| readonly reporter: BenchmarkReporter; | ||
| readonly prevBench: Benchmark | null; | ||
|
|
@@ -98,10 +100,20 @@ export class BenchmarkRunner implements VitestRunner { | |
|
|
||
| debug("finished tests. passed: %i, skipped: %i, failed: %i", passed.length, skipped.length, failed.length); | ||
|
|
||
| if (passed.length + skipped.length + failed.length === res.length) { | ||
| return store.getAllResults(); | ||
| if (passed.length + skipped.length + failed.length !== res.length) { | ||
| throw new Error("Some tests returned with unknown state"); | ||
| } | ||
|
|
||
| throw new Error("Some tests cause returned with unknown state"); | ||
| if (failed.length > 0) { | ||
| this.failedCount = failed.length; | ||
| consoleError(`${failed.length} benchmark(s) failed:\n`); | ||
| for (const f of failed) { | ||
| const error = f.result?.errors?.[0]; | ||
| const errorMsg = error?.message ?? error?.toString() ?? "unknown error"; | ||
| consoleError(` ✖ ${f.name}: ${errorMsg}`); | ||
| } | ||
| } | ||
|
Comment on lines
+103
to
+115
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lodekeeper The diagnosis of the issue is fine but solution is a bit hacky. The runner pipeline expects Better approach would be either:
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point — throwing from Option 2 (consolidated pass/fail result set) would be the more complete approach long-term, but would require extending
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated the approach based on your feedback — now:
This way passed benchmarks still get persisted/compared, and CI still fails on errors. |
||
|
|
||
| return store.getAllResults(); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.