| ... | @@ -284,6 +284,7 @@ const Code = struct { | ... | @@ -284,6 +284,7 @@ const Code = struct { |
| 284 | TestSafety: []const u8, | 284 | TestSafety: []const u8, |
| 285 | Exe: ExpectedOutcome, | 285 | Exe: ExpectedOutcome, |
| 286 | Obj: ?[]const u8, | 286 | Obj: ?[]const u8, |
| | 287 | Lib, |
| 287 | }; | 288 | }; |
| 288 | }; | 289 | }; |
| 289 | | 290 | |
| ... | @@ -484,6 +485,8 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc { | ... | @@ -484,6 +485,8 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc { |
| 484 | } else if (mem.eql(u8, code_kind_str, "obj_err")) { | 485 | } else if (mem.eql(u8, code_kind_str, "obj_err")) { |
| 485 | code_kind_id = Code.Id{ .Obj = name }; | 486 | code_kind_id = Code.Id{ .Obj = name }; |
| 486 | name = "test"; | 487 | name = "test"; |
| | 488 | } else if (mem.eql(u8, code_kind_str, "lib")) { |
| | 489 | code_kind_id = Code.Id.Lib; |
| 487 | } else if (mem.eql(u8, code_kind_str, "syntax")) { | 490 | } else if (mem.eql(u8, code_kind_str, "syntax")) { |
| 488 | code_kind_id = Code.Id{ .Obj = null }; | 491 | code_kind_id = Code.Id{ .Obj = null }; |
| 489 | is_inline = true; | 492 | is_inline = true; |
| ... | @@ -1402,6 +1405,42 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var | ... | @@ -1402,6 +1405,42 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var |
| 1402 | try out.print("</code></pre>\n"); | 1405 | try out.print("</code></pre>\n"); |
| 1403 | } | 1406 | } |
| 1404 | }, | 1407 | }, |
| | 1408 | Code.Id.Lib => { |
| | 1409 | var test_args = std.ArrayList([]const u8).init(allocator); |
| | 1410 | defer test_args.deinit(); |
| | 1411 | |
| | 1412 | try test_args.appendSlice([][]const u8{ |
| | 1413 | zig_exe, |
| | 1414 | "build-lib", |
| | 1415 | tmp_source_file_name, |
| | 1416 | "--output-dir", |
| | 1417 | tmp_dir_name, |
| | 1418 | }); |
| | 1419 | try out.print("<pre><code class=\"shell\">$ zig build-lib {}.zig", code.name); |
| | 1420 | switch (code.mode) { |
| | 1421 | builtin.Mode.Debug => {}, |
| | 1422 | builtin.Mode.ReleaseSafe => { |
| | 1423 | try test_args.append("--release-safe"); |
| | 1424 | try out.print(" --release-safe"); |
| | 1425 | }, |
| | 1426 | builtin.Mode.ReleaseFast => { |
| | 1427 | try test_args.append("--release-fast"); |
| | 1428 | try out.print(" --release-fast"); |
| | 1429 | }, |
| | 1430 | builtin.Mode.ReleaseSmall => { |
| | 1431 | try test_args.append("--release-small"); |
| | 1432 | try out.print(" --release-small"); |
| | 1433 | }, |
| | 1434 | } |
| | 1435 | if (code.target_str) |triple| { |
| | 1436 | try test_args.appendSlice([][]const u8{ "-target", triple }); |
| | 1437 | try out.print(" -target {}", triple); |
| | 1438 | } |
| | 1439 | const result = exec(allocator, &env_map, test_args.toSliceConst()) catch return parseError(tokenizer, code.source_token, "test failed"); |
| | 1440 | const escaped_stderr = try escapeHtml(allocator, result.stderr); |
| | 1441 | const escaped_stdout = try escapeHtml(allocator, result.stdout); |
| | 1442 | try out.print("\n{}{}</code></pre>\n", escaped_stderr, escaped_stdout); |
| | 1443 | }, |
| 1405 | } | 1444 | } |
| 1406 | warn("OK\n"); | 1445 | warn("OK\n"); |
| 1407 | }, | 1446 | }, |