aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Ashcon Partovi <ashcon@partovi.net> 2023-05-01 09:01:41 -0700
committerGravatar Ashcon Partovi <ashcon@partovi.net> 2023-05-01 09:01:41 -0700
commitc19c522744ca4fb21ad212bea7905d058c8640ef (patch)
tree8ab9ced1481359836955533dc2d8715ad8e0dea8
parent1fc86391775bfd0b267d958bbbf2f7ce5e4d6952 (diff)
downloadbun-c19c522744ca4fb21ad212bea7905d058c8640ef.tar.gz
bun-c19c522744ca4fb21ad212bea7905d058c8640ef.tar.zst
bun-c19c522744ca4fb21ad212bea7905d058c8640ef.zip
Fix error links in markdown summary
-rw-r--r--.github/scripts/test-runner.ts17
1 files changed, 9 insertions, 8 deletions
diff --git a/.github/scripts/test-runner.ts b/.github/scripts/test-runner.ts
index 946e2315b..cd049e822 100644
--- a/.github/scripts/test-runner.ts
+++ b/.github/scripts/test-runner.ts
@@ -1,6 +1,8 @@
-// Dear reader
+// This file parses the output of `bun test` and outputs
+// a markdown summary and Github Action annotations.
//
-// The existence of this file is temporary, a hack.
+// In the future, a version of this will be built-in to Bun.
+
import { join, basename } from "node:path";
import { readdirSync, writeSync, fsyncSync, appendFileSync } from "node:fs";
import { spawn, spawnSync } from "node:child_process";
@@ -557,18 +559,17 @@ function formatTest(result: ParseTestResult, options?: FormatTestOptions): strin
...tests
.filter(({ status }) => status === "fail")
.map(({ name, errors }) => {
- let content = header(3, name);
- let hasLink = false;
+ let url = "";
+ let content = "";
if (errors) {
content += errors
.map(({ name, message, stack }) => {
let preview = code(`${name}: ${message}`, "diff");
if (stack?.length && baseUrl) {
const { file, line } = stack[0];
- if (!is3rdParty(file) && !hasLink) {
+ if (!is3rdParty(file) && !url) {
const { href } = new URL(`${file}?plain=1#L${line}`, baseUrl);
- content = link(content, href);
- hasLink = true;
+ url = href;
}
}
return preview;
@@ -577,7 +578,7 @@ function formatTest(result: ParseTestResult, options?: FormatTestOptions): strin
} else {
content += code("See logs for details");
}
- return content;
+ return `${header(3, link(name, url))}\n${content}`;
}),
];
})