| author | |
| committer | |
| log | 691afee786d095fef2a7abed73efa035feef3f4e |
| tree | d8bf25bd5d2c833bd0b277d16228dec4eb6670fd |
| parent | 33e302d67a80fe7d213b4c461dc41c91813db869 |
6 files changed, 61 insertions(+), 50 deletions(-)
doc/langref/bad_default_value.zig+1-1| ... | @@ -17,7 +17,7 @@ pub fn main() !void { | ... | @@ -17,7 +17,7 @@ pub fn main() !void { |
| 17 | .maximum = 0.20, | 17 | .maximum = 0.20, |
| 18 | }; | 18 | }; |
| 19 | const category = threshold.categorize(0.90); | 19 | const category = threshold.categorize(0.90); |
| 20 | try std.fs.File.stdout().writeAll(@tagName(category)); | 20 | std.log.info("category: {t}", .{category}); |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | const std = @import("std"); | 23 | const std = @import("std"); |
doc/langref/hello.zig+11-1| ... | @@ -1,7 +1,17 @@ | ... | @@ -1,7 +1,17 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | 2 | ||
| 3 | // See https://github.com/ziglang/zig/issues/24510 | ||
| 4 | // for the plan to simplify this code. | ||
| 3 | pub fn main() !void { | 5 | pub fn main() !void { |
| 4 | try std.fs.File.stdout().writeAll("Hello, World!\n"); | 6 | var debug_allocator: std.heap.DebugAllocator(.{}) = .init; |
| 7 | defer _ = debug_allocator.deinit(); | ||
| 8 | const gpa = debug_allocator.allocator(); | ||
| 9 | |||
| 10 | var threaded: std.Io.Threaded = .init(gpa, .{}); | ||
| 11 | defer threaded.deinit(); | ||
| 12 | const io = threaded.io(); | ||
| 13 | |||
| 14 | try std.Io.File.stdout().writeStreamingAll(io, "Hello, World!\n"); | ||
| 5 | } | 15 | } |
| 6 | 16 | ||
| 7 | // exe=succeed | 17 | // exe=succeed |
lib/compiler/aro/aro/Compilation.zig+2-1| ... | @@ -1713,7 +1713,8 @@ pub fn initSearchPath(comp: *Compilation, includes: []const Include, verbose: bo | ... | @@ -1713,7 +1713,8 @@ pub fn initSearchPath(comp: *Compilation, includes: []const Include, verbose: bo |
| 1713 | } | 1713 | } |
| 1714 | } | 1714 | } |
| 1715 | fn addToSearchPath(comp: *Compilation, include: Include, verbose: bool) !void { | 1715 | fn addToSearchPath(comp: *Compilation, include: Include, verbose: bool) !void { |
| 1716 | comp.cwd.access(include.path, .{}) catch { | 1716 | const io = comp.io; |
| 1717 | comp.cwd.access(io, include.path, .{}) catch { | ||
| 1717 | if (verbose) { | 1718 | if (verbose) { |
| 1718 | std.debug.print("ignoring nonexistent directory \"{s}\"\n", .{include.path}); | 1719 | std.debug.print("ignoring nonexistent directory \"{s}\"\n", .{include.path}); |
| 1719 | return; | 1720 | return; |
lib/compiler/translate-c/main.zig+9-6| ... | @@ -34,11 +34,14 @@ pub fn main() u8 { | ... | @@ -34,11 +34,14 @@ pub fn main() u8 { |
| 34 | zig_integration = true; | 34 | zig_integration = true; |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | const NO_COLOR = std.zig.EnvVar.NO_COLOR.isSet(); | ||
| 38 | const CLICOLOR_FORCE = std.zig.EnvVar.CLICOLOR_FORCE.isSet(); | ||
| 39 | |||
| 37 | var stderr_buf: [1024]u8 = undefined; | 40 | var stderr_buf: [1024]u8 = undefined; |
| 38 | var stderr = Io.File.stderr().writer(io, &stderr_buf); | 41 | var stderr = Io.File.stderr().writer(io, &stderr_buf); |
| 39 | var diagnostics: aro.Diagnostics = switch (zig_integration) { | 42 | var diagnostics: aro.Diagnostics = switch (zig_integration) { |
| 40 | false => .{ .output = .{ .to_writer = .{ | 43 | false => .{ .output = .{ .to_writer = .{ |
| 41 | .color = .detect(stderr.file), | 44 | .mode = Io.Terminal.Mode.detect(io, stderr.file, NO_COLOR, CLICOLOR_FORCE) catch unreachable, |
| 42 | .writer = &stderr.interface, | 45 | .writer = &stderr.interface, |
| 43 | } } }, | 46 | } } }, |
| 44 | true => .{ .output = .{ .to_list = .{ | 47 | true => .{ .output = .{ .to_list = .{ |
| ... | @@ -69,7 +72,7 @@ pub fn main() u8 { | ... | @@ -69,7 +72,7 @@ pub fn main() u8 { |
| 69 | return 1; | 72 | return 1; |
| 70 | }, | 73 | }, |
| 71 | error.FatalError => if (zig_integration) { | 74 | error.FatalError => if (zig_integration) { |
| 72 | serveErrorBundle(arena, &diagnostics) catch |bundle_err| { | 75 | serveErrorBundle(arena, io, &diagnostics) catch |bundle_err| { |
| 73 | std.debug.print("unable to serve error bundle: {}\n", .{bundle_err}); | 76 | std.debug.print("unable to serve error bundle: {}\n", .{bundle_err}); |
| 74 | if (fast_exit) process.exit(1); | 77 | if (fast_exit) process.exit(1); |
| 75 | return 1; | 78 | return 1; |
| ... | @@ -93,14 +96,14 @@ pub fn main() u8 { | ... | @@ -93,14 +96,14 @@ pub fn main() u8 { |
| 93 | return @intFromBool(comp.diagnostics.errors != 0); | 96 | return @intFromBool(comp.diagnostics.errors != 0); |
| 94 | } | 97 | } |
| 95 | 98 | ||
| 96 | fn serveErrorBundle(arena: std.mem.Allocator, diagnostics: *const aro.Diagnostics) !void { | 99 | fn serveErrorBundle(arena: std.mem.Allocator, io: Io, diagnostics: *const aro.Diagnostics) !void { |
| 97 | const error_bundle = try compiler_util.aroDiagnosticsToErrorBundle( | 100 | const error_bundle = try compiler_util.aroDiagnosticsToErrorBundle( |
| 98 | diagnostics, | 101 | diagnostics, |
| 99 | arena, | 102 | arena, |
| 100 | "translation failure", | 103 | "translation failure", |
| 101 | ); | 104 | ); |
| 102 | var stdout_buffer: [1024]u8 = undefined; | 105 | var stdout_buffer: [1024]u8 = undefined; |
| 103 | var stdout_writer = Io.File.stdout().writer(&stdout_buffer); | 106 | var stdout_writer = Io.File.stdout().writer(io, &stdout_buffer); |
| 104 | var server: std.zig.Server = .{ | 107 | var server: std.zig.Server = .{ |
| 105 | .out = &stdout_writer.interface, | 108 | .out = &stdout_writer.interface, |
| 106 | .in = undefined, | 109 | .in = undefined, |
| ... | @@ -130,13 +133,13 @@ fn translate(d: *aro.Driver, tc: *aro.Toolchain, args: [][:0]u8, zig_integration | ... | @@ -130,13 +133,13 @@ fn translate(d: *aro.Driver, tc: *aro.Toolchain, args: [][:0]u8, zig_integration |
| 130 | args[i] = arg; | 133 | args[i] = arg; |
| 131 | if (mem.eql(u8, arg, "--help")) { | 134 | if (mem.eql(u8, arg, "--help")) { |
| 132 | var stdout_buf: [512]u8 = undefined; | 135 | var stdout_buf: [512]u8 = undefined; |
| 133 | var stdout = Io.File.stdout().writer(&stdout_buf); | 136 | var stdout = Io.File.stdout().writer(io, &stdout_buf); |
| 134 | try stdout.interface.print(usage, .{args[0]}); | 137 | try stdout.interface.print(usage, .{args[0]}); |
| 135 | try stdout.interface.flush(); | 138 | try stdout.interface.flush(); |
| 136 | return; | 139 | return; |
| 137 | } else if (mem.eql(u8, arg, "--version")) { | 140 | } else if (mem.eql(u8, arg, "--version")) { |
| 138 | var stdout_buf: [512]u8 = undefined; | 141 | var stdout_buf: [512]u8 = undefined; |
| 139 | var stdout = Io.File.stdout().writer(&stdout_buf); | 142 | var stdout = Io.File.stdout().writer(io, &stdout_buf); |
| 140 | // TODO add version | 143 | // TODO add version |
| 141 | try stdout.interface.writeAll("0.0.0-dev\n"); | 144 | try stdout.interface.writeAll("0.0.0-dev\n"); |
| 142 | try stdout.interface.flush(); | 145 | try stdout.interface.flush(); |
tools/docgen.zig+14-12| ... | @@ -1,6 +1,8 @@ | ... | @@ -1,6 +1,8 @@ |
| 1 | const std = @import("std"); | ||
| 2 | const builtin = @import("builtin"); | 1 | const builtin = @import("builtin"); |
| 3 | const fs = std.fs; | 2 | |
| 3 | const std = @import("std"); | ||
| 4 | const Io = std.Io; | ||
| 5 | const Dir = std.Io.Dir; | ||
| 4 | const process = std.process; | 6 | const process = std.process; |
| 5 | const Progress = std.Progress; | 7 | const Progress = std.Progress; |
| 6 | const print = std.debug.print; | 8 | const print = std.debug.print; |
| ... | @@ -8,7 +10,6 @@ const mem = std.mem; | ... | @@ -8,7 +10,6 @@ const mem = std.mem; |
| 8 | const testing = std.testing; | 10 | const testing = std.testing; |
| 9 | const Allocator = std.mem.Allocator; | 11 | const Allocator = std.mem.Allocator; |
| 10 | const ArrayList = std.ArrayList; | 12 | const ArrayList = std.ArrayList; |
| 11 | const getExternalExecutor = std.zig.system.getExternalExecutor; | ||
| 12 | const fatal = std.process.fatal; | 13 | const fatal = std.process.fatal; |
| 13 | const Writer = std.Io.Writer; | 14 | const Writer = std.Io.Writer; |
| 14 | 15 | ||
| ... | @@ -49,7 +50,7 @@ pub fn main() !void { | ... | @@ -49,7 +50,7 @@ pub fn main() !void { |
| 49 | while (args_it.next()) |arg| { | 50 | while (args_it.next()) |arg| { |
| 50 | if (mem.startsWith(u8, arg, "-")) { | 51 | if (mem.startsWith(u8, arg, "-")) { |
| 51 | if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) { | 52 | if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) { |
| 52 | try fs.File.stdout().writeAll(usage); | 53 | try Io.File.stdout().writeStreamingAll(io, usage); |
| 53 | process.exit(0); | 54 | process.exit(0); |
| 54 | } else if (mem.eql(u8, arg, "--code-dir")) { | 55 | } else if (mem.eql(u8, arg, "--code-dir")) { |
| 55 | if (args_it.next()) |param| { | 56 | if (args_it.next()) |param| { |
| ... | @@ -72,15 +73,15 @@ pub fn main() !void { | ... | @@ -72,15 +73,15 @@ pub fn main() !void { |
| 72 | const output_path = opt_output orelse fatal("missing output file", .{}); | 73 | const output_path = opt_output orelse fatal("missing output file", .{}); |
| 73 | const code_dir_path = opt_code_dir orelse fatal("missing --code-dir argument", .{}); | 74 | const code_dir_path = opt_code_dir orelse fatal("missing --code-dir argument", .{}); |
| 74 | 75 | ||
| 75 | var in_file = try fs.cwd().openFile(input_path, .{}); | 76 | var in_file = try Dir.cwd().openFile(io, input_path, .{}); |
| 76 | defer in_file.close(io); | 77 | defer in_file.close(io); |
| 77 | 78 | ||
| 78 | var out_file = try fs.cwd().createFile(output_path, .{}); | 79 | var out_file = try Dir.cwd().createFile(io, output_path, .{}); |
| 79 | defer out_file.close(io); | 80 | defer out_file.close(io); |
| 80 | var out_file_buffer: [4096]u8 = undefined; | 81 | var out_file_buffer: [4096]u8 = undefined; |
| 81 | var out_file_writer = out_file.writer(&out_file_buffer); | 82 | var out_file_writer = out_file.writer(io, &out_file_buffer); |
| 82 | 83 | ||
| 83 | var code_dir = try fs.cwd().openDir(code_dir_path, .{}); | 84 | var code_dir = try Dir.cwd().openDir(io, code_dir_path, .{}); |
| 84 | defer code_dir.close(io); | 85 | defer code_dir.close(io); |
| 85 | 86 | ||
| 86 | var in_file_reader = in_file.reader(io, &.{}); | 87 | var in_file_reader = in_file.reader(io, &.{}); |
| ... | @@ -89,7 +90,7 @@ pub fn main() !void { | ... | @@ -89,7 +90,7 @@ pub fn main() !void { |
| 89 | var tokenizer = Tokenizer.init(input_path, input_file_bytes); | 90 | var tokenizer = Tokenizer.init(input_path, input_file_bytes); |
| 90 | var toc = try genToc(arena, &tokenizer); | 91 | var toc = try genToc(arena, &tokenizer); |
| 91 | 92 | ||
| 92 | try genHtml(arena, &tokenizer, &toc, code_dir, &out_file_writer.interface); | 93 | try genHtml(arena, io, &tokenizer, &toc, code_dir, &out_file_writer.interface); |
| 93 | try out_file_writer.end(); | 94 | try out_file_writer.end(); |
| 94 | } | 95 | } |
| 95 | 96 | ||
| ... | @@ -988,9 +989,10 @@ fn printShell(out: *Writer, shell_content: []const u8, escape: bool) !void { | ... | @@ -988,9 +989,10 @@ fn printShell(out: *Writer, shell_content: []const u8, escape: bool) !void { |
| 988 | 989 | ||
| 989 | fn genHtml( | 990 | fn genHtml( |
| 990 | allocator: Allocator, | 991 | allocator: Allocator, |
| 992 | io: Io, | ||
| 991 | tokenizer: *Tokenizer, | 993 | tokenizer: *Tokenizer, |
| 992 | toc: *Toc, | 994 | toc: *Toc, |
| 993 | code_dir: std.fs.Dir, | 995 | code_dir: Dir, |
| 994 | out: *Writer, | 996 | out: *Writer, |
| 995 | ) !void { | 997 | ) !void { |
| 996 | for (toc.nodes) |node| { | 998 | for (toc.nodes) |node| { |
| ... | @@ -1042,11 +1044,11 @@ fn genHtml( | ... | @@ -1042,11 +1044,11 @@ fn genHtml( |
| 1042 | }, | 1044 | }, |
| 1043 | .Code => |code| { | 1045 | .Code => |code| { |
| 1044 | const out_basename = try std.fmt.allocPrint(allocator, "{s}.out", .{ | 1046 | const out_basename = try std.fmt.allocPrint(allocator, "{s}.out", .{ |
| 1045 | fs.path.stem(code.name), | 1047 | Dir.path.stem(code.name), |
| 1046 | }); | 1048 | }); |
| 1047 | defer allocator.free(out_basename); | 1049 | defer allocator.free(out_basename); |
| 1048 | 1050 | ||
| 1049 | const contents = code_dir.readFileAlloc(out_basename, allocator, .limited(std.math.maxInt(u32))) catch |err| { | 1051 | const contents = code_dir.readFileAlloc(io, out_basename, allocator, .limited(std.math.maxInt(u32))) catch |err| { |
| 1050 | return parseError(tokenizer, code.token, "unable to open '{s}': {t}", .{ out_basename, err }); | 1052 | return parseError(tokenizer, code.token, "unable to open '{s}': {t}", .{ out_basename, err }); |
| 1051 | }; | 1053 | }; |
| 1052 | defer allocator.free(contents); | 1054 | defer allocator.free(contents); |
tools/doctest.zig+24-29| ... | @@ -2,10 +2,10 @@ const builtin = @import("builtin"); | ... | @@ -2,10 +2,10 @@ const builtin = @import("builtin"); |
| 2 | 2 | ||
| 3 | const std = @import("std"); | 3 | const std = @import("std"); |
| 4 | const Io = std.Io; | 4 | const Io = std.Io; |
| 5 | const Dir = std.Io.Dir; | ||
| 5 | const Writer = std.Io.Writer; | 6 | const Writer = std.Io.Writer; |
| 6 | const fatal = std.process.fatal; | 7 | const fatal = std.process.fatal; |
| 7 | const mem = std.mem; | 8 | const mem = std.mem; |
| 8 | const fs = std.fs; | ||
| 9 | const process = std.process; | 9 | const process = std.process; |
| 10 | const Allocator = std.mem.Allocator; | 10 | const Allocator = std.mem.Allocator; |
| 11 | const testing = std.testing; | 11 | const testing = std.testing; |
| ... | @@ -53,7 +53,7 @@ pub fn main() !void { | ... | @@ -53,7 +53,7 @@ pub fn main() !void { |
| 53 | while (args_it.next()) |arg| { | 53 | while (args_it.next()) |arg| { |
| 54 | if (mem.startsWith(u8, arg, "-")) { | 54 | if (mem.startsWith(u8, arg, "-")) { |
| 55 | if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) { | 55 | if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) { |
| 56 | try std.fs.File.stdout().writeAll(usage); | 56 | try Io.File.stdout().writeStreamingAll(io, usage); |
| 57 | process.exit(0); | 57 | process.exit(0); |
| 58 | } else if (mem.eql(u8, arg, "-i")) { | 58 | } else if (mem.eql(u8, arg, "-i")) { |
| 59 | opt_input = args_it.next() orelse fatal("expected parameter after -i", .{}); | 59 | opt_input = args_it.next() orelse fatal("expected parameter after -i", .{}); |
| ... | @@ -78,37 +78,37 @@ pub fn main() !void { | ... | @@ -78,37 +78,37 @@ pub fn main() !void { |
| 78 | const zig_path = opt_zig orelse fatal("missing zig compiler path (--zig)", .{}); | 78 | const zig_path = opt_zig orelse fatal("missing zig compiler path (--zig)", .{}); |
| 79 | const cache_root = opt_cache_root orelse fatal("missing cache root path (--cache-root)", .{}); | 79 | const cache_root = opt_cache_root orelse fatal("missing cache root path (--cache-root)", .{}); |
| 80 | 80 | ||
| 81 | const source_bytes = try fs.cwd().readFileAlloc(input_path, arena, .limited(std.math.maxInt(u32))); | 81 | const source_bytes = try Dir.cwd().readFileAlloc(io, input_path, arena, .limited(std.math.maxInt(u32))); |
| 82 | const code = try parseManifest(arena, source_bytes); | 82 | const code = try parseManifest(arena, source_bytes); |
| 83 | const source = stripManifest(source_bytes); | 83 | const source = stripManifest(source_bytes); |
| 84 | 84 | ||
| 85 | const tmp_dir_path = try std.fmt.allocPrint(arena, "{s}/tmp/{x}", .{ | 85 | const tmp_dir_path = try std.fmt.allocPrint(arena, "{s}/tmp/{x}", .{ |
| 86 | cache_root, std.crypto.random.int(u64), | 86 | cache_root, std.crypto.random.int(u64), |
| 87 | }); | 87 | }); |
| 88 | fs.cwd().createDirPath(io, tmp_dir_path) catch |err| | 88 | Dir.cwd().createDirPath(io, tmp_dir_path) catch |err| |
| 89 | fatal("unable to create tmp dir '{s}': {t}", .{ tmp_dir_path, err }); | 89 | fatal("unable to create tmp dir '{s}': {t}", .{ tmp_dir_path, err }); |
| 90 | defer fs.cwd().deleteTree(io, tmp_dir_path) catch |err| std.log.err("unable to delete '{s}': {t}", .{ | 90 | defer Dir.cwd().deleteTree(io, tmp_dir_path) catch |err| std.log.err("unable to delete '{s}': {t}", .{ |
| 91 | tmp_dir_path, err, | 91 | tmp_dir_path, err, |
| 92 | }); | 92 | }); |
| 93 | 93 | ||
| 94 | var out_file = try fs.cwd().createFile(io, output_path, .{}); | 94 | var out_file = try Dir.cwd().createFile(io, output_path, .{}); |
| 95 | defer out_file.close(io); | 95 | defer out_file.close(io); |
| 96 | var out_file_buffer: [4096]u8 = undefined; | 96 | var out_file_buffer: [4096]u8 = undefined; |
| 97 | var out_file_writer = out_file.writer(io, &out_file_buffer); | 97 | var out_file_writer = out_file.writer(io, &out_file_buffer); |
| 98 | 98 | ||
| 99 | const out = &out_file_writer.interface; | 99 | const out = &out_file_writer.interface; |
| 100 | 100 | ||
| 101 | try printSourceBlock(arena, out, source, fs.path.basename(input_path)); | 101 | try printSourceBlock(arena, out, source, Dir.path.basename(input_path)); |
| 102 | try printOutput( | 102 | try printOutput( |
| 103 | arena, | 103 | arena, |
| 104 | io, | 104 | io, |
| 105 | out, | 105 | out, |
| 106 | code, | 106 | code, |
| 107 | tmp_dir_path, | 107 | tmp_dir_path, |
| 108 | try std.fs.path.relative(arena, tmp_dir_path, zig_path), | 108 | try Dir.path.relative(arena, tmp_dir_path, zig_path), |
| 109 | try std.fs.path.relative(arena, tmp_dir_path, input_path), | 109 | try Dir.path.relative(arena, tmp_dir_path, input_path), |
| 110 | if (opt_zig_lib_dir) |zig_lib_dir| | 110 | if (opt_zig_lib_dir) |zig_lib_dir| |
| 111 | try std.fs.path.relative(arena, tmp_dir_path, zig_lib_dir) | 111 | try Dir.path.relative(arena, tmp_dir_path, zig_lib_dir) |
| 112 | else | 112 | else |
| 113 | null, | 113 | null, |
| 114 | ); | 114 | ); |
| ... | @@ -141,7 +141,7 @@ fn printOutput( | ... | @@ -141,7 +141,7 @@ fn printOutput( |
| 141 | defer shell_buffer.deinit(); | 141 | defer shell_buffer.deinit(); |
| 142 | const shell_out = &shell_buffer.writer; | 142 | const shell_out = &shell_buffer.writer; |
| 143 | 143 | ||
| 144 | const code_name = std.fs.path.stem(input_path); | 144 | const code_name = Dir.path.stem(input_path); |
| 145 | 145 | ||
| 146 | switch (code.id) { | 146 | switch (code.id) { |
| 147 | .exe => |expected_outcome| code_block: { | 147 | .exe => |expected_outcome| code_block: { |
| ... | @@ -201,8 +201,7 @@ fn printOutput( | ... | @@ -201,8 +201,7 @@ fn printOutput( |
| 201 | try shell_out.print("\n", .{}); | 201 | try shell_out.print("\n", .{}); |
| 202 | 202 | ||
| 203 | if (expected_outcome == .build_fail) { | 203 | if (expected_outcome == .build_fail) { |
| 204 | const result = try process.Child.run(.{ | 204 | const result = try process.Child.run(arena, io, .{ |
| 205 | .allocator = arena, | ||
| 206 | .argv = build_args.items, | 205 | .argv = build_args.items, |
| 207 | .cwd = tmp_dir_path, | 206 | .cwd = tmp_dir_path, |
| 208 | .env_map = &env_map, | 207 | .env_map = &env_map, |
| ... | @@ -227,7 +226,7 @@ fn printOutput( | ... | @@ -227,7 +226,7 @@ fn printOutput( |
| 227 | try shell_out.writeAll(colored_stderr); | 226 | try shell_out.writeAll(colored_stderr); |
| 228 | break :code_block; | 227 | break :code_block; |
| 229 | } | 228 | } |
| 230 | const exec_result = run(arena, &env_map, tmp_dir_path, build_args.items) catch | 229 | const exec_result = run(arena, io, &env_map, tmp_dir_path, build_args.items) catch |
| 231 | fatal("example failed to compile", .{}); | 230 | fatal("example failed to compile", .{}); |
| 232 | 231 | ||
| 233 | if (code.verbose_cimport) { | 232 | if (code.verbose_cimport) { |
| ... | @@ -258,8 +257,7 @@ fn printOutput( | ... | @@ -258,8 +257,7 @@ fn printOutput( |
| 258 | var exited_with_signal = false; | 257 | var exited_with_signal = false; |
| 259 | 258 | ||
| 260 | const result = if (expected_outcome == .fail) blk: { | 259 | const result = if (expected_outcome == .fail) blk: { |
| 261 | const result = try process.Child.run(.{ | 260 | const result = try process.Child.run(arena, io, .{ |
| 262 | .allocator = arena, | ||
| 263 | .argv = run_args, | 261 | .argv = run_args, |
| 264 | .env_map = &env_map, | 262 | .env_map = &env_map, |
| 265 | .cwd = tmp_dir_path, | 263 | .cwd = tmp_dir_path, |
| ... | @@ -278,7 +276,7 @@ fn printOutput( | ... | @@ -278,7 +276,7 @@ fn printOutput( |
| 278 | } | 276 | } |
| 279 | break :blk result; | 277 | break :blk result; |
| 280 | } else blk: { | 278 | } else blk: { |
| 281 | break :blk run(arena, &env_map, tmp_dir_path, run_args) catch | 279 | break :blk run(arena, io, &env_map, tmp_dir_path, run_args) catch |
| 282 | fatal("example crashed", .{}); | 280 | fatal("example crashed", .{}); |
| 283 | }; | 281 | }; |
| 284 | 282 | ||
| ... | @@ -327,7 +325,7 @@ fn printOutput( | ... | @@ -327,7 +325,7 @@ fn printOutput( |
| 327 | .arch_os_abi = triple, | 325 | .arch_os_abi = triple, |
| 328 | }); | 326 | }); |
| 329 | const target = try std.zig.system.resolveTargetQuery(io, target_query); | 327 | const target = try std.zig.system.resolveTargetQuery(io, target_query); |
| 330 | switch (getExternalExecutor(&host, &target, .{ | 328 | switch (getExternalExecutor(io, &host, &target, .{ |
| 331 | .link_libc = code.link_libc, | 329 | .link_libc = code.link_libc, |
| 332 | })) { | 330 | })) { |
| 333 | .native => {}, | 331 | .native => {}, |
| ... | @@ -347,7 +345,7 @@ fn printOutput( | ... | @@ -347,7 +345,7 @@ fn printOutput( |
| 347 | } | 345 | } |
| 348 | } | 346 | } |
| 349 | 347 | ||
| 350 | const result = run(arena, &env_map, tmp_dir_path, test_args.items) catch | 348 | const result = run(arena, io, &env_map, tmp_dir_path, test_args.items) catch |
| 351 | fatal("test failed", .{}); | 349 | fatal("test failed", .{}); |
| 352 | const escaped_stderr = try escapeHtml(arena, result.stderr); | 350 | const escaped_stderr = try escapeHtml(arena, result.stderr); |
| 353 | const escaped_stdout = try escapeHtml(arena, result.stdout); | 351 | const escaped_stdout = try escapeHtml(arena, result.stdout); |
| ... | @@ -378,8 +376,7 @@ fn printOutput( | ... | @@ -378,8 +376,7 @@ fn printOutput( |
| 378 | try test_args.append("-lc"); | 376 | try test_args.append("-lc"); |
| 379 | try shell_out.print("-lc ", .{}); | 377 | try shell_out.print("-lc ", .{}); |
| 380 | } | 378 | } |
| 381 | const result = try process.Child.run(.{ | 379 | const result = try process.Child.run(arena, io, .{ |
| 382 | .allocator = arena, | ||
| 383 | .argv = test_args.items, | 380 | .argv = test_args.items, |
| 384 | .env_map = &env_map, | 381 | .env_map = &env_map, |
| 385 | .cwd = tmp_dir_path, | 382 | .cwd = tmp_dir_path, |
| ... | @@ -435,8 +432,7 @@ fn printOutput( | ... | @@ -435,8 +432,7 @@ fn printOutput( |
| 435 | }, | 432 | }, |
| 436 | } | 433 | } |
| 437 | 434 | ||
| 438 | const result = try process.Child.run(.{ | 435 | const result = try process.Child.run(arena, io, .{ |
| 439 | .allocator = arena, | ||
| 440 | .argv = test_args.items, | 436 | .argv = test_args.items, |
| 441 | .env_map = &env_map, | 437 | .env_map = &env_map, |
| 442 | .cwd = tmp_dir_path, | 438 | .cwd = tmp_dir_path, |
| ... | @@ -512,8 +508,7 @@ fn printOutput( | ... | @@ -512,8 +508,7 @@ fn printOutput( |
| 512 | } | 508 | } |
| 513 | 509 | ||
| 514 | if (maybe_error_match) |error_match| { | 510 | if (maybe_error_match) |error_match| { |
| 515 | const result = try process.Child.run(.{ | 511 | const result = try process.Child.run(arena, io, .{ |
| 516 | .allocator = arena, | ||
| 517 | .argv = build_args.items, | 512 | .argv = build_args.items, |
| 518 | .env_map = &env_map, | 513 | .env_map = &env_map, |
| 519 | .cwd = tmp_dir_path, | 514 | .cwd = tmp_dir_path, |
| ... | @@ -541,7 +536,7 @@ fn printOutput( | ... | @@ -541,7 +536,7 @@ fn printOutput( |
| 541 | const colored_stderr = try termColor(arena, escaped_stderr); | 536 | const colored_stderr = try termColor(arena, escaped_stderr); |
| 542 | try shell_out.print("\n{s} ", .{colored_stderr}); | 537 | try shell_out.print("\n{s} ", .{colored_stderr}); |
| 543 | } else { | 538 | } else { |
| 544 | _ = run(arena, &env_map, tmp_dir_path, build_args.items) catch fatal("example failed to compile", .{}); | 539 | _ = run(arena, io, &env_map, tmp_dir_path, build_args.items) catch fatal("example failed to compile", .{}); |
| 545 | } | 540 | } |
| 546 | try shell_out.writeAll("\n"); | 541 | try shell_out.writeAll("\n"); |
| 547 | }, | 542 | }, |
| ... | @@ -600,7 +595,7 @@ fn printOutput( | ... | @@ -600,7 +595,7 @@ fn printOutput( |
| 600 | try test_args.append(option); | 595 | try test_args.append(option); |
| 601 | try shell_out.print("{s} ", .{option}); | 596 | try shell_out.print("{s} ", .{option}); |
| 602 | } | 597 | } |
| 603 | const result = run(arena, &env_map, tmp_dir_path, test_args.items) catch fatal("test failed", .{}); | 598 | const result = run(arena, io, &env_map, tmp_dir_path, test_args.items) catch fatal("test failed", .{}); |
| 604 | const escaped_stderr = try escapeHtml(arena, result.stderr); | 599 | const escaped_stderr = try escapeHtml(arena, result.stderr); |
| 605 | const escaped_stdout = try escapeHtml(arena, result.stdout); | 600 | const escaped_stdout = try escapeHtml(arena, result.stdout); |
| 606 | try shell_out.print("\n{s}{s}\n", .{ escaped_stderr, escaped_stdout }); | 601 | try shell_out.print("\n{s}{s}\n", .{ escaped_stderr, escaped_stdout }); |
| ... | @@ -1132,12 +1127,12 @@ fn in(slice: []const u8, number: u8) bool { | ... | @@ -1132,12 +1127,12 @@ fn in(slice: []const u8, number: u8) bool { |
| 1132 | 1127 | ||
| 1133 | fn run( | 1128 | fn run( |
| 1134 | allocator: Allocator, | 1129 | allocator: Allocator, |
| 1130 | io: Io, | ||
| 1135 | env_map: *process.EnvMap, | 1131 | env_map: *process.EnvMap, |
| 1136 | cwd: []const u8, | 1132 | cwd: []const u8, |
| 1137 | args: []const []const u8, | 1133 | args: []const []const u8, |
| 1138 | ) !process.Child.RunResult { | 1134 | ) !process.Child.RunResult { |
| 1139 | const result = try process.Child.run(.{ | 1135 | const result = try process.Child.run(allocator, io, .{ |
| 1140 | .allocator = allocator, | ||
| 1141 | .argv = args, | 1136 | .argv = args, |
| 1142 | .env_map = env_map, | 1137 | .env_map = env_map, |
| 1143 | .cwd = cwd, | 1138 | .cwd = cwd, |