| ... | ... | @@ -1042,22 +1042,18 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var |
| 1042 | 1042 | switch (code.id) { |
| 1043 | 1043 | Code.Id.Exe => |expected_outcome| code_block: { |
| 1044 | 1044 | const name_plus_bin_ext = try std.fmt.allocPrint(allocator, "{}{}", code.name, exe_ext); |
| 1045 | | const tmp_bin_file_name = try fs.path.join( |
| 1046 | | allocator, |
| 1047 | | [_][]const u8{ tmp_dir_name, name_plus_bin_ext }, |
| 1048 | | ); |
| 1049 | 1045 | var build_args = std.ArrayList([]const u8).init(allocator); |
| 1050 | 1046 | defer build_args.deinit(); |
| 1051 | 1047 | try build_args.appendSlice([_][]const u8{ |
| 1052 | 1048 | zig_exe, |
| 1053 | 1049 | "build-exe", |
| 1054 | 1050 | tmp_source_file_name, |
| 1055 | | "--output-dir", |
| 1056 | | tmp_dir_name, |
| 1057 | 1051 | "--name", |
| 1058 | 1052 | code.name, |
| 1059 | 1053 | "--color", |
| 1060 | 1054 | "on", |
| 1055 | "--cache", |
| 1056 | "on", |
| 1061 | 1057 | }); |
| 1062 | 1058 | try out.print("<pre><code class=\"shell\">$ zig build-exe {}.zig", code.name); |
| 1063 | 1059 | switch (code.mode) { |
| ... | ... | @@ -1128,7 +1124,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var |
| 1128 | 1124 | try out.print("\n{}</code></pre>\n", colored_stderr); |
| 1129 | 1125 | break :code_block; |
| 1130 | 1126 | } |
| 1131 | | _ = exec(allocator, &env_map, build_args.toSliceConst()) catch return parseError(tokenizer, code.source_token, "example failed to compile"); |
| 1127 | const exec_result = exec(allocator, &env_map, build_args.toSliceConst()) catch return parseError(tokenizer, code.source_token, "example failed to compile"); |
| 1132 | 1128 | |
| 1133 | 1129 | if (code.target_str) |triple| { |
| 1134 | 1130 | if (mem.startsWith(u8, triple, "wasm32") or |
| ... | ... | @@ -1141,7 +1137,8 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var |
| 1141 | 1137 | } |
| 1142 | 1138 | } |
| 1143 | 1139 | |
| 1144 | | const run_args = [_][]const u8{tmp_bin_file_name}; |
| 1140 | const path_to_exe = mem.trim(u8, exec_result.stdout, " \r\n"); |
| 1141 | const run_args = [_][]const u8{path_to_exe}; |
| 1145 | 1142 | |
| 1146 | 1143 | const result = if (expected_outcome == ExpectedOutcome.Fail) blk: { |
| 1147 | 1144 | const result = try ChildProcess.exec(allocator, run_args, null, &env_map, max_doc_file_size); |
| ... | ... | @@ -1179,8 +1176,8 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var |
| 1179 | 1176 | zig_exe, |
| 1180 | 1177 | "test", |
| 1181 | 1178 | tmp_source_file_name, |
| 1182 | | "--output-dir", |
| 1183 | | tmp_dir_name, |
| 1179 | "--cache", |
| 1180 | "on", |
| 1184 | 1181 | }); |
| 1185 | 1182 | try out.print("<pre><code class=\"shell\">$ zig test {}.zig", code.name); |
| 1186 | 1183 | switch (code.mode) { |