mirror of
https://github.com/oven-sh/bun
synced 2026-02-16 22:01:47 +00:00
node test: run bun:test tests with bun test
This commit is contained in:
@@ -256,7 +256,8 @@ async function runTests() {
|
||||
const absoluteTestPath = join(testsPath, testPath);
|
||||
const title = relative(cwd, absoluteTestPath).replaceAll(sep, "/");
|
||||
if (isNodeParallelTest(testPath)) {
|
||||
const subcommand = title.includes("needs-test") ? "test" : "run";
|
||||
const runWithBunTest = title.includes("needs-test") || readFileSync(absoluteTestPath, "utf-8").includes('bun:test');
|
||||
const subcommand = runWithBunTest ? "test" : "run";
|
||||
await runTest(title, async () => {
|
||||
const { ok, error, stdout } = await spawnBun(execPath, {
|
||||
cwd: cwd,
|
||||
|
||||
@@ -5519,6 +5519,7 @@ pub const NodeFS = struct {
|
||||
// We cannot use removefileat() on macOS because it does not handle write-protected files as expected.
|
||||
if (args.recursive) {
|
||||
zigDeleteTree(std.fs.cwd(), args.path.slice(), .file) catch |err| {
|
||||
bun.handleErrorReturnTrace(err, @errorReturnTrace());
|
||||
const errno: E = switch (@as(anyerror, err)) {
|
||||
// error.InvalidHandle => .BADF,
|
||||
error.AccessDenied => .ACCES,
|
||||
@@ -5563,14 +5564,16 @@ pub const NodeFS = struct {
|
||||
|
||||
const dest = args.path.sliceZ(&this.sync_error_buf);
|
||||
|
||||
std.posix.unlinkZ(dest) catch |er| {
|
||||
std.posix.unlinkZ(dest) catch |err1| {
|
||||
bun.handleErrorReturnTrace(err1, @errorReturnTrace());
|
||||
// empircally, it seems to return AccessDenied when the
|
||||
// file is actually a directory on macOS.
|
||||
if (args.recursive and
|
||||
(er == error.IsDir or er == error.NotDir or er == error.AccessDenied))
|
||||
(err1 == error.IsDir or err1 == error.NotDir or err1 == error.AccessDenied))
|
||||
{
|
||||
std.posix.rmdirZ(dest) catch |err| {
|
||||
const code: E = switch (err) {
|
||||
std.posix.rmdirZ(dest) catch |err2| {
|
||||
bun.handleErrorReturnTrace(err2, @errorReturnTrace());
|
||||
const code: E = switch (err2) {
|
||||
error.AccessDenied => .ACCES,
|
||||
error.SymLinkLoop => .LOOP,
|
||||
error.NameTooLong => .NAMETOOLONG,
|
||||
@@ -5598,7 +5601,7 @@ pub const NodeFS = struct {
|
||||
}
|
||||
|
||||
{
|
||||
const code: E = switch (er) {
|
||||
const code: E = switch (err1) {
|
||||
error.AccessDenied => .ACCES,
|
||||
error.SymLinkLoop => .LOOP,
|
||||
error.NameTooLong => .NAMETOOLONG,
|
||||
|
||||
@@ -463,7 +463,7 @@ describe("ENOENT", () => {
|
||||
await Bun.write(file, "contents", ...opts);
|
||||
expect(fs.existsSync(file)).toBe(true);
|
||||
} finally {
|
||||
fs.rmSync(dir, { force: true });
|
||||
fs.rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -483,7 +483,7 @@ describe("ENOENT", () => {
|
||||
);
|
||||
expect(fs.existsSync(file)).toBe(false);
|
||||
} finally {
|
||||
fs.rmSync(dir, { force: true });
|
||||
fs.rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user