Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/build/deps/webkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* for local mode. Override via `--webkit-version=<hash>` to test a branch.
* From https://github.com/oven-sh/WebKit releases.
*/
export const WEBKIT_VERSION = "274ebb3cf6008f627197d818e3939d1e2bfc514d";
export const WEBKIT_VERSION = "autobuild-preview-pr-851-b880fb21";
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
Comment thread
dylan-conway marked this conversation as resolved.
Resolved

/**
* WebKit (JavaScriptCore) — the JS engine.
Expand Down
49 changes: 49 additions & 0 deletions test/cli/test/coverage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,55 @@ test("only imports the function", () => {
expect(exitCode).toBe(0);
});

test("what is after an await at the top level of a module that throws did not run", async () => {
using dir = tempDir("cov-top-level-await", {
"subject.ts": `let ran = 0;
export const first = await 1;
ran++;
try {
await Promise.reject(new Error());
ran++;
} catch {
ran++;
}
export default await ran;
export { ran };
`,
"subject.test.ts": `
import { expect, test } from "bun:test";
import ran from "./subject.ts";
test("ran", () => {
expect(ran).toBe(2);
});
`,
});
await using proc = Bun.spawn({
cmd: [bunExe(), "test", "--coverage", "--coverage-reporter=lcov"],
env: bunEnv,
cwd: String(dir),
stderr: "pipe",
});
const [stderr, exitCode] = await Promise.all([proc.stderr.text(), proc.exited]);

const lcov = readFileSync(path.join(String(dir), "coverage", "lcov.info"), "utf-8");
const record = lcov.split("end_of_record").find(r => r.includes("SF:subject.ts"));
expect(record?.match(/^DA:.*$/gm)).toEqual([
"DA:1,1",
"DA:2,1",
"DA:3,1",
"DA:4,1",
"DA:5,1",
"DA:6,0",
"DA:7,1",
"DA:8,1",
"DA:10,1",
"DA:11,1",
]);
expect(stderr).toContain(" 1 pass");
expect(exitCode).toBe(0);
});

// https://github.com/oven-sh/bun/issues/40586
// Each worker executes a different function of the same module; the merged
// report must count a function as covered if any worker ran it.
Expand Down
91 changes: 91 additions & 0 deletions test/js/bun/sourcemap/source-positions-corpus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,97 @@ export const cases: Record<string, Case> = {
`,
},
// What is a function to the engine alone: not one of the file's functions, and not run until it is.
// What is after a statement that the function was left at, and did not come back to.
"suspended.ts": {
functions: "4/4",
lines: `
2|function* generator() {
2| at();
2| yield 1;
1| at();
1| yield 2;
0| at();
-|}
1|const resumed = generator();
1|resumed.next();
1|resumed.next();
1|generator().next();
1|async function stuck() {
1| at();
1| await new Promise(() => {});
0| at();
-|}
1|stuck();
1|async function rejected() {
1| try {
1| await Promise.reject(new Error());
0| at();
1| } catch {
1| at();
-| }
1| at();
-|}
1|rejected();
`,
},
// What `?.`, a logical assignment and a value that is there skip.
"skipped.ts": {
functions: "8/8",
lines: `
4|function one() {
4| at();
4| return 1;
-|}
2|function chain(o?: { a(n: number): void }) {
2| o
1| ?.a(
1| one(),
1| );
-|}
1|chain();
1|chain({ a() {} });
2|function call(f?: (n: number) => void) {
2| f
-| ?.(
1| one(),
1| );
-|}
1|call();
1|call(() => {});
2|function assign(o: Record<string, number | null>) {
2| o.a ||=
1| one();
2| o.b &&=
0| one();
2| o.c ??=
0| one();
-|}
1|assign({ a: 1, b: 0, c: 0 });
1|assign({ a: 0, b: 0, c: 0 });
2|function parameter(
2| v =
1| one(),
-|) {
2| at();
-|}
1|parameter();
1|parameter(1);
1|function pattern({
1| v =
0| one(),
-|}: { v?: number }) {
1| at();
-|}
1|pattern({ v: 1 });
1|let node: any = { next: { next: {} } };
3|while (node?.next) {
2| node = node.next;
-|}
1|switch (2 as number) {
0| case node?.next: at();
-|}
`,
},
"engine-functions.ts": {
functions: "5/6",
lines: `
Expand Down
Loading