From 4749449bb08064862b02f1dc6d7c4e7da20ad8ab Mon Sep 17 00:00:00 2001 From: Zack Radisic <56137411+zackradisic@users.noreply.github.com> Date: Mon, 25 Dec 2023 23:38:23 +0300 Subject: [PATCH] fix bugz --- src/bun.js/api/glob.zig | 10 ++++++++-- src/cli/test_command.zig | 13 ++++++++----- test/cli/test/bun-test.test.ts | 2 +- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/bun.js/api/glob.zig b/src/bun.js/api/glob.zig index 2f9fd6a523..0ddaac9782 100644 --- a/src/bun.js/api/glob.zig +++ b/src/bun.js/api/glob.zig @@ -268,6 +268,7 @@ pub const WalkTask = struct { fn deinit(this: *WalkTask) void { this.walker.deinit(true); + this.alloc.destroy(this.walker); this.alloc.destroy(this); } }; @@ -306,7 +307,9 @@ fn makeGlobWalker( return null; }; - globWalker.* = .{}; + globWalker.* = .{ + .allocator = alloc, + }; switch (globWalker.initWithCwd( arena, @@ -334,7 +337,9 @@ fn makeGlobWalker( return null; }; - globWalker.* = .{}; + globWalker.* = .{ + .allocator = alloc, + }; switch (globWalker.init( arena, this.pattern, @@ -463,6 +468,7 @@ pub fn __scanSync(this: *Glob, globalThis: *JSGlobalObject, callframe: *JSC.Call arena.deinit(); return .undefined; }; + defer alloc.destroy(globWalker); defer globWalker.deinit(true); switch (globWalker.walk() catch { diff --git a/src/cli/test_command.zig b/src/cli/test_command.zig index 8def31c876..454fe77370 100644 --- a/src/cli/test_command.zig +++ b/src/cli/test_command.zig @@ -742,9 +742,13 @@ pub const TestCommand = struct { if (ctx.test_options.include) |include_glob_pattern| { const glob = @import("../glob.zig"); const GlobWalker = glob.GlobWalker_(glob.ignoreNodeModules, true); - var glob_walker = bun.new(GlobWalker, .{}); - var arena = std.heap.ArenaAllocator.init(bun.default_allocator); - errdefer arena.deinit(); + var glob_walker = ctx.allocator.create(GlobWalker) catch bun.outOfMemory(); + glob_walker.* = .{ + .allocator = ctx.allocator, + }; + defer ctx.allocator.destroy(glob_walker); + var arena = std.heap.ArenaAllocator.init(ctx.allocator); + defer arena.deinit(); const result = brk: { const dot: bool = false; @@ -773,13 +777,12 @@ pub const TestCommand = struct { }; break :brk glob_walker.initWithCwd(&arena, include_glob_pattern, cwd, dot, absolute, follow_symlinks, error_on_broken_symlinks, only_files) catch { - arena.deinit(); return; }; }; _ = try result.unwrap(); - defer glob_walker.deinit(true); + defer glob_walker.deinit(false); var iter = GlobWalker.Iterator{ .walker = glob_walker }; defer iter.deinit(); diff --git a/test/cli/test/bun-test.test.ts b/test/cli/test/bun-test.test.ts index f5995500d0..3c09ddcc81 100644 --- a/test/cli/test/bun-test.test.ts +++ b/test/cli/test/bun-test.test.ts @@ -6,7 +6,7 @@ import { describe, test, expect } from "bun:test"; import { bunExe, bunEnv } from "harness"; describe("bun test", () => { - test("glob include", () => { + test("bun test include", () => { const cwd = createTest([ { filename: "hello.lol.js",