[bun:test] Implement test.root configuration option

This commit is contained in:
Jarred Sumner
2023-01-09 08:28:37 -08:00
parent ca58556c54
commit 30b10d5fb1
3 changed files with 21 additions and 0 deletions

11
bunfig.toml Normal file
View File

@@ -0,0 +1,11 @@
[test]
# Large monorepos (like Bun) may want to specify the test directory more specifically
# By default, `bun wiptest` scans every single folder recurisvely which, if you
# have a gigantic submodule (like WebKit), it has to do lots of directory
# traversals
#
# Instead, we can just make it scan only the test directory for Bun's runtime tests
root = "test/bun.js"

View File

@@ -191,6 +191,14 @@ pub const Bunfig = struct {
}
}
if (comptime cmd == .TestCommand) {
if (json.get("test")) |test_| {
if (test_.get("root")) |root| {
this.ctx.debug.test_directory = root.asString(this.allocator) orelse "";
}
}
}
if (comptime cmd.isNPMRelated() or cmd == .RunCommand or cmd == .AutoCommand) {
if (json.get("install")) |_bun| {
var install: *Api.BunInstall = this.ctx.install orelse brk: {

View File

@@ -838,6 +838,8 @@ pub const Command = struct {
macros: ?MacroMap = null,
editor: string = "",
package_bundle_map: bun.StringArrayHashMapUnmanaged(options.BundlePackage) = bun.StringArrayHashMapUnmanaged(options.BundlePackage){},
test_directory: []const u8 = "",
};
pub const Context = struct {