Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
478 commits
Select commit Hold shift + click to select a range
bf5585c
remove unused todo comment
pfgithub Sep 4, 2025
e4fb65c
describe n^2 problem and solution
pfgithub Sep 4, 2025
38898d8
remove unused jest fns part 1
pfgithub Sep 5, 2025
82cea86
removes TestRunnerTask
pfgithub Sep 5, 2025
dc33b71
removing more
pfgithub Sep 5, 2025
f0a2d4f
more
pfgithub Sep 5, 2025
424cdcf
remove more
pfgithub Sep 5, 2025
b8da8a8
diff command
pfgithub Sep 5, 2025
c0ef229
sequence init method
pfgithub Sep 5, 2025
c8f62a1
sequence things
pfgithub Sep 5, 2025
b9d3bc5
track remaining items in group
pfgithub Sep 5, 2025
afb92a8
notes
pfgithub Sep 5, 2025
6a36929
runOne/runOneCompleted -> .step() but the n² fix is not implemented yet
pfgithub Sep 5, 2025
a912fbe
todo fix
pfgithub Sep 5, 2025
d15c0c0
add printIfNeeded
pfgithub Sep 5, 2025
11bea1e
add done parameter for hooks
pfgithub Sep 5, 2025
3317e87
unhandledrejections change
pfgithub Sep 5, 2025
125961a
slight mess waiting for both promise and done
pfgithub Sep 5, 2025
208f513
progress
pfgithub Sep 5, 2025
c9984af
add back repeating the messages
pfgithub Sep 5, 2025
9ff129a
checklist
pfgithub Sep 5, 2025
2747c16
Merge remote-tracking branch 'origin/main' into pfg/describe-2
pfgithub Sep 5, 2025
0b305c9
group disable
pfgithub Sep 5, 2025
e09c9d2
todo
pfgithub Sep 6, 2025
7669030
note
pfgithub Sep 6, 2025
9485b38
renames BunTestFile->BunTest, BunTest->BunTestRoot
pfgithub Sep 6, 2025
52a2916
sort imports
pfgithub Sep 6, 2025
c8cea9e
changes_1
pfgithub Sep 6, 2025
b65890f
note
pfgithub Sep 6, 2025
3b5ad4b
vitest order note
pfgithub Sep 8, 2025
ac8dfb3
,
pfgithub Sep 8, 2025
9e4251c
remove n²
pfgithub Sep 8, 2025
86f4f1d
remove these todos
pfgithub Sep 8, 2025
c84b663
note
pfgithub Sep 8, 2025
4093069
wip
pfgithub Sep 8, 2025
1bed951
wip: failure-skip
pfgithub Sep 8, 2025
ac41670
modifies todo implementation
pfgithub Sep 8, 2025
5165564
modifies todo implementation again
pfgithub Sep 8, 2025
d2b20fa
wip
pfgithub Sep 8, 2025
4a6c007
failure-skip progress
pfgithub Sep 8, 2025
1980a6f
changes
pfgithub Sep 9, 2025
fd7d025
wip
pfgithub Sep 9, 2025
cadd729
reorder the todo list
pfgithub Sep 9, 2025
581ad0c
pass failure-skip
pfgithub Sep 9, 2025
94db5f5
Adds timeout to beforeAll
pfgithub Sep 9, 2025
984bc68
describe2 fixture
pfgithub Sep 9, 2025
26765ed
Merge remote-tracking branch 'origin/main' into pfg/describe-2
pfgithub Sep 9, 2025
12edf1e
fixes github ::error logging (it requires exceptions, not errors)
pfgithub Sep 9, 2025
2bf0111
updates timeout message to work with toFailWithTimeout
pfgithub Sep 9, 2025
41bedf8
update todo list
pfgithub Sep 9, 2025
d81ff53
reorganize todo_md
pfgithub Sep 9, 2025
86deaa6
update
pfgithub Sep 9, 2025
f49085f
wip
pfgithub Sep 9, 2025
4cc9825
oops
pfgithub Sep 9, 2025
1b91d84
remove more
pfgithub Sep 9, 2025
db31741
+
pfgithub Sep 9, 2025
bd4edff
todo
pfgithub Sep 9, 2025
d2dad0f
BunTest strong pointer / weak pointer
pfgithub Sep 10, 2025
a76d8a6
todo
pfgithub Sep 10, 2025
9879501
cross-file safety test
pfgithub Sep 10, 2025
3f05691
updates
pfgithub Sep 10, 2025
6c573b2
todo
pfgithub Sep 10, 2025
651d0ea
todo
pfgithub Sep 10, 2025
c646f7d
fix done missing call/apply
pfgithub Sep 10, 2025
712d0aa
updates 19850 to error once rather than twice
pfgithub Sep 10, 2025
7a5551b
update todo
pfgithub Sep 10, 2025
1b9d761
change so unhandled exceptions do not attribute to the current state …
pfgithub Sep 10, 2025
ffc62e3
some repros and todos
pfgithub Sep 10, 2025
e8d2e62
work around jsonwebtoken issue for claim-iss test
pfgithub Sep 10, 2025
d777ad5
fix 18159
pfgithub Sep 10, 2025
9f79d07
list of test failures to resolve
pfgithub Sep 10, 2025
c55d27c
update todo
pfgithub Sep 10, 2025
20f1bb3
update so only the first done() call reports errors
pfgithub Sep 10, 2025
4923e2d
revert change to 18159
pfgithub Sep 10, 2025
07acd63
revert change to claim-iss
pfgithub Sep 10, 2025
742c759
pass done-infinity (start the next test as soon as the previous one f…
pfgithub Sep 10, 2025
93ea08a
update todo
pfgithub Sep 10, 2025
b349599
capture line no.mber from the first function call rather than the last
pfgithub Sep 10, 2025
9732f01
more line no
pfgithub Sep 10, 2025
918a06b
more line no (for describes it was being set to '2')
pfgithub Sep 10, 2025
7427957
fix wrong cfg in use after line no change
pfgithub Sep 10, 2025
1a6aa46
adds line no to junit test
pfgithub Sep 10, 2025
7e68367
remove hostname from junit output
pfgithub Sep 10, 2025
a01fcf9
fixes line_no on raw `describe()`
pfgithub Sep 11, 2025
c8ac91c
callback handling stuff
pfgithub Sep 11, 2025
446e6be
updates checklist
pfgithub Sep 11, 2025
4acfa6a
fail_because_timeout github action error print
pfgithub Sep 11, 2025
3da5f2b
fix types
pfgithub Sep 11, 2025
07fb4f6
fix heap snapshot crash
pfgithub Sep 11, 2025
3e641cd
names for describe functions
pfgithub Sep 11, 2025
04ddcd7
pass ban-words
pfgithub Sep 11, 2025
bcd69ee
make sure a test that synchronously errors exits immediately even if …
pfgithub Sep 11, 2025
e4358f5
,,
pfgithub Sep 11, 2025
7dfaca1
todo
pfgithub Sep 11, 2025
0fa6ba9
update hooks now that we match order. still a bug remains.
pfgithub Sep 11, 2025
509b3a1
fix node-test.test.ts
pfgithub Sep 11, 2025
250c9ec
notes
pfgithub Sep 11, 2025
89ff1ac
fix write.spec.ts with fixed beforeAll execution order
pfgithub Sep 11, 2025
a4860c2
pfgithub Sep 11, 2025
a561065
fix filter names append order
pfgithub Sep 11, 2025
50a202e
pass test-filter-lifecycle-snapshot
pfgithub Sep 11, 2025
a0c2001
changes describe function argument parsing
pfgithub Sep 12, 2025
e168110
fixes process-nexttick.test.js
pfgithub Sep 12, 2025
3cc10f4
update test-test based on breaking change
pfgithub Sep 12, 2025
95768b5
allow null/undefined as explicit skipIf parameter, just disallow `.sk…
pfgithub Sep 12, 2025
f18a568
test-test updates
pfgithub Sep 12, 2025
648f0d0
add back auto_killer?
pfgithub Sep 12, 2025
a670f97
test-test passing (don't deactivate beforeAll/beforeEach hooks of an …
pfgithub Sep 12, 2025
28a355c
check off test-test
pfgithub Sep 12, 2025
5e520c2
rather than reportUncaughtExceptionFromError(throwValue(value)), use …
pfgithub Sep 12, 2025
9657179
elim unused EntryID
pfgithub Sep 12, 2025
1866b55
update '0' timeout to mean 'unlimited'
pfgithub Sep 12, 2025
d1b3403
fix linear_fifo
pfgithub Sep 12, 2025
a7a6b98
notes
pfgithub Sep 12, 2025
d3d9898
fixes bugs in shared & updates usage of shared ptr
pfgithub Sep 12, 2025
cbb99d0
pass bunshell.test.ts
pfgithub Sep 12, 2025
a3fb11a
update describe2fixture
pfgithub Sep 12, 2025
3b63d56
Merge remote-tracking branch 'origin/main' into pfg/describe-2
pfgithub Sep 12, 2025
1357442
issue
pfgithub Sep 13, 2025
4695474
move drain later to fix double-error
pfgithub Sep 13, 2025
a69da29
don't run auto_killer for beforeAll/afterAll
pfgithub Sep 13, 2025
d097ebd
done
pfgithub Sep 13, 2025
5fa3be2
wip
pfgithub Sep 13, 2025
c4604f0
[autofix.ci] apply automated fixes
autofix-ci[bot] Sep 13, 2025
eb3f628
todo
pfgithub Sep 13, 2025
e08c3b7
gc on group completion
pfgithub Sep 13, 2025
eb4c102
remove gc between tests
pfgithub Sep 13, 2025
0b20e0c
pass tcp-server
pfgithub Sep 13, 2025
b688625
todo:md
pfgithub Sep 13, 2025
bab9ab1
add 'killed (d) dangling processes)' message & some fixes
pfgithub Sep 15, 2025
945f2db
timeout upd
pfgithub Sep 15, 2025
4bd86cc
add timeout before calling test callback
pfgithub Sep 15, 2025
817eee7
test-timeout-behaviour
pfgithub Sep 15, 2025
68a0d8c
more
pfgithub Sep 15, 2025
e22f4e8
fixes timeout
pfgithub Sep 15, 2025
b8e0f87
adds `--concurrent` flag
pfgithub Sep 15, 2025
a690faa
08964
pfgithub Sep 15, 2025
2d96d4c
Merge remote-tracking branch 'origin/main' into pfg/describe-2
pfgithub Sep 15, 2025
6399998
describe2
pfgithub Sep 15, 2025
22b55b0
new list
pfgithub Sep 15, 2025
0279fdf
fix junit on windows
pfgithub Sep 15, 2025
02202e2
categorizing failures
pfgithub Sep 16, 2025
22a8de1
updates todo md
pfgithub Sep 16, 2025
fd565b1
,,
pfgithub Sep 16, 2025
4ecc818
updates serve test ts kill to not use afterAll inside tests
pfgithub Sep 17, 2025
76e48be
update todo
pfgithub Sep 17, 2025
d28a891
switches DoneCallback to be a bound function
pfgithub Sep 17, 2025
16e36e7
WIP: migrates ScopeFunctions to bind()
pfgithub Sep 17, 2025
716f4c4
customBasePrototype -> forBind
pfgithub Sep 17, 2025
f74d72e
2
pfgithub Sep 17, 2025
b5def17
TODO
pfgithub Sep 17, 2025
c3f25bd
complete ScopeFunctions to bind migration
pfgithub Sep 17, 2025
6f53bbf
remove addLineNoToCfg, update snapshot
pfgithub Sep 17, 2025
47d7d70
,,
pfgithub Sep 17, 2025
315111b
updates
pfgithub Sep 17, 2025
fde87ff
adds
pfgithub Sep 17, 2025
02131b9
updates
pfgithub Sep 17, 2025
6802235
updates
pfgithub Sep 17, 2025
7e12956
,,
pfgithub Sep 17, 2025
41cf84e
updates elysia tests
pfgithub Sep 17, 2025
9944beb
,
pfgithub Sep 17, 2025
9f391bc
BunTest init in-place and fixes allocator leak
pfgithub Sep 17, 2025
118653c
adds an arena
pfgithub Sep 17, 2025
0902743
removes done_promise
pfgithub Sep 17, 2025
a285326
removes runErrorHandlerWithDedupe, last_reported_error_for_dedupe
pfgithub Sep 17, 2025
0de1fd0
adds
pfgithub Sep 18, 2025
8bc1230
wip
pfgithub Sep 18, 2025
f8f44b7
,,
pfgithub Sep 18, 2025
0e01163
done
pfgithub Sep 18, 2025
0bec5da
Merge remote-tracking branch 'origin/main' into pfg/describe-2
pfgithub Sep 18, 2025
9b6dada
sol.n
pfgithub Sep 18, 2025
9130bb2
,
pfgithub Sep 18, 2025
eb6eb10
maybe fix stack?
pfgithub Sep 18, 2025
cda296b
[autofix.ci] apply automated fixes
autofix-ci[bot] Sep 18, 2025
b04284e
hooks inside node test
pfgithub Sep 18, 2025
7ef70ed
wip
pfgithub Sep 18, 2025
bdf13b4
12250 not fixed
pfgithub Sep 18, 2025
af81a4d
08768 fixed
pfgithub Sep 18, 2025
59e4313
14624 fixed
pfgithub Sep 18, 2025
2c36144
20100 is fixed
pfgithub Sep 18, 2025
5cb70d4
11793 fix
pfgithub Sep 18, 2025
747f0d6
20092 already fixed on main
pfgithub Sep 18, 2025
e5406ff
19875 fixed
pfgithub Sep 18, 2025
e407ade
14135 fixed
pfgithub Sep 18, 2025
bff384a
20980 fixed
pfgithub Sep 18, 2025
c7affbe
,
pfgithub Sep 18, 2025
b6fa40b
,
pfgithub Sep 18, 2025
bbbb532
21830 fixed
pfgithub Sep 18, 2025
e468d3f
5738
pfgithub Sep 19, 2025
2590488
19758 fixed
pfgithub Sep 19, 2025
06cadc5
5961 already fixed on main
pfgithub Sep 19, 2025
69c0d11
21177 already fixed on main
pfgithub Sep 19, 2025
2a96868
more 21177
pfgithub Sep 19, 2025
465c7fb
12782 fixed
pfgithub Sep 19, 2025
a7b9206
marks fixed
pfgithub Sep 19, 2025
4cf29c5
update elysia again
pfgithub Sep 19, 2025
2bb8103
build before running elysia tests
pfgithub Sep 19, 2025
427b92b
[autofix.ci] apply automated fixes
autofix-ci[bot] Sep 19, 2025
0b8a178
clean
pfgithub Sep 19, 2025
3162702
only print auto_killer in the timeout case
pfgithub Sep 19, 2025
f5e226c
only activate the auto_killer for timeouts
pfgithub Sep 19, 2025
9219f2f
order problem
pfgithub Sep 19, 2025
58aadc2
possible sol.n
pfgithub Sep 19, 2025
42833fb
fixes describe2
pfgithub Sep 19, 2025
15b9f9a
oops
pfgithub Sep 19, 2025
23aef9b
wip
pfgithub Sep 19, 2025
fb74283
fixes client-fetch
pfgithub Sep 19, 2025
a3ef0cd
,
pfgithub Sep 19, 2025
67f3bb1
wip
pfgithub Sep 19, 2025
fd63a6b
switch concurrent fixture to no longer use sleep
pfgithub Sep 19, 2025
f4b9811
[x]
pfgithub Sep 19, 2025
c342671
don't need to wait for a microtask, just a tick
pfgithub Sep 19, 2025
9b75517
r
pfgithub Sep 19, 2025
27a52ef
adds enable_fast_build flag
pfgithub Sep 19, 2025
be4752c
remove the gc(true), expectMaxObjectTypeCount should do that
pfgithub Sep 19, 2025
048bc04
elim instanceCallable
pfgithub Sep 19, 2025
047610f
work around error-code-done-callback
pfgithub Sep 19, 2025
acd958a
remove todos
pfgithub Sep 19, 2025
f9af4d6
disable the logs by default
pfgithub Sep 19, 2025
0762be4
unclear
pfgithub Sep 19, 2025
58f8779
,,
pfgithub Sep 19, 2025
8f62dd7
fix logic
pfgithub Sep 19, 2025
b35782b
fixes 'todo' color
pfgithub Sep 19, 2025
a862d79
mark complete
pfgithub Sep 19, 2025
04d4424
removes beforeAll from bun-install-registry - lots of code in here ru…
pfgithub Sep 19, 2025
633b7ba
Merge remote-tracking branch 'origin/main' into pfg/describe-2
pfgithub Sep 19, 2025
af30235
[autofix.ci] apply automated fixes
autofix-ci[bot] Sep 19, 2025
8fe648b
removes
pfgithub Sep 19, 2025
8de1a9e
more
pfgithub Sep 19, 2025
6821ab2
deletes todo md
pfgithub Sep 19, 2025
ba01520
tcp-server,socket
pfgithub Sep 19, 2025
d69c085
adds only-inside-only fix & support
pfgithub Sep 20, 2025
7351058
[autofix.ci] apply automated fixes
autofix-ci[bot] Sep 20, 2025
c5feb10
updates unreachable/reachable behaviour in bun-test.test.ts
pfgithub Sep 20, 2025
99b41b5
updates sql test to not use befdoreAll
pfgithub Sep 20, 2025
ed63b19
remove unused
pfgithub Sep 20, 2025
02430d7
renames describe2 to bun_test
pfgithub Sep 20, 2025
857f34f
pas bun_test
pfgithub Sep 20, 2025
8715a6a
fixes wants_loud
pfgithub Sep 20, 2025
a3b3328
upd
pfgithub Sep 20, 2025
8ed86eb
upd
pfgithub Sep 20, 2025
2ad7cdc
pass args to bind part 1
pfgithub Sep 20, 2025
08e26be
migrates to bind
pfgithub Sep 20, 2025
beb402a
upd
pfgithub Sep 20, 2025
e9c604e
fixes the memory leak
pfgithub Sep 20, 2025
3a89f78
renames safe strong to deprecated strong and deletes todo.md
pfgithub Sep 20, 2025
49c03ca
use active_scope from RefDataValue
pfgithub Sep 20, 2025
3b73ed3
fix the signature
pfgithub Sep 20, 2025
96cbfeb
increment object number
pfgithub Sep 20, 2025
785e123
remove start,end,last
pfgithub Sep 20, 2025
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
8 changes: 7 additions & 1 deletion build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -587,9 +587,15 @@ pub fn addBunObject(b: *Build, opts: *BunBuildOptions) *Compile {
.root_module = root,
});
configureObj(b, opts, obj);
if (enableFastBuild(b)) obj.root_module.strip = true;
return obj;
}

fn enableFastBuild(b: *Build) bool {
const val = b.graph.env_map.get("BUN_BUILD_FAST") orelse return false;
return std.mem.eql(u8, val, "1");
}

fn configureObj(b: *Build, opts: *BunBuildOptions, obj: *Compile) void {
// Flags on root module get used for the compilation
obj.root_module.omit_frame_pointer = false;
Expand All @@ -600,7 +606,7 @@ fn configureObj(b: *Build, opts: *BunBuildOptions, obj: *Compile) void {
// Object options
obj.use_llvm = !opts.no_llvm;
obj.use_lld = if (opts.os == .mac) false else !opts.no_llvm;
if (opts.enable_asan) {
if (opts.enable_asan and !enableFastBuild(b)) {
if (@hasField(Build.Module, "sanitize_address")) {
obj.root_module.sanitize_address = true;
} else {
Expand Down
176 changes: 70 additions & 106 deletions packages/bun-types/test.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,69 +206,54 @@ declare module "bun:test" {
*
* @category Testing
*/
export interface Describe {
export interface Describe<T extends Readonly<any[]>> {
(fn: () => void): void;

(label: DescribeLabel, fn: () => void): void;
(label: DescribeLabel, fn: (...args: T) => void): void;
/**
* Skips all other tests, except this group of tests.
*
* @param label the label for the tests
* @param fn the function that defines the tests
*/
only(label: DescribeLabel, fn: () => void): void;
only: Describe<T>;
/**
* Skips this group of tests.
*
* @param label the label for the tests
* @param fn the function that defines the tests
*/
skip(label: DescribeLabel, fn: () => void): void;
skip: Describe<T>;
/**
* Marks this group of tests as to be written or to be fixed.
*
* @param label the label for the tests
* @param fn the function that defines the tests
*/
todo(label: DescribeLabel, fn?: () => void): void;
todo: Describe<T>;
/**
* Marks this group of tests to be executed concurrently.
*/
concurrent: Describe<T>;
/**
* Runs this group of tests, only if `condition` is true.
*
* This is the opposite of `describe.skipIf()`.
*
* @param condition if these tests should run
*/
if(condition: boolean): (label: DescribeLabel, fn: () => void) => void;
if(condition: boolean): Describe<T>;
/**
* Skips this group of tests, if `condition` is true.
*
* @param condition if these tests should be skipped
*/
skipIf(condition: boolean): (label: DescribeLabel, fn: () => void) => void;
skipIf(condition: boolean): Describe<T>;
/**
* Marks this group of tests as to be written or to be fixed, if `condition` is true.
*
* @param condition if these tests should be skipped
*/
todoIf(condition: boolean): (label: DescribeLabel, fn: () => void) => void;
todoIf(condition: boolean): Describe<T>;
/**
* Returns a function that runs for each item in `table`.
*
* @param table Array of Arrays with the arguments that are passed into the test fn for each row.
*/
each<T extends Readonly<[any, ...any[]]>>(
table: readonly T[],
): (label: DescribeLabel, fn: (...args: [...T]) => void | Promise<unknown>, options?: number | TestOptions) => void;
each<T extends any[]>(
table: readonly T[],
): (
label: DescribeLabel,
fn: (...args: Readonly<T>) => void | Promise<unknown>,
options?: number | TestOptions,
) => void;
each<T>(
table: T[],
): (label: DescribeLabel, fn: (...args: T[]) => void | Promise<unknown>, options?: number | TestOptions) => void;
each<T extends Readonly<[any, ...any[]]>>(table: readonly T[]): Describe<[...T]>;
each<T extends any[]>(table: readonly T[]): Describe<[...T]>;
each<T>(table: T[]): Describe<[T]>;
}
/**
* Describes a group of related tests.
Expand All @@ -286,7 +271,7 @@ declare module "bun:test" {
* @param label the label for the tests
* @param fn the function that defines the tests
*/
export const describe: Describe;
export const describe: Describe<[]>;
/**
* Skips a group of related tests.
*
Expand All @@ -295,7 +280,9 @@ declare module "bun:test" {
* @param label the label for the tests
* @param fn the function that defines the tests
*/
export const xdescribe: Describe;
export const xdescribe: Describe<[]>;

type HookOptions = number | { timeout?: number };
/**
* Runs a function, once, before all the tests.
*
Expand All @@ -312,7 +299,10 @@ declare module "bun:test" {
*
* @param fn the function to run
*/
export function beforeAll(fn: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void)): void;
export function beforeAll(
fn: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void),
options?: HookOptions,
): void;
/**
* Runs a function before each test.
*
Expand All @@ -323,7 +313,10 @@ declare module "bun:test" {
*
* @param fn the function to run
*/
export function beforeEach(fn: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void)): void;
export function beforeEach(
fn: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void),
options?: HookOptions,
): void;
/**
* Runs a function, once, after all the tests.
*
Expand All @@ -340,7 +333,10 @@ declare module "bun:test" {
*
* @param fn the function to run
*/
export function afterAll(fn: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void)): void;
export function afterAll(
fn: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void),
options?: HookOptions,
): void;
/**
* Runs a function after each test.
*
Expand All @@ -349,7 +345,10 @@ declare module "bun:test" {
*
* @param fn the function to run
*/
export function afterEach(fn: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void)): void;
export function afterEach(
fn: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void),
options?: HookOptions,
): void;
/**
* Sets the default timeout for all tests in the current file. If a test specifies a timeout, it will
* override this value. The default timeout is 5000ms (5 seconds).
Expand Down Expand Up @@ -382,6 +381,11 @@ declare module "bun:test" {
*/
repeats?: number;
}
type IsTuple<T> = T extends readonly unknown[]
? number extends T["length"]
? false // It's an array with unknown length, not a tuple
: true // It's an array with a fixed length (a tuple)
: false; // Not an array at all
/**
* Runs a test.
*
Expand All @@ -405,10 +409,10 @@ declare module "bun:test" {
*
* @category Testing
*/
export interface Test {
export interface Test<T extends Readonly<any[]>> {
(
label: string,
fn: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void),
fn: (...args: IsTuple<T> extends true ? [...T, (err?: unknown) => void] : T) => void | Promise<unknown>,
/**
* - If a `number`, sets the timeout for the test in milliseconds.
* - If an `object`, sets the options for the test.
Expand All @@ -420,45 +424,21 @@ declare module "bun:test" {
): void;
/**
* Skips all other tests, except this test when run with the `--only` option.
*
* @param label the label for the test
* @param fn the test function
* @param options the test timeout or options
*/
only(
label: string,
fn: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void),
options?: number | TestOptions,
): void;
only: Test<T>;
/**
* Skips this test.
*
* @param label the label for the test
* @param fn the test function
* @param options the test timeout or options
*/
skip(
label: string,
fn: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void),
options?: number | TestOptions,
): void;
skip: Test<T>;
/**
* Marks this test as to be written or to be fixed.
*
* These tests will not be executed unless the `--todo` flag is passed. With the flag,
* if the test passes, the test will be marked as `fail` in the results; you will have to
* remove the `.todo` or check that your test
* is implemented correctly.
*
* @param label the label for the test
* @param fn the test function
* @param options the test timeout or options
*/
todo(
label: string,
fn?: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void),
options?: number | TestOptions,
): void;
todo: Test<T>;
/**
* Marks this test as failing.
*
Expand All @@ -469,68 +449,52 @@ declare module "bun:test" {
*
* `test.failing` is very similar to {@link test.todo} except that it always
* runs, regardless of the `--todo` flag.
*
* @param label the label for the test
* @param fn the test function
* @param options the test timeout or options
*/
failing(
label: string,
fn?: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void),
options?: number | TestOptions,
): void;
failing: Test<T>;
/**
* Runs the test concurrently with other concurrent tests.
*/
concurrent: Test<T>;
/**
* Runs this test, if `condition` is true.
*
* This is the opposite of `test.skipIf()`.
*
* @param condition if the test should run
*/
if(
condition: boolean,
): (
label: string,
fn: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void),
options?: number | TestOptions,
) => void;
if(condition: boolean): Test<T>;
/**
* Skips this test, if `condition` is true.
*
* @param condition if the test should be skipped
*/
skipIf(
condition: boolean,
): (
label: string,
fn: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void),
options?: number | TestOptions,
) => void;
skipIf(condition: boolean): Test<T>;
/**
* Marks this test as to be written or to be fixed, if `condition` is true.
*
* @param condition if the test should be marked TODO
*/
todoIf(
condition: boolean,
): (
label: string,
fn: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void),
options?: number | TestOptions,
) => void;
todoIf(condition: boolean): Test<T>;
/**
* Marks this test as failing, if `condition` is true.
*
* @param condition if the test should be marked as failing
*/
failingIf(condition: boolean): Test<T>;
/**
* Runs the test concurrently with other concurrent tests, if `condition` is true.
*
* @param condition if the test should run concurrently
*/
concurrentIf(condition: boolean): Test<T>;
/**
* Returns a function that runs for each item in `table`.
*
* @param table Array of Arrays with the arguments that are passed into the test fn for each row.
*/
each<T extends Readonly<[any, ...any[]]>>(
table: readonly T[],
): (label: string, fn: (...args: [...T]) => void | Promise<unknown>, options?: number | TestOptions) => void;
each<T extends any[]>(
table: readonly T[],
): (label: string, fn: (...args: Readonly<T>) => void | Promise<unknown>, options?: number | TestOptions) => void;
each<T>(
table: T[],
): (label: string, fn: (...args: T[]) => void | Promise<unknown>, options?: number | TestOptions) => void;
each<T extends Readonly<[any, ...any[]]>>(table: readonly T[]): Test<[...T]>;
each<T extends any[]>(table: readonly T[]): Test<[...T]>;
each<T>(table: T[]): Test<[T]>;
}
/**
* Runs a test.
Expand All @@ -548,7 +512,7 @@ declare module "bun:test" {
* @param label the label for the test
* @param fn the test function
*/
export const test: Test;
export const test: Test<[]>;
export { test as it, xtest as xit };

/**
Expand All @@ -559,7 +523,7 @@ declare module "bun:test" {
* @param label the label for the test
* @param fn the test function
*/
export const xtest: Test;
export const xtest: Test<[]>;

/**
* Asserts that a value matches some criteria.
Expand Down
9 changes: 9 additions & 0 deletions scripts/runner.node.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,15 @@ async function runTests() {
throw new Error(`Unsupported package manager: ${packageManager}`);
}

// build
const buildResult = await spawnBun(execPath, {
cwd: vendorPath,
args: ["run", "build"],
});
if (!buildResult.ok) {
throw new Error(`Failed to build vendor: ${buildResult.error}`);
}

for (const testPath of testPaths) {
const title = join(relative(cwd, vendorPath), testPath).replace(/\\/g, "/");

Expand Down
4 changes: 2 additions & 2 deletions src/allocators/allocation_scope.zig
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,10 @@ const State = struct {
self.history.unlock();
}

fn deinit(self: *Self) void {
pub fn deinit(self: *Self) void {
defer self.* = undefined;
var history = self.history.intoUnprotected();
defer history.deinit();
defer history.deinit(self.parent);

const count = history.allocations.count();
if (count == 0) return;
Expand Down
1 change: 1 addition & 0 deletions src/bun.js/Debugger.zig
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ pub const TestReporterAgent = struct {
handle: ?*Handle = null,
const debug = Output.scoped(.TestReporterAgent, .visible);

/// this enum is kept in sync with c++ InspectorTestReporterAgent.cpp `enum class BunTestStatus`
pub const TestStatus = enum(u8) {
pass,
fail,
Expand Down
Loading