| author | |
| committer | |
| log | ebdbbd20ace6e93b581b90075f52946b3832da93 |
| tree | 09fb393f4a4578512ddf4906c7df14df5f6f9255 |
| parent | 3725f72293c87a73e0c11e74739574c7b78bb53d |
16 files changed, 102 insertions(+), 97 deletions(-)
lib/compiler/reduce.zig+8-8| ... | @@ -92,9 +92,7 @@ pub fn main() !void { | ... | @@ -92,9 +92,7 @@ pub fn main() !void { |
| 92 | if (i >= args.len) fatal("expected 32-bit integer after {s}", .{arg}); | 92 | if (i >= args.len) fatal("expected 32-bit integer after {s}", .{arg}); |
| 93 | const next_arg = args[i]; | 93 | const next_arg = args[i]; |
| 94 | seed = std.fmt.parseUnsigned(u32, next_arg, 0) catch |err| { | 94 | seed = std.fmt.parseUnsigned(u32, next_arg, 0) catch |err| { |
| 95 | fatal("unable to parse seed '{s}' as 32-bit integer: {s}", .{ | 95 | fatal("unable to parse seed '{s}' as 32-bit integer: {t}", .{ next_arg, err }); |
| 96 | next_arg, @errorName(err), | ||
| 97 | }); | ||
| 98 | }; | 96 | }; |
| 99 | } else { | 97 | } else { |
| 100 | fatal("unrecognized parameter: '{s}'", .{arg}); | 98 | fatal("unrecognized parameter: '{s}'", .{arg}); |
| ... | @@ -125,7 +123,7 @@ pub fn main() !void { | ... | @@ -125,7 +123,7 @@ pub fn main() !void { |
| 125 | var astgen_input: std.Io.Writer.Allocating = .init(gpa); | 123 | var astgen_input: std.Io.Writer.Allocating = .init(gpa); |
| 126 | defer astgen_input.deinit(); | 124 | defer astgen_input.deinit(); |
| 127 | 125 | ||
| 128 | var tree = try parse(gpa, root_source_file_path); | 126 | var tree = try parse(gpa, io, root_source_file_path); |
| 129 | defer { | 127 | defer { |
| 130 | gpa.free(tree.source); | 128 | gpa.free(tree.source); |
| 131 | tree.deinit(gpa); | 129 | tree.deinit(gpa); |
| ... | @@ -190,7 +188,7 @@ pub fn main() !void { | ... | @@ -190,7 +188,7 @@ pub fn main() !void { |
| 190 | std.debug.print("{s} ", .{@tagName(t)}); | 188 | std.debug.print("{s} ", .{@tagName(t)}); |
| 191 | } | 189 | } |
| 192 | std.debug.print("\n", .{}); | 190 | std.debug.print("\n", .{}); |
| 193 | try transformationsToFixups(gpa, arena, root_source_file_path, this_set, &fixups); | 191 | try transformationsToFixups(gpa, arena, io, root_source_file_path, this_set, &fixups); |
| 194 | 192 | ||
| 195 | rendered.clearRetainingCapacity(); | 193 | rendered.clearRetainingCapacity(); |
| 196 | try tree.render(gpa, &rendered.writer, fixups); | 194 | try tree.render(gpa, &rendered.writer, fixups); |
| ... | @@ -246,7 +244,7 @@ pub fn main() !void { | ... | @@ -246,7 +244,7 @@ pub fn main() !void { |
| 246 | }); | 244 | }); |
| 247 | switch (interestingness) { | 245 | switch (interestingness) { |
| 248 | .interesting => { | 246 | .interesting => { |
| 249 | const new_tree = try parse(gpa, root_source_file_path); | 247 | const new_tree = try parse(gpa, io, root_source_file_path); |
| 250 | gpa.free(tree.source); | 248 | gpa.free(tree.source); |
| 251 | tree.deinit(gpa); | 249 | tree.deinit(gpa); |
| 252 | tree = new_tree; | 250 | tree = new_tree; |
| ... | @@ -317,6 +315,7 @@ fn runCheck(arena: Allocator, io: Io, argv: []const []const u8) !Interestingness | ... | @@ -317,6 +315,7 @@ fn runCheck(arena: Allocator, io: Io, argv: []const []const u8) !Interestingness |
| 317 | fn transformationsToFixups( | 315 | fn transformationsToFixups( |
| 318 | gpa: Allocator, | 316 | gpa: Allocator, |
| 319 | arena: Allocator, | 317 | arena: Allocator, |
| 318 | io: Io, | ||
| 320 | root_source_file_path: []const u8, | 319 | root_source_file_path: []const u8, |
| 321 | transforms: []const Walk.Transformation, | 320 | transforms: []const Walk.Transformation, |
| 322 | fixups: *Ast.Render.Fixups, | 321 | fixups: *Ast.Render.Fixups, |
| ... | @@ -354,7 +353,7 @@ fn transformationsToFixups( | ... | @@ -354,7 +353,7 @@ fn transformationsToFixups( |
| 354 | inline_imported_file.imported_string, | 353 | inline_imported_file.imported_string, |
| 355 | }); | 354 | }); |
| 356 | defer gpa.free(full_imported_path); | 355 | defer gpa.free(full_imported_path); |
| 357 | var other_file_ast = try parse(gpa, full_imported_path); | 356 | var other_file_ast = try parse(gpa, io, full_imported_path); |
| 358 | defer { | 357 | defer { |
| 359 | gpa.free(other_file_ast.source); | 358 | gpa.free(other_file_ast.source); |
| 360 | other_file_ast.deinit(gpa); | 359 | other_file_ast.deinit(gpa); |
| ... | @@ -398,8 +397,9 @@ fn transformationsToFixups( | ... | @@ -398,8 +397,9 @@ fn transformationsToFixups( |
| 398 | }; | 397 | }; |
| 399 | } | 398 | } |
| 400 | 399 | ||
| 401 | fn parse(gpa: Allocator, file_path: []const u8) !Ast { | 400 | fn parse(gpa: Allocator, io: Io, file_path: []const u8) !Ast { |
| 402 | const source_code = Io.Dir.cwd().readFileAllocOptions( | 401 | const source_code = Io.Dir.cwd().readFileAllocOptions( |
| 402 | io, | ||
| 403 | file_path, | 403 | file_path, |
| 404 | gpa, | 404 | gpa, |
| 405 | .limited(std.math.maxInt(u32)), | 405 | .limited(std.math.maxInt(u32)), |
lib/std/Build/Step/CheckObject.zig+2| ... | @@ -547,12 +547,14 @@ pub fn checkComputeCompare( | ... | @@ -547,12 +547,14 @@ pub fn checkComputeCompare( |
| 547 | fn make(step: *Step, make_options: Step.MakeOptions) !void { | 547 | fn make(step: *Step, make_options: Step.MakeOptions) !void { |
| 548 | _ = make_options; | 548 | _ = make_options; |
| 549 | const b = step.owner; | 549 | const b = step.owner; |
| 550 | const io = b.graph.io; | ||
| 550 | const gpa = b.allocator; | 551 | const gpa = b.allocator; |
| 551 | const check_object: *CheckObject = @fieldParentPtr("step", step); | 552 | const check_object: *CheckObject = @fieldParentPtr("step", step); |
| 552 | try step.singleUnchangingWatchInput(check_object.source); | 553 | try step.singleUnchangingWatchInput(check_object.source); |
| 553 | 554 | ||
| 554 | const src_path = check_object.source.getPath3(b, step); | 555 | const src_path = check_object.source.getPath3(b, step); |
| 555 | const contents = src_path.root_dir.handle.readFileAllocOptions( | 556 | const contents = src_path.root_dir.handle.readFileAllocOptions( |
| 557 | io, | ||
| 556 | src_path.sub_path, | 558 | src_path.sub_path, |
| 557 | gpa, | 559 | gpa, |
| 558 | .limited(check_object.max_bytes), | 560 | .limited(check_object.max_bytes), |
lib/std/Build/Step/RemoveDir.zig+4-7| ... | @@ -27,6 +27,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void { | ... | @@ -27,6 +27,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void { |
| 27 | _ = options; | 27 | _ = options; |
| 28 | 28 | ||
| 29 | const b = step.owner; | 29 | const b = step.owner; |
| 30 | const io = b.graph.io; | ||
| 30 | const remove_dir: *RemoveDir = @fieldParentPtr("step", step); | 31 | const remove_dir: *RemoveDir = @fieldParentPtr("step", step); |
| 31 | 32 | ||
| 32 | step.clearWatchInputs(); | 33 | step.clearWatchInputs(); |
| ... | @@ -34,15 +35,11 @@ fn make(step: *Step, options: Step.MakeOptions) !void { | ... | @@ -34,15 +35,11 @@ fn make(step: *Step, options: Step.MakeOptions) !void { |
| 34 | 35 | ||
| 35 | const full_doomed_path = remove_dir.doomed_path.getPath2(b, step); | 36 | const full_doomed_path = remove_dir.doomed_path.getPath2(b, step); |
| 36 | 37 | ||
| 37 | b.build_root.handle.deleteTree(full_doomed_path) catch |err| { | 38 | b.build_root.handle.deleteTree(io, full_doomed_path) catch |err| { |
| 38 | if (b.build_root.path) |base| { | 39 | if (b.build_root.path) |base| { |
| 39 | return step.fail("unable to recursively delete path '{s}/{s}': {s}", .{ | 40 | return step.fail("unable to recursively delete path '{s}/{s}': {t}", .{ base, full_doomed_path, err }); |
| 40 | base, full_doomed_path, @errorName(err), | ||
| 41 | }); | ||
| 42 | } else { | 41 | } else { |
| 43 | return step.fail("unable to recursively delete path '{s}': {s}", .{ | 42 | return step.fail("unable to recursively delete path '{s}': {t}", .{ full_doomed_path, err }); |
| 44 | full_doomed_path, @errorName(err), | ||
| 45 | }); | ||
| 46 | } | 43 | } |
| 47 | }; | 44 | }; |
| 48 | } | 45 | } |
lib/std/Build/Step/Run.zig+1-1| ... | @@ -1044,7 +1044,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void { | ... | @@ -1044,7 +1044,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void { |
| 1044 | 1044 | ||
| 1045 | b.cache_root.handle.rename(tmp_dir_path, b.cache_root.handle, o_sub_path, io) catch |err| { | 1045 | b.cache_root.handle.rename(tmp_dir_path, b.cache_root.handle, o_sub_path, io) catch |err| { |
| 1046 | if (err == error.PathAlreadyExists) { | 1046 | if (err == error.PathAlreadyExists) { |
| 1047 | b.cache_root.handle.deleteTree(o_sub_path) catch |del_err| { | 1047 | b.cache_root.handle.deleteTree(io, o_sub_path) catch |del_err| { |
| 1048 | return step.fail("unable to remove dir '{f}'{s}: {t}", .{ | 1048 | return step.fail("unable to remove dir '{f}'{s}: {t}", .{ |
| 1049 | b.cache_root, tmp_dir_path, del_err, | 1049 | b.cache_root, tmp_dir_path, del_err, |
| 1050 | }); | 1050 | }); |
lib/std/fs/test.zig+35-35| ... | @@ -186,7 +186,7 @@ test "Dir.readLink" { | ... | @@ -186,7 +186,7 @@ test "Dir.readLink" { |
| 186 | const file_target_path = try ctx.transformPath("file.txt"); | 186 | const file_target_path = try ctx.transformPath("file.txt"); |
| 187 | try ctx.dir.writeFile(io, .{ .sub_path = file_target_path, .data = "nonsense" }); | 187 | try ctx.dir.writeFile(io, .{ .sub_path = file_target_path, .data = "nonsense" }); |
| 188 | const dir_target_path = try ctx.transformPath("subdir"); | 188 | const dir_target_path = try ctx.transformPath("subdir"); |
| 189 | try ctx.dir.makeDir(dir_target_path); | 189 | try ctx.dir.makeDir(io, dir_target_path, .default_dir); |
| 190 | 190 | ||
| 191 | // On Windows, symlink targets always use the canonical path separator | 191 | // On Windows, symlink targets always use the canonical path separator |
| 192 | const canonical_file_target_path = try ctx.toCanonicalPathSep(file_target_path); | 192 | const canonical_file_target_path = try ctx.toCanonicalPathSep(file_target_path); |
| ... | @@ -282,7 +282,7 @@ test "File.stat on a File that is a symlink returns Kind.sym_link" { | ... | @@ -282,7 +282,7 @@ test "File.stat on a File that is a symlink returns Kind.sym_link" { |
| 282 | try testWithAllSupportedPathTypes(struct { | 282 | try testWithAllSupportedPathTypes(struct { |
| 283 | fn impl(ctx: *TestContext) !void { | 283 | fn impl(ctx: *TestContext) !void { |
| 284 | const dir_target_path = try ctx.transformPath("subdir"); | 284 | const dir_target_path = try ctx.transformPath("subdir"); |
| 285 | try ctx.dir.makeDir(dir_target_path); | 285 | try ctx.dir.makeDir(io, dir_target_path, .default_dir); |
| 286 | 286 | ||
| 287 | try setupSymlink(ctx.dir, dir_target_path, "symlink", .{ .is_directory = true }); | 287 | try setupSymlink(ctx.dir, dir_target_path, "symlink", .{ .is_directory = true }); |
| 288 | 288 | ||
| ... | @@ -363,7 +363,7 @@ test "openDir" { | ... | @@ -363,7 +363,7 @@ test "openDir" { |
| 363 | fn impl(ctx: *TestContext) !void { | 363 | fn impl(ctx: *TestContext) !void { |
| 364 | const allocator = ctx.arena.allocator(); | 364 | const allocator = ctx.arena.allocator(); |
| 365 | const subdir_path = try ctx.transformPath("subdir"); | 365 | const subdir_path = try ctx.transformPath("subdir"); |
| 366 | try ctx.dir.makeDir(subdir_path); | 366 | try ctx.dir.makeDir(io, subdir_path, .default_dir); |
| 367 | 367 | ||
| 368 | for ([_][]const u8{ "", ".", ".." }) |sub_path| { | 368 | for ([_][]const u8{ "", ".", ".." }) |sub_path| { |
| 369 | const dir_path = try fs.path.join(allocator, &.{ subdir_path, sub_path }); | 369 | const dir_path = try fs.path.join(allocator, &.{ subdir_path, sub_path }); |
| ... | @@ -398,7 +398,7 @@ test "openDirAbsolute" { | ... | @@ -398,7 +398,7 @@ test "openDirAbsolute" { |
| 398 | 398 | ||
| 399 | const tmp_ino = (try tmp.dir.stat(io)).inode; | 399 | const tmp_ino = (try tmp.dir.stat(io)).inode; |
| 400 | 400 | ||
| 401 | try tmp.dir.makeDir("subdir"); | 401 | try tmp.dir.makeDir(io, "subdir", .default_dir); |
| 402 | const sub_path = try tmp.dir.realpathAlloc(testing.allocator, "subdir"); | 402 | const sub_path = try tmp.dir.realpathAlloc(testing.allocator, "subdir"); |
| 403 | defer testing.allocator.free(sub_path); | 403 | defer testing.allocator.free(sub_path); |
| 404 | 404 | ||
| ... | @@ -494,7 +494,7 @@ test "readLinkAbsolute" { | ... | @@ -494,7 +494,7 @@ test "readLinkAbsolute" { |
| 494 | 494 | ||
| 495 | // Create some targets | 495 | // Create some targets |
| 496 | try tmp.dir.writeFile(io, .{ .sub_path = "file.txt", .data = "nonsense" }); | 496 | try tmp.dir.writeFile(io, .{ .sub_path = "file.txt", .data = "nonsense" }); |
| 497 | try tmp.dir.makeDir("subdir"); | 497 | try tmp.dir.makeDir(io, "subdir", .default_dir); |
| 498 | 498 | ||
| 499 | // Get base abs path | 499 | // Get base abs path |
| 500 | var arena = ArenaAllocator.init(testing.allocator); | 500 | var arena = ArenaAllocator.init(testing.allocator); |
| ... | @@ -531,7 +531,7 @@ test "Dir.Iterator" { | ... | @@ -531,7 +531,7 @@ test "Dir.Iterator" { |
| 531 | const file = try tmp_dir.dir.createFile(io, "some_file", .{}); | 531 | const file = try tmp_dir.dir.createFile(io, "some_file", .{}); |
| 532 | file.close(io); | 532 | file.close(io); |
| 533 | 533 | ||
| 534 | try tmp_dir.dir.makeDir("some_dir"); | 534 | try tmp_dir.dir.makeDir(io, "some_dir", .default_dir); |
| 535 | 535 | ||
| 536 | var arena = ArenaAllocator.init(testing.allocator); | 536 | var arena = ArenaAllocator.init(testing.allocator); |
| 537 | defer arena.deinit(); | 537 | defer arena.deinit(); |
| ... | @@ -600,7 +600,7 @@ test "Dir.Iterator twice" { | ... | @@ -600,7 +600,7 @@ test "Dir.Iterator twice" { |
| 600 | const file = try tmp_dir.dir.createFile(io, "some_file", .{}); | 600 | const file = try tmp_dir.dir.createFile(io, "some_file", .{}); |
| 601 | file.close(io); | 601 | file.close(io); |
| 602 | 602 | ||
| 603 | try tmp_dir.dir.makeDir("some_dir"); | 603 | try tmp_dir.dir.makeDir(io, "some_dir", .default_dir); |
| 604 | 604 | ||
| 605 | var arena = ArenaAllocator.init(testing.allocator); | 605 | var arena = ArenaAllocator.init(testing.allocator); |
| 606 | defer arena.deinit(); | 606 | defer arena.deinit(); |
| ... | @@ -635,7 +635,7 @@ test "Dir.Iterator reset" { | ... | @@ -635,7 +635,7 @@ test "Dir.Iterator reset" { |
| 635 | const file = try tmp_dir.dir.createFile(io, "some_file", .{}); | 635 | const file = try tmp_dir.dir.createFile(io, "some_file", .{}); |
| 636 | file.close(io); | 636 | file.close(io); |
| 637 | 637 | ||
| 638 | try tmp_dir.dir.makeDir("some_dir"); | 638 | try tmp_dir.dir.makeDir(io, "some_dir", .default_dir); |
| 639 | 639 | ||
| 640 | var arena = ArenaAllocator.init(testing.allocator); | 640 | var arena = ArenaAllocator.init(testing.allocator); |
| 641 | defer arena.deinit(); | 641 | defer arena.deinit(); |
| ... | @@ -682,7 +682,7 @@ test "Dir.Iterator but dir is deleted during iteration" { | ... | @@ -682,7 +682,7 @@ test "Dir.Iterator but dir is deleted during iteration" { |
| 682 | // This is a contrived reproduction, but this could happen outside of the program, in another thread, etc. | 682 | // This is a contrived reproduction, but this could happen outside of the program, in another thread, etc. |
| 683 | // If we get an error while trying to delete, we can skip this test (this will happen on platforms | 683 | // If we get an error while trying to delete, we can skip this test (this will happen on platforms |
| 684 | // like Windows which will give FileBusy if the directory is currently open for iteration). | 684 | // like Windows which will give FileBusy if the directory is currently open for iteration). |
| 685 | tmp.dir.deleteTree("subdir") catch return error.SkipZigTest; | 685 | tmp.dir.deleteTree(io, "subdir") catch return error.SkipZigTest; |
| 686 | 686 | ||
| 687 | // Now, when we try to iterate, the next call should return null immediately. | 687 | // Now, when we try to iterate, the next call should return null immediately. |
| 688 | const entry = try iterator.next(); | 688 | const entry = try iterator.next(); |
| ... | @@ -724,7 +724,7 @@ test "Dir.realpath smoke test" { | ... | @@ -724,7 +724,7 @@ test "Dir.realpath smoke test" { |
| 724 | 724 | ||
| 725 | // Now create the file and dir | 725 | // Now create the file and dir |
| 726 | try ctx.dir.writeFile(io, .{ .sub_path = test_file_path, .data = "" }); | 726 | try ctx.dir.writeFile(io, .{ .sub_path = test_file_path, .data = "" }); |
| 727 | try ctx.dir.makeDir(test_dir_path); | 727 | try ctx.dir.makeDir(io, test_dir_path, .default_dir); |
| 728 | 728 | ||
| 729 | const base_path = try ctx.transformPath("."); | 729 | const base_path = try ctx.transformPath("."); |
| 730 | const base_realpath = try ctx.dir.realpathAlloc(allocator, base_path); | 730 | const base_realpath = try ctx.dir.realpathAlloc(allocator, base_path); |
| ... | @@ -842,7 +842,7 @@ test "directory operations on files" { | ... | @@ -842,7 +842,7 @@ test "directory operations on files" { |
| 842 | var file = try ctx.dir.createFile(io, test_file_name, .{ .read = true }); | 842 | var file = try ctx.dir.createFile(io, test_file_name, .{ .read = true }); |
| 843 | file.close(io); | 843 | file.close(io); |
| 844 | 844 | ||
| 845 | try testing.expectError(error.PathAlreadyExists, ctx.dir.makeDir(test_file_name)); | 845 | try testing.expectError(error.PathAlreadyExists, ctx.dir.makeDir(io, test_file_name, .default_dir)); |
| 846 | try testing.expectError(error.NotDir, ctx.dir.openDir(io, test_file_name, .{})); | 846 | try testing.expectError(error.NotDir, ctx.dir.openDir(io, test_file_name, .{})); |
| 847 | try testing.expectError(error.NotDir, ctx.dir.deleteDir(test_file_name)); | 847 | try testing.expectError(error.NotDir, ctx.dir.deleteDir(test_file_name)); |
| 848 | 848 | ||
| ... | @@ -870,7 +870,7 @@ test "file operations on directories" { | ... | @@ -870,7 +870,7 @@ test "file operations on directories" { |
| 870 | fn impl(ctx: *TestContext) !void { | 870 | fn impl(ctx: *TestContext) !void { |
| 871 | const test_dir_name = try ctx.transformPath("test_dir"); | 871 | const test_dir_name = try ctx.transformPath("test_dir"); |
| 872 | 872 | ||
| 873 | try ctx.dir.makeDir(test_dir_name); | 873 | try ctx.dir.makeDir(io, test_dir_name, .default_dir); |
| 874 | 874 | ||
| 875 | try testing.expectError(error.IsDir, ctx.dir.createFile(io, test_dir_name, .{})); | 875 | try testing.expectError(error.IsDir, ctx.dir.createFile(io, test_dir_name, .{})); |
| 876 | try testing.expectError(error.IsDir, ctx.dir.deleteFile(test_dir_name)); | 876 | try testing.expectError(error.IsDir, ctx.dir.deleteFile(test_dir_name)); |
| ... | @@ -937,7 +937,7 @@ test "deleteDir" { | ... | @@ -937,7 +937,7 @@ test "deleteDir" { |
| 937 | try testing.expectError(error.FileNotFound, ctx.dir.deleteDir(test_dir_path)); | 937 | try testing.expectError(error.FileNotFound, ctx.dir.deleteDir(test_dir_path)); |
| 938 | 938 | ||
| 939 | // deleting a non-empty directory | 939 | // deleting a non-empty directory |
| 940 | try ctx.dir.makeDir(test_dir_path); | 940 | try ctx.dir.makeDir(io, test_dir_path, .default_dir); |
| 941 | try ctx.dir.writeFile(io, .{ .sub_path = test_file_path, .data = "" }); | 941 | try ctx.dir.writeFile(io, .{ .sub_path = test_file_path, .data = "" }); |
| 942 | try testing.expectError(error.DirNotEmpty, ctx.dir.deleteDir(test_dir_path)); | 942 | try testing.expectError(error.DirNotEmpty, ctx.dir.deleteDir(test_dir_path)); |
| 943 | 943 | ||
| ... | @@ -1006,7 +1006,7 @@ test "Dir.rename directories" { | ... | @@ -1006,7 +1006,7 @@ test "Dir.rename directories" { |
| 1006 | const test_dir_renamed_path = try ctx.transformPath("test_dir_renamed"); | 1006 | const test_dir_renamed_path = try ctx.transformPath("test_dir_renamed"); |
| 1007 | 1007 | ||
| 1008 | // Renaming directories | 1008 | // Renaming directories |
| 1009 | try ctx.dir.makeDir(test_dir_path); | 1009 | try ctx.dir.makeDir(io, test_dir_path, .default_dir); |
| 1010 | try ctx.dir.rename(test_dir_path, ctx.dir, test_dir_renamed_path, io); | 1010 | try ctx.dir.rename(test_dir_path, ctx.dir, test_dir_renamed_path, io); |
| 1011 | 1011 | ||
| 1012 | // Ensure the directory was renamed | 1012 | // Ensure the directory was renamed |
| ... | @@ -1042,8 +1042,8 @@ test "Dir.rename directory onto empty dir" { | ... | @@ -1042,8 +1042,8 @@ test "Dir.rename directory onto empty dir" { |
| 1042 | const test_dir_path = try ctx.transformPath("test_dir"); | 1042 | const test_dir_path = try ctx.transformPath("test_dir"); |
| 1043 | const target_dir_path = try ctx.transformPath("target_dir_path"); | 1043 | const target_dir_path = try ctx.transformPath("target_dir_path"); |
| 1044 | 1044 | ||
| 1045 | try ctx.dir.makeDir(test_dir_path); | 1045 | try ctx.dir.makeDir(io, test_dir_path, .default_dir); |
| 1046 | try ctx.dir.makeDir(target_dir_path); | 1046 | try ctx.dir.makeDir(io, target_dir_path, .default_dir); |
| 1047 | try ctx.dir.rename(test_dir_path, ctx.dir, target_dir_path, io); | 1047 | try ctx.dir.rename(test_dir_path, ctx.dir, target_dir_path, io); |
| 1048 | 1048 | ||
| 1049 | // Ensure the directory was renamed | 1049 | // Ensure the directory was renamed |
| ... | @@ -1064,7 +1064,7 @@ test "Dir.rename directory onto non-empty dir" { | ... | @@ -1064,7 +1064,7 @@ test "Dir.rename directory onto non-empty dir" { |
| 1064 | const test_dir_path = try ctx.transformPath("test_dir"); | 1064 | const test_dir_path = try ctx.transformPath("test_dir"); |
| 1065 | const target_dir_path = try ctx.transformPath("target_dir_path"); | 1065 | const target_dir_path = try ctx.transformPath("target_dir_path"); |
| 1066 | 1066 | ||
| 1067 | try ctx.dir.makeDir(test_dir_path); | 1067 | try ctx.dir.makeDir(io, test_dir_path, .default_dir); |
| 1068 | 1068 | ||
| 1069 | var target_dir = try ctx.dir.makeOpenPath(target_dir_path, .{}); | 1069 | var target_dir = try ctx.dir.makeOpenPath(target_dir_path, .{}); |
| 1070 | var file = try target_dir.createFile(io, "test_file", .{ .read = true }); | 1070 | var file = try target_dir.createFile(io, "test_file", .{ .read = true }); |
| ... | @@ -1093,7 +1093,7 @@ test "Dir.rename file <-> dir" { | ... | @@ -1093,7 +1093,7 @@ test "Dir.rename file <-> dir" { |
| 1093 | 1093 | ||
| 1094 | var file = try ctx.dir.createFile(io, test_file_path, .{ .read = true }); | 1094 | var file = try ctx.dir.createFile(io, test_file_path, .{ .read = true }); |
| 1095 | file.close(io); | 1095 | file.close(io); |
| 1096 | try ctx.dir.makeDir(test_dir_path); | 1096 | try ctx.dir.makeDir(io, test_dir_path, .default_dir); |
| 1097 | try testing.expectError(error.IsDir, ctx.dir.rename(test_file_path, ctx.dir, test_dir_path, io)); | 1097 | try testing.expectError(error.IsDir, ctx.dir.rename(test_file_path, ctx.dir, test_dir_path, io)); |
| 1098 | try testing.expectError(error.NotDir, ctx.dir.rename(test_dir_path, ctx.dir, test_file_path, io)); | 1098 | try testing.expectError(error.NotDir, ctx.dir.rename(test_dir_path, ctx.dir, test_file_path, io)); |
| 1099 | } | 1099 | } |
| ... | @@ -1163,7 +1163,7 @@ test "renameAbsolute" { | ... | @@ -1163,7 +1163,7 @@ test "renameAbsolute" { |
| 1163 | // Renaming directories | 1163 | // Renaming directories |
| 1164 | const test_dir_name = "test_dir"; | 1164 | const test_dir_name = "test_dir"; |
| 1165 | const renamed_test_dir_name = "test_dir_renamed"; | 1165 | const renamed_test_dir_name = "test_dir_renamed"; |
| 1166 | try tmp_dir.dir.makeDir(test_dir_name); | 1166 | try tmp_dir.dir.makeDir(io, test_dir_name, .default_dir); |
| 1167 | try fs.renameAbsolute( | 1167 | try fs.renameAbsolute( |
| 1168 | try fs.path.join(allocator, &.{ base_path, test_dir_name }), | 1168 | try fs.path.join(allocator, &.{ base_path, test_dir_name }), |
| 1169 | try fs.path.join(allocator, &.{ base_path, renamed_test_dir_name }), | 1169 | try fs.path.join(allocator, &.{ base_path, renamed_test_dir_name }), |
| ... | @@ -1209,7 +1209,7 @@ test "deleteTree does not follow symlinks" { | ... | @@ -1209,7 +1209,7 @@ test "deleteTree does not follow symlinks" { |
| 1209 | try setupSymlink(a, "../b", "b", .{ .is_directory = true }); | 1209 | try setupSymlink(a, "../b", "b", .{ .is_directory = true }); |
| 1210 | } | 1210 | } |
| 1211 | 1211 | ||
| 1212 | try tmp.dir.deleteTree("a"); | 1212 | try tmp.dir.deleteTree(io, "a"); |
| 1213 | 1213 | ||
| 1214 | try testing.expectError(error.FileNotFound, tmp.dir.access(io, "a", .{})); | 1214 | try testing.expectError(error.FileNotFound, tmp.dir.access(io, "a", .{})); |
| 1215 | try tmp.dir.access(io, "b", .{}); | 1215 | try tmp.dir.access(io, "b", .{}); |
| ... | @@ -1225,7 +1225,7 @@ test "deleteTree on a symlink" { | ... | @@ -1225,7 +1225,7 @@ test "deleteTree on a symlink" { |
| 1225 | try tmp.dir.writeFile(io, .{ .sub_path = "file", .data = "" }); | 1225 | try tmp.dir.writeFile(io, .{ .sub_path = "file", .data = "" }); |
| 1226 | try setupSymlink(tmp.dir, "file", "filelink", .{}); | 1226 | try setupSymlink(tmp.dir, "file", "filelink", .{}); |
| 1227 | 1227 | ||
| 1228 | try tmp.dir.deleteTree("filelink"); | 1228 | try tmp.dir.deleteTree(io, "filelink"); |
| 1229 | try testing.expectError(error.FileNotFound, tmp.dir.access(io, "filelink", .{})); | 1229 | try testing.expectError(error.FileNotFound, tmp.dir.access(io, "filelink", .{})); |
| 1230 | try tmp.dir.access(io, "file", .{}); | 1230 | try tmp.dir.access(io, "file", .{}); |
| 1231 | 1231 | ||
| ... | @@ -1233,7 +1233,7 @@ test "deleteTree on a symlink" { | ... | @@ -1233,7 +1233,7 @@ test "deleteTree on a symlink" { |
| 1233 | try tmp.dir.makePath(io, "dir"); | 1233 | try tmp.dir.makePath(io, "dir"); |
| 1234 | try setupSymlink(tmp.dir, "dir", "dirlink", .{ .is_directory = true }); | 1234 | try setupSymlink(tmp.dir, "dir", "dirlink", .{ .is_directory = true }); |
| 1235 | 1235 | ||
| 1236 | try tmp.dir.deleteTree("dirlink"); | 1236 | try tmp.dir.deleteTree(io, "dirlink"); |
| 1237 | try testing.expectError(error.FileNotFound, tmp.dir.access(io, "dirlink", .{})); | 1237 | try testing.expectError(error.FileNotFound, tmp.dir.access(io, "dirlink", .{})); |
| 1238 | try tmp.dir.access(io, "dir", .{}); | 1238 | try tmp.dir.access(io, "dir", .{}); |
| 1239 | } | 1239 | } |
| ... | @@ -1255,7 +1255,7 @@ test "makePath, put some files in it, deleteTree" { | ... | @@ -1255,7 +1255,7 @@ test "makePath, put some files in it, deleteTree" { |
| 1255 | .data = "blah", | 1255 | .data = "blah", |
| 1256 | }); | 1256 | }); |
| 1257 | 1257 | ||
| 1258 | try ctx.dir.deleteTree(dir_path); | 1258 | try ctx.dir.deleteTree(io, dir_path); |
| 1259 | try testing.expectError(error.FileNotFound, ctx.dir.openDir(io, dir_path, .{})); | 1259 | try testing.expectError(error.FileNotFound, ctx.dir.openDir(io, dir_path, .{})); |
| 1260 | } | 1260 | } |
| 1261 | }.impl); | 1261 | }.impl); |
| ... | @@ -1291,7 +1291,7 @@ test "makePath in a directory that no longer exists" { | ... | @@ -1291,7 +1291,7 @@ test "makePath in a directory that no longer exists" { |
| 1291 | 1291 | ||
| 1292 | var tmp = tmpDir(.{}); | 1292 | var tmp = tmpDir(.{}); |
| 1293 | defer tmp.cleanup(); | 1293 | defer tmp.cleanup(); |
| 1294 | try tmp.parent_dir.deleteTree(&tmp.sub_path); | 1294 | try tmp.parent_dir.deleteTree(io, &tmp.sub_path); |
| 1295 | 1295 | ||
| 1296 | try testing.expectError(error.FileNotFound, tmp.dir.makePath(io, "sub-path")); | 1296 | try testing.expectError(error.FileNotFound, tmp.dir.makePath(io, "sub-path")); |
| 1297 | } | 1297 | } |
| ... | @@ -1302,7 +1302,7 @@ test "makePath but sub_path contains pre-existing file" { | ... | @@ -1302,7 +1302,7 @@ test "makePath but sub_path contains pre-existing file" { |
| 1302 | var tmp = tmpDir(.{}); | 1302 | var tmp = tmpDir(.{}); |
| 1303 | defer tmp.cleanup(); | 1303 | defer tmp.cleanup(); |
| 1304 | 1304 | ||
| 1305 | try tmp.dir.makeDir("foo"); | 1305 | try tmp.dir.makeDir(io, "foo", .default_dir); |
| 1306 | try tmp.dir.writeFile(io, .{ .sub_path = "foo/bar", .data = "" }); | 1306 | try tmp.dir.writeFile(io, .{ .sub_path = "foo/bar", .data = "" }); |
| 1307 | 1307 | ||
| 1308 | try testing.expectError(error.NotDir, tmp.dir.makePath(io, "foo/bar/baz")); | 1308 | try testing.expectError(error.NotDir, tmp.dir.makePath(io, "foo/bar/baz")); |
| ... | @@ -1319,10 +1319,10 @@ test "makepath existing directories" { | ... | @@ -1319,10 +1319,10 @@ test "makepath existing directories" { |
| 1319 | var tmp = tmpDir(.{}); | 1319 | var tmp = tmpDir(.{}); |
| 1320 | defer tmp.cleanup(); | 1320 | defer tmp.cleanup(); |
| 1321 | 1321 | ||
| 1322 | try tmp.dir.makeDir("A"); | 1322 | try tmp.dir.makeDir(io, "A", .default_dir); |
| 1323 | var tmpA = try tmp.dir.openDir(io, "A", .{}); | 1323 | var tmpA = try tmp.dir.openDir(io, "A", .{}); |
| 1324 | defer tmpA.close(io); | 1324 | defer tmpA.close(io); |
| 1325 | try tmpA.makeDir("B"); | 1325 | try tmpA.makeDir(io, "B", .default_dir); |
| 1326 | 1326 | ||
| 1327 | const testPath = "A" ++ fs.path.sep_str ++ "B" ++ fs.path.sep_str ++ "C"; | 1327 | const testPath = "A" ++ fs.path.sep_str ++ "B" ++ fs.path.sep_str ++ "C"; |
| 1328 | try tmp.dir.makePath(io, testPath); | 1328 | try tmp.dir.makePath(io, testPath); |
| ... | @@ -1336,7 +1336,7 @@ test "makepath through existing valid symlink" { | ... | @@ -1336,7 +1336,7 @@ test "makepath through existing valid symlink" { |
| 1336 | var tmp = tmpDir(.{}); | 1336 | var tmp = tmpDir(.{}); |
| 1337 | defer tmp.cleanup(); | 1337 | defer tmp.cleanup(); |
| 1338 | 1338 | ||
| 1339 | try tmp.dir.makeDir("realfolder"); | 1339 | try tmp.dir.makeDir(io, "realfolder", .default_dir); |
| 1340 | try setupSymlink(tmp.dir, "." ++ fs.path.sep_str ++ "realfolder", "working-symlink", .{}); | 1340 | try setupSymlink(tmp.dir, "." ++ fs.path.sep_str ++ "realfolder", "working-symlink", .{}); |
| 1341 | 1341 | ||
| 1342 | try tmp.dir.makePath(io, "working-symlink" ++ fs.path.sep_str ++ "in-realfolder"); | 1342 | try tmp.dir.makePath(io, "working-symlink" ++ fs.path.sep_str ++ "in-realfolder"); |
| ... | @@ -1419,7 +1419,7 @@ fn testFilenameLimits(io: Io, iterable_dir: Dir, maxed_filename: []const u8) !vo | ... | @@ -1419,7 +1419,7 @@ fn testFilenameLimits(io: Io, iterable_dir: Dir, maxed_filename: []const u8) !vo |
| 1419 | } | 1419 | } |
| 1420 | 1420 | ||
| 1421 | // ensure that we can delete the tree | 1421 | // ensure that we can delete the tree |
| 1422 | try iterable_dir.deleteTree(maxed_filename); | 1422 | try iterable_dir.deleteTree(io, maxed_filename); |
| 1423 | } | 1423 | } |
| 1424 | 1424 | ||
| 1425 | test "max file name component lengths" { | 1425 | test "max file name component lengths" { |
| ... | @@ -1570,7 +1570,7 @@ test "access file" { | ... | @@ -1570,7 +1570,7 @@ test "access file" { |
| 1570 | 1570 | ||
| 1571 | try ctx.dir.writeFile(io, .{ .sub_path = file_path, .data = "" }); | 1571 | try ctx.dir.writeFile(io, .{ .sub_path = file_path, .data = "" }); |
| 1572 | try ctx.dir.access(io, file_path, .{}); | 1572 | try ctx.dir.access(io, file_path, .{}); |
| 1573 | try ctx.dir.deleteTree(dir_path); | 1573 | try ctx.dir.deleteTree(io, dir_path); |
| 1574 | } | 1574 | } |
| 1575 | }.impl); | 1575 | }.impl); |
| 1576 | } | 1576 | } |
| ... | @@ -2042,7 +2042,7 @@ test "'.' and '..' in Io.Dir functions" { | ... | @@ -2042,7 +2042,7 @@ test "'.' and '..' in Io.Dir functions" { |
| 2042 | const rename_path = try ctx.transformPath("./subdir/../rename"); | 2042 | const rename_path = try ctx.transformPath("./subdir/../rename"); |
| 2043 | const update_path = try ctx.transformPath("./subdir/../update"); | 2043 | const update_path = try ctx.transformPath("./subdir/../update"); |
| 2044 | 2044 | ||
| 2045 | try ctx.dir.makeDir(subdir_path); | 2045 | try ctx.dir.makeDir(io, subdir_path, .default_dir); |
| 2046 | try ctx.dir.access(io, subdir_path, .{}); | 2046 | try ctx.dir.access(io, subdir_path, .{}); |
| 2047 | var created_subdir = try ctx.dir.openDir(io, subdir_path, .{}); | 2047 | var created_subdir = try ctx.dir.openDir(io, subdir_path, .{}); |
| 2048 | created_subdir.close(io); | 2048 | created_subdir.close(io); |
| ... | @@ -2120,7 +2120,7 @@ test "chmod" { | ... | @@ -2120,7 +2120,7 @@ test "chmod" { |
| 2120 | try file.chmod(0o644); | 2120 | try file.chmod(0o644); |
| 2121 | try testing.expectEqual(@as(File.Mode, 0o644), (try file.stat(io)).mode & 0o7777); | 2121 | try testing.expectEqual(@as(File.Mode, 0o644), (try file.stat(io)).mode & 0o7777); |
| 2122 | 2122 | ||
| 2123 | try tmp.dir.makeDir("test_dir"); | 2123 | try tmp.dir.makeDir(io, "test_dir", .default_dir); |
| 2124 | var dir = try tmp.dir.openDir(io, "test_dir", .{ .iterate = true }); | 2124 | var dir = try tmp.dir.openDir(io, "test_dir", .{ .iterate = true }); |
| 2125 | defer dir.close(io); | 2125 | defer dir.close(io); |
| 2126 | 2126 | ||
| ... | @@ -2141,7 +2141,7 @@ test "chown" { | ... | @@ -2141,7 +2141,7 @@ test "chown" { |
| 2141 | defer file.close(io); | 2141 | defer file.close(io); |
| 2142 | try file.chown(null, null); | 2142 | try file.chown(null, null); |
| 2143 | 2143 | ||
| 2144 | try tmp.dir.makeDir("test_dir"); | 2144 | try tmp.dir.makeDir(io, "test_dir", .default_dir); |
| 2145 | 2145 | ||
| 2146 | var dir = try tmp.dir.openDir(io, "test_dir", .{ .iterate = true }); | 2146 | var dir = try tmp.dir.openDir(io, "test_dir", .{ .iterate = true }); |
| 2147 | defer dir.close(io); | 2147 | defer dir.close(io); |
| ... | @@ -2165,7 +2165,7 @@ test "invalid UTF-8/WTF-8 paths" { | ... | @@ -2165,7 +2165,7 @@ test "invalid UTF-8/WTF-8 paths" { |
| 2165 | 2165 | ||
| 2166 | try testing.expectError(expected_err, ctx.dir.createFile(invalid_path, .{})); | 2166 | try testing.expectError(expected_err, ctx.dir.createFile(invalid_path, .{})); |
| 2167 | 2167 | ||
| 2168 | try testing.expectError(expected_err, ctx.dir.makeDir(invalid_path)); | 2168 | try testing.expectError(expected_err, ctx.dir.makeDir(invalid_path, .default_dir)); |
| 2169 | 2169 | ||
| 2170 | try testing.expectError(expected_err, ctx.dir.makePath(invalid_path)); | 2170 | try testing.expectError(expected_err, ctx.dir.makePath(invalid_path)); |
| 2171 | try testing.expectError(expected_err, ctx.dir.makeOpenPath(invalid_path, .{})); | 2171 | try testing.expectError(expected_err, ctx.dir.makeOpenPath(invalid_path, .{})); |
| ... | @@ -2191,7 +2191,7 @@ test "invalid UTF-8/WTF-8 paths" { | ... | @@ -2191,7 +2191,7 @@ test "invalid UTF-8/WTF-8 paths" { |
| 2191 | try testing.expectError(expected_err, ctx.dir.readFile(invalid_path, &[_]u8{})); | 2191 | try testing.expectError(expected_err, ctx.dir.readFile(invalid_path, &[_]u8{})); |
| 2192 | try testing.expectError(expected_err, ctx.dir.readFileAlloc(invalid_path, testing.allocator, .limited(0))); | 2192 | try testing.expectError(expected_err, ctx.dir.readFileAlloc(invalid_path, testing.allocator, .limited(0))); |
| 2193 | 2193 | ||
| 2194 | try testing.expectError(expected_err, ctx.dir.deleteTree(invalid_path)); | 2194 | try testing.expectError(expected_err, ctx.dir.deleteTree(io, invalid_path)); |
| 2195 | try testing.expectError(expected_err, ctx.dir.deleteTreeMinStackSize(invalid_path)); | 2195 | try testing.expectError(expected_err, ctx.dir.deleteTreeMinStackSize(invalid_path)); |
| 2196 | 2196 | ||
| 2197 | try testing.expectError(expected_err, ctx.dir.writeFile(io, .{ .sub_path = invalid_path, .data = "" })); | 2197 | try testing.expectError(expected_err, ctx.dir.writeFile(io, .{ .sub_path = invalid_path, .data = "" })); |
lib/std/testing.zig+1-1| ... | @@ -616,7 +616,7 @@ pub const TmpDir = struct { | ... | @@ -616,7 +616,7 @@ pub const TmpDir = struct { |
| 616 | 616 | ||
| 617 | pub fn cleanup(self: *TmpDir) void { | 617 | pub fn cleanup(self: *TmpDir) void { |
| 618 | self.dir.close(io); | 618 | self.dir.close(io); |
| 619 | self.parent_dir.deleteTree(&self.sub_path) catch {}; | 619 | self.parent_dir.deleteTree(io, &self.sub_path) catch {}; |
| 620 | self.parent_dir.close(io); | 620 | self.parent_dir.close(io); |
| 621 | self.* = undefined; | 621 | self.* = undefined; |
| 622 | } | 622 | } |
src/Compilation.zig+8-14| ... | @@ -2823,12 +2823,9 @@ fn cleanupAfterUpdate(comp: *Compilation, tmp_dir_rand_int: u64) void { | ... | @@ -2823,12 +2823,9 @@ fn cleanupAfterUpdate(comp: *Compilation, tmp_dir_rand_int: u64) void { |
| 2823 | return; | 2823 | return; |
| 2824 | } | 2824 | } |
| 2825 | const tmp_dir_sub_path = "tmp" ++ fs.path.sep_str ++ std.fmt.hex(tmp_dir_rand_int); | 2825 | const tmp_dir_sub_path = "tmp" ++ fs.path.sep_str ++ std.fmt.hex(tmp_dir_rand_int); |
| 2826 | comp.dirs.local_cache.handle.deleteTree(tmp_dir_sub_path) catch |err| { | 2826 | comp.dirs.local_cache.handle.deleteTree(io, tmp_dir_sub_path) catch |err| { |
| 2827 | log.warn("failed to delete temporary directory '{s}{c}{s}': {s}", .{ | 2827 | log.warn("failed to delete temporary directory '{s}{c}{s}': {t}", .{ |
| 2828 | comp.dirs.local_cache.path orelse ".", | 2828 | comp.dirs.local_cache.path orelse ".", fs.path.sep, tmp_dir_sub_path, err, |
| 2829 | fs.path.sep, | ||
| 2830 | tmp_dir_sub_path, | ||
| 2831 | @errorName(err), | ||
| 2832 | }); | 2829 | }); |
| 2833 | }; | 2830 | }; |
| 2834 | } | 2831 | } |
| ... | @@ -2847,12 +2844,9 @@ fn cleanupAfterUpdate(comp: *Compilation, tmp_dir_rand_int: u64) void { | ... | @@ -2847,12 +2844,9 @@ fn cleanupAfterUpdate(comp: *Compilation, tmp_dir_rand_int: u64) void { |
| 2847 | tmp_dir.handle.close(io); | 2844 | tmp_dir.handle.close(io); |
| 2848 | whole.tmp_artifact_directory = null; | 2845 | whole.tmp_artifact_directory = null; |
| 2849 | const tmp_dir_sub_path = "tmp" ++ fs.path.sep_str ++ std.fmt.hex(tmp_dir_rand_int); | 2846 | const tmp_dir_sub_path = "tmp" ++ fs.path.sep_str ++ std.fmt.hex(tmp_dir_rand_int); |
| 2850 | comp.dirs.local_cache.handle.deleteTree(tmp_dir_sub_path) catch |err| { | 2847 | comp.dirs.local_cache.handle.deleteTree(io, tmp_dir_sub_path) catch |err| { |
| 2851 | log.warn("failed to delete temporary directory '{s}{c}{s}': {s}", .{ | 2848 | log.warn("failed to delete temporary directory '{s}{c}{s}': {t}", .{ |
| 2852 | comp.dirs.local_cache.path orelse ".", | 2849 | comp.dirs.local_cache.path orelse ".", fs.path.sep, tmp_dir_sub_path, err, |
| 2853 | fs.path.sep, | ||
| 2854 | tmp_dir_sub_path, | ||
| 2855 | @errorName(err), | ||
| 2856 | }); | 2850 | }); |
| 2857 | }; | 2851 | }; |
| 2858 | } | 2852 | } |
| ... | @@ -3419,13 +3413,13 @@ fn renameTmpIntoCache( | ... | @@ -3419,13 +3413,13 @@ fn renameTmpIntoCache( |
| 3419 | .windows => { | 3413 | .windows => { |
| 3420 | if (seen_eaccess) return error.AccessDenied; | 3414 | if (seen_eaccess) return error.AccessDenied; |
| 3421 | seen_eaccess = true; | 3415 | seen_eaccess = true; |
| 3422 | try cache_directory.handle.deleteTree(o_sub_path); | 3416 | try cache_directory.handle.deleteTree(io, o_sub_path); |
| 3423 | continue; | 3417 | continue; |
| 3424 | }, | 3418 | }, |
| 3425 | else => return error.AccessDenied, | 3419 | else => return error.AccessDenied, |
| 3426 | }, | 3420 | }, |
| 3427 | error.PathAlreadyExists => { | 3421 | error.PathAlreadyExists => { |
| 3428 | try cache_directory.handle.deleteTree(o_sub_path); | 3422 | try cache_directory.handle.deleteTree(io, o_sub_path); |
| 3429 | continue; | 3423 | continue; |
| 3430 | }, | 3424 | }, |
| 3431 | error.FileNotFound => { | 3425 | error.FileNotFound => { |
src/Package/Fetch.zig+5-3| ... | @@ -656,9 +656,11 @@ fn checkBuildFileExistence(f: *Fetch) RunError!void { | ... | @@ -656,9 +656,11 @@ fn checkBuildFileExistence(f: *Fetch) RunError!void { |
| 656 | 656 | ||
| 657 | /// This function populates `f.manifest` or leaves it `null`. | 657 | /// This function populates `f.manifest` or leaves it `null`. |
| 658 | fn loadManifest(f: *Fetch, pkg_root: Cache.Path) RunError!void { | 658 | fn loadManifest(f: *Fetch, pkg_root: Cache.Path) RunError!void { |
| 659 | const io = f.job_queue.io; | ||
| 659 | const eb = &f.error_bundle; | 660 | const eb = &f.error_bundle; |
| 660 | const arena = f.arena.allocator(); | 661 | const arena = f.arena.allocator(); |
| 661 | const manifest_bytes = pkg_root.root_dir.handle.readFileAllocOptions( | 662 | const manifest_bytes = pkg_root.root_dir.handle.readFileAllocOptions( |
| 663 | io, | ||
| 662 | try fs.path.join(arena, &.{ pkg_root.sub_path, Manifest.basename }), | 664 | try fs.path.join(arena, &.{ pkg_root.sub_path, Manifest.basename }), |
| 663 | arena, | 665 | arena, |
| 664 | .limited(Manifest.max_bytes), | 666 | .limited(Manifest.max_bytes), |
| ... | @@ -1409,7 +1411,7 @@ fn unpackGitPack(f: *Fetch, out_dir: Io.Dir, resource: *Resource.Git) anyerror!U | ... | @@ -1409,7 +1411,7 @@ fn unpackGitPack(f: *Fetch, out_dir: Io.Dir, resource: *Resource.Git) anyerror!U |
| 1409 | } | 1411 | } |
| 1410 | } | 1412 | } |
| 1411 | 1413 | ||
| 1412 | try out_dir.deleteTree(".git"); | 1414 | try out_dir.deleteTree(io, ".git"); |
| 1413 | return res; | 1415 | return res; |
| 1414 | } | 1416 | } |
| 1415 | 1417 | ||
| ... | @@ -1461,7 +1463,7 @@ pub fn renameTmpIntoCache(io: Io, cache_dir: Io.Dir, tmp_dir_sub_path: []const u | ... | @@ -1461,7 +1463,7 @@ pub fn renameTmpIntoCache(io: Io, cache_dir: Io.Dir, tmp_dir_sub_path: []const u |
| 1461 | cache_dir.rename(tmp_dir_sub_path, cache_dir, dest_dir_sub_path, io) catch |err| switch (err) { | 1463 | cache_dir.rename(tmp_dir_sub_path, cache_dir, dest_dir_sub_path, io) catch |err| switch (err) { |
| 1462 | error.FileNotFound => { | 1464 | error.FileNotFound => { |
| 1463 | if (handled_missing_dir) return err; | 1465 | if (handled_missing_dir) return err; |
| 1464 | cache_dir.makeDir(dest_dir_sub_path[0..1]) catch |mkd_err| switch (mkd_err) { | 1466 | cache_dir.makeDir(io, dest_dir_sub_path[0..1], .default_dir) catch |mkd_err| switch (mkd_err) { |
| 1465 | error.PathAlreadyExists => handled_missing_dir = true, | 1467 | error.PathAlreadyExists => handled_missing_dir = true, |
| 1466 | else => |e| return e, | 1468 | else => |e| return e, |
| 1467 | }; | 1469 | }; |
| ... | @@ -1469,7 +1471,7 @@ pub fn renameTmpIntoCache(io: Io, cache_dir: Io.Dir, tmp_dir_sub_path: []const u | ... | @@ -1469,7 +1471,7 @@ pub fn renameTmpIntoCache(io: Io, cache_dir: Io.Dir, tmp_dir_sub_path: []const u |
| 1469 | }, | 1471 | }, |
| 1470 | error.PathAlreadyExists, error.AccessDenied => { | 1472 | error.PathAlreadyExists, error.AccessDenied => { |
| 1471 | // Package has been already downloaded and may already be in use on the system. | 1473 | // Package has been already downloaded and may already be in use on the system. |
| 1472 | cache_dir.deleteTree(tmp_dir_sub_path) catch { | 1474 | cache_dir.deleteTree(io, tmp_dir_sub_path) catch { |
| 1473 | // Garbage files leftover in zig-cache/tmp/ is, as they say | 1475 | // Garbage files leftover in zig-cache/tmp/ is, as they say |
| 1474 | // on Star Trek, "operating within normal parameters". | 1476 | // on Star Trek, "operating within normal parameters". |
| 1475 | }; | 1477 | }; |
src/Package/Fetch/git.zig+2-2| ... | @@ -253,7 +253,7 @@ pub const Repository = struct { | ... | @@ -253,7 +253,7 @@ pub const Repository = struct { |
| 253 | while (try tree_iter.next()) |entry| { | 253 | while (try tree_iter.next()) |entry| { |
| 254 | switch (entry.type) { | 254 | switch (entry.type) { |
| 255 | .directory => { | 255 | .directory => { |
| 256 | try dir.makeDir(entry.name); | 256 | try dir.makeDir(io, entry.name, .default_dir); |
| 257 | var subdir = try dir.openDir(io, entry.name, .{}); | 257 | var subdir = try dir.openDir(io, entry.name, .{}); |
| 258 | defer subdir.close(io); | 258 | defer subdir.close(io); |
| 259 | const sub_path = try std.fs.path.join(repository.odb.allocator, &.{ current_path, entry.name }); | 259 | const sub_path = try std.fs.path.join(repository.odb.allocator, &.{ current_path, entry.name }); |
| ... | @@ -296,7 +296,7 @@ pub const Repository = struct { | ... | @@ -296,7 +296,7 @@ pub const Repository = struct { |
| 296 | .gitlink => { | 296 | .gitlink => { |
| 297 | // Consistent with git archive behavior, create the directory but | 297 | // Consistent with git archive behavior, create the directory but |
| 298 | // do nothing else | 298 | // do nothing else |
| 299 | try dir.makeDir(entry.name); | 299 | try dir.makeDir(io, entry.name, .default_dir); |
| 300 | }, | 300 | }, |
| 301 | } | 301 | } |
| 302 | } | 302 | } |
src/main.zig+1| ... | @@ -7316,6 +7316,7 @@ fn loadManifest( | ... | @@ -7316,6 +7316,7 @@ fn loadManifest( |
| 7316 | ) !struct { Package.Manifest, Ast } { | 7316 | ) !struct { Package.Manifest, Ast } { |
| 7317 | const manifest_bytes = while (true) { | 7317 | const manifest_bytes = while (true) { |
| 7318 | break options.dir.readFileAllocOptions( | 7318 | break options.dir.readFileAllocOptions( |
| 7319 | io, | ||
| 7319 | Package.Manifest.basename, | 7320 | Package.Manifest.basename, |
| 7320 | arena, | 7321 | arena, |
| 7321 | .limited(Package.Manifest.max_bytes), | 7322 | .limited(Package.Manifest.max_bytes), |
test/src/Cases.zig+3-1| ... | @@ -10,6 +10,7 @@ const ArrayList = std.ArrayList; | ... | @@ -10,6 +10,7 @@ const ArrayList = std.ArrayList; |
| 10 | 10 | ||
| 11 | gpa: Allocator, | 11 | gpa: Allocator, |
| 12 | arena: Allocator, | 12 | arena: Allocator, |
| 13 | io: Io, | ||
| 13 | cases: std.array_list.Managed(Case), | 14 | cases: std.array_list.Managed(Case), |
| 14 | 15 | ||
| 15 | pub const IncrementalCase = struct { | 16 | pub const IncrementalCase = struct { |
| ... | @@ -334,6 +335,7 @@ fn addFromDirInner( | ... | @@ -334,6 +335,7 @@ fn addFromDirInner( |
| 334 | current_file: *[]const u8, | 335 | current_file: *[]const u8, |
| 335 | b: *std.Build, | 336 | b: *std.Build, |
| 336 | ) !void { | 337 | ) !void { |
| 338 | const io = ctx.io; | ||
| 337 | var it = try iterable_dir.walk(ctx.arena); | 339 | var it = try iterable_dir.walk(ctx.arena); |
| 338 | var filenames: ArrayList([]const u8) = .empty; | 340 | var filenames: ArrayList([]const u8) = .empty; |
| 339 | 341 | ||
| ... | @@ -349,7 +351,7 @@ fn addFromDirInner( | ... | @@ -349,7 +351,7 @@ fn addFromDirInner( |
| 349 | current_file.* = filename; | 351 | current_file.* = filename; |
| 350 | 352 | ||
| 351 | const max_file_size = 10 * 1024 * 1024; | 353 | const max_file_size = 10 * 1024 * 1024; |
| 352 | const src = try iterable_dir.readFileAllocOptions(filename, ctx.arena, .limited(max_file_size), .@"1", 0); | 354 | const src = try iterable_dir.readFileAllocOptions(io, filename, ctx.arena, .limited(max_file_size), .@"1", 0); |
| 353 | 355 | ||
| 354 | // Parse the manifest | 356 | // Parse the manifest |
| 355 | var manifest = try TestManifest.parse(ctx.arena, src); | 357 | var manifest = try TestManifest.parse(ctx.arena, src); |
test/standalone/posix/relpaths.zig+11-10| ... | @@ -5,13 +5,14 @@ const builtin = @import("builtin"); | ... | @@ -5,13 +5,14 @@ const builtin = @import("builtin"); |
| 5 | 5 | ||
| 6 | const std = @import("std"); | 6 | const std = @import("std"); |
| 7 | const Io = std.Io; | 7 | const Io = std.Io; |
| 8 | const Allocator = std.mem.Allocator; | ||
| 8 | 9 | ||
| 9 | pub fn main() !void { | 10 | pub fn main() !void { |
| 10 | if (builtin.target.os.tag == .wasi) return; // Can link, but can't change into tmpDir | 11 | if (builtin.target.os.tag == .wasi) return; // Can link, but can't change into tmpDir |
| 11 | 12 | ||
| 12 | var Allocator = std.heap.DebugAllocator(.{}){}; | 13 | var debug_allocator: std.heap.DebugAllocator(.{}) = .init; |
| 13 | const a = Allocator.allocator(); | 14 | const gpa = debug_allocator.allocator(); |
| 14 | defer std.debug.assert(Allocator.deinit() == .ok); | 15 | defer std.debug.assert(debug_allocator.deinit() == .ok); |
| 15 | 16 | ||
| 16 | var threaded: std.Io.Threaded = .init_single_threaded; | 17 | var threaded: std.Io.Threaded = .init_single_threaded; |
| 17 | const io = threaded.io(); | 18 | const io = threaded.io(); |
| ... | @@ -24,22 +25,22 @@ pub fn main() !void { | ... | @@ -24,22 +25,22 @@ pub fn main() !void { |
| 24 | // Want to test relative paths, so cd into the tmpdir for these tests | 25 | // Want to test relative paths, so cd into the tmpdir for these tests |
| 25 | try tmp.dir.setAsCwd(); | 26 | try tmp.dir.setAsCwd(); |
| 26 | 27 | ||
| 27 | try test_symlink(a, tmp); | 28 | try test_symlink(gpa, io, tmp); |
| 28 | try test_link(io, tmp); | 29 | try test_link(io, tmp); |
| 29 | } | 30 | } |
| 30 | 31 | ||
| 31 | fn test_symlink(a: std.mem.Allocator, tmp: std.testing.TmpDir) !void { | 32 | fn test_symlink(gpa: Allocator, io: Io, tmp: std.testing.TmpDir) !void { |
| 32 | const target_name = "symlink-target"; | 33 | const target_name = "symlink-target"; |
| 33 | const symlink_name = "symlinker"; | 34 | const symlink_name = "symlinker"; |
| 34 | 35 | ||
| 35 | // Create the target file | 36 | // Create the target file |
| 36 | try tmp.dir.writeFile(.{ .sub_path = target_name, .data = "nonsense" }); | 37 | try tmp.dir.writeFile(io, .{ .sub_path = target_name, .data = "nonsense" }); |
| 37 | 38 | ||
| 38 | if (builtin.target.os.tag == .windows) { | 39 | if (builtin.target.os.tag == .windows) { |
| 39 | const wtarget_name = try std.unicode.wtf8ToWtf16LeAllocZ(a, target_name); | 40 | const wtarget_name = try std.unicode.wtf8ToWtf16LeAllocZ(gpa, target_name); |
| 40 | const wsymlink_name = try std.unicode.wtf8ToWtf16LeAllocZ(a, symlink_name); | 41 | const wsymlink_name = try std.unicode.wtf8ToWtf16LeAllocZ(gpa, symlink_name); |
| 41 | defer a.free(wtarget_name); | 42 | defer gpa.free(wtarget_name); |
| 42 | defer a.free(wsymlink_name); | 43 | defer gpa.free(wsymlink_name); |
| 43 | 44 | ||
| 44 | std.os.windows.CreateSymbolicLink(tmp.dir.fd, wsymlink_name, wtarget_name, false) catch |err| switch (err) { | 45 | std.os.windows.CreateSymbolicLink(tmp.dir.fd, wsymlink_name, wtarget_name, false) catch |err| switch (err) { |
| 45 | // Symlink requires admin privileges on windows, so this test can legitimately fail. | 46 | // Symlink requires admin privileges on windows, so this test can legitimately fail. |
test/standalone/windows_bat_args/fuzz.zig+7-4| ... | @@ -9,6 +9,9 @@ pub fn main() anyerror!void { | ... | @@ -9,6 +9,9 @@ pub fn main() anyerror!void { |
| 9 | defer std.debug.assert(debug_alloc_inst.deinit() == .ok); | 9 | defer std.debug.assert(debug_alloc_inst.deinit() == .ok); |
| 10 | const gpa = debug_alloc_inst.allocator(); | 10 | const gpa = debug_alloc_inst.allocator(); |
| 11 | 11 | ||
| 12 | var threaded: Io.Threaded = .init(gpa); | ||
| 13 | const io = threaded.io(); | ||
| 14 | |||
| 12 | var it = try std.process.argsWithAllocator(gpa); | 15 | var it = try std.process.argsWithAllocator(gpa); |
| 13 | defer it.deinit(); | 16 | defer it.deinit(); |
| 14 | _ = it.next() orelse unreachable; // skip binary name | 17 | _ = it.next() orelse unreachable; // skip binary name |
| ... | @@ -58,15 +61,15 @@ pub fn main() anyerror!void { | ... | @@ -58,15 +61,15 @@ pub fn main() anyerror!void { |
| 58 | const preamble_len = buf.items.len; | 61 | const preamble_len = buf.items.len; |
| 59 | 62 | ||
| 60 | try buf.appendSlice(gpa, " %*"); | 63 | try buf.appendSlice(gpa, " %*"); |
| 61 | try tmp.dir.writeFile(.{ .sub_path = "args1.bat", .data = buf.items }); | 64 | try tmp.dir.writeFile(io, .{ .sub_path = "args1.bat", .data = buf.items }); |
| 62 | buf.shrinkRetainingCapacity(preamble_len); | 65 | buf.shrinkRetainingCapacity(preamble_len); |
| 63 | 66 | ||
| 64 | try buf.appendSlice(gpa, " %1 %2 %3 %4 %5 %6 %7 %8 %9"); | 67 | try buf.appendSlice(gpa, " %1 %2 %3 %4 %5 %6 %7 %8 %9"); |
| 65 | try tmp.dir.writeFile(.{ .sub_path = "args2.bat", .data = buf.items }); | 68 | try tmp.dir.writeFile(io, .{ .sub_path = "args2.bat", .data = buf.items }); |
| 66 | buf.shrinkRetainingCapacity(preamble_len); | 69 | buf.shrinkRetainingCapacity(preamble_len); |
| 67 | 70 | ||
| 68 | try buf.appendSlice(gpa, " \"%~1\" \"%~2\" \"%~3\" \"%~4\" \"%~5\" \"%~6\" \"%~7\" \"%~8\" \"%~9\""); | 71 | try buf.appendSlice(gpa, " \"%~1\" \"%~2\" \"%~3\" \"%~4\" \"%~5\" \"%~6\" \"%~7\" \"%~8\" \"%~9\""); |
| 69 | try tmp.dir.writeFile(.{ .sub_path = "args3.bat", .data = buf.items }); | 72 | try tmp.dir.writeFile(io, .{ .sub_path = "args3.bat", .data = buf.items }); |
| 70 | buf.shrinkRetainingCapacity(preamble_len); | 73 | buf.shrinkRetainingCapacity(preamble_len); |
| 71 | 74 | ||
| 72 | var i: u64 = 0; | 75 | var i: u64 = 0; |
| ... | @@ -74,7 +77,7 @@ pub fn main() anyerror!void { | ... | @@ -74,7 +77,7 @@ pub fn main() anyerror!void { |
| 74 | const rand_arg = try randomArg(gpa, rand); | 77 | const rand_arg = try randomArg(gpa, rand); |
| 75 | defer gpa.free(rand_arg); | 78 | defer gpa.free(rand_arg); |
| 76 | 79 | ||
| 77 | try testExec(gpa, &.{rand_arg}, null); | 80 | try testExec(gpa, io, &.{rand_arg}, null); |
| 78 | 81 | ||
| 79 | i += 1; | 82 | i += 1; |
| 80 | } | 83 | } |
test/standalone/windows_bat_args/test.zig+6-3| ... | @@ -7,6 +7,9 @@ pub fn main() anyerror!void { | ... | @@ -7,6 +7,9 @@ pub fn main() anyerror!void { |
| 7 | defer std.debug.assert(debug_alloc_inst.deinit() == .ok); | 7 | defer std.debug.assert(debug_alloc_inst.deinit() == .ok); |
| 8 | const gpa = debug_alloc_inst.allocator(); | 8 | const gpa = debug_alloc_inst.allocator(); |
| 9 | 9 | ||
| 10 | var threaded: Io.Threaded = .init(gpa); | ||
| 11 | const io = threaded.io(); | ||
| 12 | |||
| 10 | var it = try std.process.argsWithAllocator(gpa); | 13 | var it = try std.process.argsWithAllocator(gpa); |
| 11 | defer it.deinit(); | 14 | defer it.deinit(); |
| 12 | _ = it.next() orelse unreachable; // skip binary name | 15 | _ = it.next() orelse unreachable; // skip binary name |
| ... | @@ -32,15 +35,15 @@ pub fn main() anyerror!void { | ... | @@ -32,15 +35,15 @@ pub fn main() anyerror!void { |
| 32 | const preamble_len = buf.items.len; | 35 | const preamble_len = buf.items.len; |
| 33 | 36 | ||
| 34 | try buf.appendSlice(gpa, " %*"); | 37 | try buf.appendSlice(gpa, " %*"); |
| 35 | try tmp.dir.writeFile(.{ .sub_path = "args1.bat", .data = buf.items }); | 38 | try tmp.dir.writeFile(io, .{ .sub_path = "args1.bat", .data = buf.items }); |
| 36 | buf.shrinkRetainingCapacity(preamble_len); | 39 | buf.shrinkRetainingCapacity(preamble_len); |
| 37 | 40 | ||
| 38 | try buf.appendSlice(gpa, " %1 %2 %3 %4 %5 %6 %7 %8 %9"); | 41 | try buf.appendSlice(gpa, " %1 %2 %3 %4 %5 %6 %7 %8 %9"); |
| 39 | try tmp.dir.writeFile(.{ .sub_path = "args2.bat", .data = buf.items }); | 42 | try tmp.dir.writeFile(io, .{ .sub_path = "args2.bat", .data = buf.items }); |
| 40 | buf.shrinkRetainingCapacity(preamble_len); | 43 | buf.shrinkRetainingCapacity(preamble_len); |
| 41 | 44 | ||
| 42 | try buf.appendSlice(gpa, " \"%~1\" \"%~2\" \"%~3\" \"%~4\" \"%~5\" \"%~6\" \"%~7\" \"%~8\" \"%~9\""); | 45 | try buf.appendSlice(gpa, " \"%~1\" \"%~2\" \"%~3\" \"%~4\" \"%~5\" \"%~6\" \"%~7\" \"%~8\" \"%~9\""); |
| 43 | try tmp.dir.writeFile(.{ .sub_path = "args3.bat", .data = buf.items }); | 46 | try tmp.dir.writeFile(io, .{ .sub_path = "args3.bat", .data = buf.items }); |
| 44 | buf.shrinkRetainingCapacity(preamble_len); | 47 | buf.shrinkRetainingCapacity(preamble_len); |
| 45 | 48 | ||
| 46 | // Test cases are from https://github.com/rust-lang/rust/blob/master/tests/ui/std/windows-bat-args.rs | 49 | // Test cases are from https://github.com/rust-lang/rust/blob/master/tests/ui/std/windows-bat-args.rs |
test/standalone/windows_spawn/main.zig+4-4| ... | @@ -65,9 +65,9 @@ pub fn main() anyerror!void { | ... | @@ -65,9 +65,9 @@ pub fn main() anyerror!void { |
| 65 | try std.testing.expectError(error.FileNotFound, testExecWithCwd(gpa, io, "hello.exe", "missing_dir", "")); | 65 | try std.testing.expectError(error.FileNotFound, testExecWithCwd(gpa, io, "hello.exe", "missing_dir", "")); |
| 66 | 66 | ||
| 67 | // now add a .bat | 67 | // now add a .bat |
| 68 | try tmp.dir.writeFile(.{ .sub_path = "hello.bat", .data = "@echo hello from bat" }); | 68 | try tmp.dir.writeFile(io, .{ .sub_path = "hello.bat", .data = "@echo hello from bat" }); |
| 69 | // and a .cmd | 69 | // and a .cmd |
| 70 | try tmp.dir.writeFile(.{ .sub_path = "hello.cmd", .data = "@echo hello from cmd" }); | 70 | try tmp.dir.writeFile(io, .{ .sub_path = "hello.cmd", .data = "@echo hello from cmd" }); |
| 71 | 71 | ||
| 72 | // with extension should find the .bat (case insensitive) | 72 | // with extension should find the .bat (case insensitive) |
| 73 | try testExec(gpa, "heLLo.bat", "hello from bat\r\n"); | 73 | try testExec(gpa, "heLLo.bat", "hello from bat\r\n"); |
| ... | @@ -84,7 +84,7 @@ pub fn main() anyerror!void { | ... | @@ -84,7 +84,7 @@ pub fn main() anyerror!void { |
| 84 | // without extension should succeed (case insensitive) | 84 | // without extension should succeed (case insensitive) |
| 85 | try testExec(gpa, "heLLo", "hello from exe\n"); | 85 | try testExec(gpa, "heLLo", "hello from exe\n"); |
| 86 | 86 | ||
| 87 | try tmp.dir.makeDir("something"); | 87 | try tmp.dir.makeDir(io, "something", .default_dir); |
| 88 | try renameExe(tmp.dir, "hello", "something/hello.exe"); | 88 | try renameExe(tmp.dir, "hello", "something/hello.exe"); |
| 89 | 89 | ||
| 90 | const relative_path_no_ext = try std.fs.path.join(gpa, &.{ tmp_relative_path, "something/hello" }); | 90 | const relative_path_no_ext = try std.fs.path.join(gpa, &.{ tmp_relative_path, "something/hello" }); |
| ... | @@ -99,7 +99,7 @@ pub fn main() anyerror!void { | ... | @@ -99,7 +99,7 @@ pub fn main() anyerror!void { |
| 99 | try testExec(gpa, "heLLo", "hello from bat\r\n"); | 99 | try testExec(gpa, "heLLo", "hello from bat\r\n"); |
| 100 | 100 | ||
| 101 | // Add a hello.exe that is not a valid executable | 101 | // Add a hello.exe that is not a valid executable |
| 102 | try tmp.dir.writeFile(.{ .sub_path = "hello.exe", .data = "invalid" }); | 102 | try tmp.dir.writeFile(io, .{ .sub_path = "hello.exe", .data = "invalid" }); |
| 103 | 103 | ||
| 104 | // Trying to execute it with extension will give InvalidExe. This is a special | 104 | // Trying to execute it with extension will give InvalidExe. This is a special |
| 105 | // case for .EXE extensions, where if they ever try to get executed but they are | 105 | // case for .EXE extensions, where if they ever try to get executed but they are |
test/tests.zig+4-4| ... | @@ -2135,12 +2135,12 @@ pub fn addCliTests(b: *std.Build) *Step { | ... | @@ -2135,12 +2135,12 @@ pub fn addCliTests(b: *std.Build) *Step { |
| 2135 | 2135 | ||
| 2136 | var dir = std.Io.Dir.cwd().openDir(io, tmp_path, .{}) catch @panic("unhandled"); | 2136 | var dir = std.Io.Dir.cwd().openDir(io, tmp_path, .{}) catch @panic("unhandled"); |
| 2137 | defer dir.close(io); | 2137 | defer dir.close(io); |
| 2138 | dir.writeFile(.{ .sub_path = "fmt1.zig", .data = unformatted_code }) catch @panic("unhandled"); | 2138 | dir.writeFile(io, .{ .sub_path = "fmt1.zig", .data = unformatted_code }) catch @panic("unhandled"); |
| 2139 | dir.writeFile(.{ .sub_path = "fmt2.zig", .data = unformatted_code }) catch @panic("unhandled"); | 2139 | dir.writeFile(io, .{ .sub_path = "fmt2.zig", .data = unformatted_code }) catch @panic("unhandled"); |
| 2140 | dir.makeDir("subdir") catch @panic("unhandled"); | 2140 | dir.makeDir(io, "subdir", .default_dir) catch @panic("unhandled"); |
| 2141 | var subdir = dir.openDir(io, "subdir", .{}) catch @panic("unhandled"); | 2141 | var subdir = dir.openDir(io, "subdir", .{}) catch @panic("unhandled"); |
| 2142 | defer subdir.close(io); | 2142 | defer subdir.close(io); |
| 2143 | subdir.writeFile(.{ .sub_path = "fmt3.zig", .data = unformatted_code }) catch @panic("unhandled"); | 2143 | subdir.writeFile(io, .{ .sub_path = "fmt3.zig", .data = unformatted_code }) catch @panic("unhandled"); |
| 2144 | 2144 | ||
| 2145 | // Test zig fmt affecting only the appropriate files. | 2145 | // Test zig fmt affecting only the appropriate files. |
| 2146 | const run1 = b.addSystemCommand(&.{ b.graph.zig_exe, "fmt", "fmt1.zig" }); | 2146 | const run1 = b.addSystemCommand(&.{ b.graph.zig_exe, "fmt", "fmt1.zig" }); |