authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-09-21 21:14:01-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-09-21 21:14:01-07:00
logafac5d28951cfd913851094649e8b9f2136694ca
tree85587c7cc735424cc4595c616d3c1a1c7ad3461e
parentead50ea6657d31632f5661f788b035a66c344d13

fix regressed stage2 test harness


9 files changed, 58 insertions(+), 47 deletions(-)

src/Compilation.zig+10-5
......@@ -772,7 +772,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
772772 if (build_options.is_stage1 and comp.bin_file.options.use_llvm) {
773773 try comp.work_queue.writeItem(.{ .stage1_module = {} });
774774 }
775 if (is_exe_or_dyn_lib) {
775 if (is_exe_or_dyn_lib and comp.bin_file.options.use_llvm) {
776776 try comp.work_queue.writeItem(.{ .libcompiler_rt = {} });
777777 if (!comp.bin_file.options.link_libc) {
778778 try comp.work_queue.writeItem(.{ .zig_libc = {} });
......@@ -1128,6 +1128,9 @@ pub fn performAllTheWork(self: *Compilation) error{OutOfMemory}!void {
11281128 };
11291129 },
11301130 .stage1_module => {
1131 if (!build_options.is_stage1)
1132 unreachable;
1133
11311134 self.updateStage1Module() catch |err| {
11321135 fatal("unable to build stage1 zig object: {}", .{@errorName(err)});
11331136 };
......@@ -1685,11 +1688,13 @@ pub fn classifyFileExt(filename: []const u8) FileExt {
16851688test "classifyFileExt" {
16861689 std.testing.expectEqual(FileExt.cpp, classifyFileExt("foo.cc"));
16871690 std.testing.expectEqual(FileExt.unknown, classifyFileExt("foo.nim"));
1688 std.testing.expectEqual(FileExt.so, classifyFileExt("foo.so"));
1689 std.testing.expectEqual(FileExt.so, classifyFileExt("foo.so.1"));
1690 std.testing.expectEqual(FileExt.so, classifyFileExt("foo.so.1.2"));
1691 std.testing.expectEqual(FileExt.so, classifyFileExt("foo.so.1.2.3"));
1691 std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so"));
1692 std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so.1"));
1693 std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so.1.2"));
1694 std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so.1.2.3"));
16921695 std.testing.expectEqual(FileExt.unknown, classifyFileExt("foo.so.1.2.3~"));
1696 std.testing.expectEqual(FileExt.zig, classifyFileExt("foo.zig"));
1697 std.testing.expectEqual(FileExt.zir, classifyFileExt("foo.zir"));
16931698}
16941699
16951700fn haveFramePointer(comp: *Compilation) bool {
src/stage1/stage2.h+1-1
......@@ -29,7 +29,7 @@
2929#endif
3030
3131// ABI warning: the types and declarations in this file must match both those in
32// stage2.cpp and src-self-hosted/stage1.zig.
32// stage2.cpp and src/stage1.zig.
3333
3434// ABI warning
3535enum Error {
src/test.zig+10-4
......@@ -458,9 +458,15 @@ pub const TestContext = struct {
458458 .path = try std.fs.path.join(arena, &[_][]const u8{ bogus_path, "zig-cache" }),
459459 };
460460
461 const tmp_src_path = if (case.extension == .Zig) "test_case.zig" else if (case.extension == .ZIR) "test_case.zir" else unreachable;
462 const root_pkg = try Package.create(allocator, tmp.dir, ".", tmp_src_path);
463 defer root_pkg.destroy(allocator);
461 const tmp_src_path = switch (case.extension) {
462 .Zig => "test_case.zig",
463 .ZIR => "test_case.zir",
464 };
465
466 var root_pkg: Package = .{
467 .root_src_directory = .{ .path = bogus_path, .handle = tmp.dir },
468 .root_src_path = tmp_src_path,
469 };
464470
465471 const ofmt: ?std.builtin.ObjectFormat = if (case.cbe) .c else null;
466472 const bin_name = try std.zig.binNameAlloc(arena, "test_case", target, case.output_mode, null, ofmt);
......@@ -486,7 +492,7 @@ pub const TestContext = struct {
486492 // TODO: support testing optimizations
487493 .optimize_mode = .Debug,
488494 .emit_bin = emit_bin,
489 .root_pkg = root_pkg,
495 .root_pkg = &root_pkg,
490496 .keep_source_files_loaded = true,
491497 .object_format = ofmt,
492498 .is_native_os = case.target.isNativeOs(),
src/windows_sdk.h+4-4
......@@ -16,7 +16,7 @@
1616
1717#include <stddef.h>
1818
19// ABI warning - src-self-hosted/windows_sdk.zig
19// ABI warning - src/windows_sdk.zig
2020struct ZigWindowsSDK {
2121 const char *path10_ptr;
2222 size_t path10_len;
......@@ -34,7 +34,7 @@ struct ZigWindowsSDK {
3434 size_t msvc_lib_dir_len;
3535};
3636
37// ABI warning - src-self-hosted/windows_sdk.zig
37// ABI warning - src/windows_sdk.zig
3838enum ZigFindWindowsSdkError {
3939 ZigFindWindowsSdkErrorNone,
4040 ZigFindWindowsSdkErrorOutOfMemory,
......@@ -42,10 +42,10 @@ enum ZigFindWindowsSdkError {
4242 ZigFindWindowsSdkErrorPathTooLong,
4343};
4444
45// ABI warning - src-self-hosted/windows_sdk.zig
45// ABI warning - src/windows_sdk.zig
4646ZIG_EXTERN_C enum ZigFindWindowsSdkError zig_find_windows_sdk(struct ZigWindowsSDK **out_sdk);
4747
48// ABI warning - src-self-hosted/windows_sdk.zig
48// ABI warning - src/windows_sdk.zig
4949ZIG_EXTERN_C void zig_free_windows_sdk(struct ZigWindowsSDK *sdk);
5050
5151#endif
src/zig_clang.h+1-1
......@@ -14,7 +14,7 @@
1414
1515// ATTENTION: If you modify this file, be sure to update the corresponding
1616// extern function declarations in the self-hosted compiler file
17// src-self-hosted/clang.zig.
17// src/clang.zig.
1818
1919struct ZigClangSourceLocation {
2020 unsigned ID;
test/stage2/cbe.zig+1-1
......@@ -1,5 +1,5 @@
11const std = @import("std");
2const TestContext = @import("../../src-self-hosted/test.zig").TestContext;
2const TestContext = @import("../../src/test.zig").TestContext;
33
44// These tests should work with all platforms, but we're using linux_x64 for
55// now for consistency. Will be expanded eventually.
test/stage2/spu-ii.zig+1-1
......@@ -1,5 +1,5 @@
11const std = @import("std");
2const TestContext = @import("../../src-self-hosted/test.zig").TestContext;
2const TestContext = @import("../../src/test.zig").TestContext;
33
44const spu = std.zig.CrossTarget{
55 .cpu_arch = .spu_2,
test/stage2/test.zig+28-28
......@@ -1,5 +1,5 @@
11const std = @import("std");
2const TestContext = @import("../../src-self-hosted/test.zig").TestContext;
2const TestContext = @import("../../src/test.zig").TestContext;
33
44// Self-hosted has differing levels of support for various architectures. For now we pass explicit
55// target parameters to each test case. At some point we will take this to the next level and have
......@@ -76,7 +76,7 @@ pub fn addCases(ctx: *TestContext) !void {
7676 \\ );
7777 \\ unreachable;
7878 \\}
79 ,
79 ,
8080 "Hello, World!\n",
8181 );
8282 // Now change the message only
......@@ -108,7 +108,7 @@ pub fn addCases(ctx: *TestContext) !void {
108108 \\ );
109109 \\ unreachable;
110110 \\}
111 ,
111 ,
112112 "What is up? This is a longer message that will force the data to be relocated in virtual address space.\n",
113113 );
114114 // Now we print it twice.
......@@ -184,7 +184,7 @@ pub fn addCases(ctx: *TestContext) !void {
184184 \\ );
185185 \\ unreachable;
186186 \\}
187 ,
187 ,
188188 "Hello, World!\n",
189189 );
190190 }
......@@ -219,7 +219,7 @@ pub fn addCases(ctx: *TestContext) !void {
219219 \\ );
220220 \\ unreachable;
221221 \\}
222 ,
222 ,
223223 "Hello, World!\n",
224224 );
225225 }
......@@ -244,7 +244,7 @@ pub fn addCases(ctx: *TestContext) !void {
244244 \\ );
245245 \\ unreachable;
246246 \\}
247 ,
247 ,
248248 "Hello, World!\n",
249249 );
250250 }
......@@ -271,7 +271,7 @@ pub fn addCases(ctx: *TestContext) !void {
271271 \\ );
272272 \\ unreachable;
273273 \\}
274 ,
274 ,
275275 "",
276276 );
277277 }
......@@ -298,7 +298,7 @@ pub fn addCases(ctx: *TestContext) !void {
298298 \\ );
299299 \\ unreachable;
300300 \\}
301 ,
301 ,
302302 "",
303303 );
304304 }
......@@ -329,7 +329,7 @@ pub fn addCases(ctx: *TestContext) !void {
329329 \\ );
330330 \\ unreachable;
331331 \\}
332 ,
332 ,
333333 "",
334334 );
335335
......@@ -362,7 +362,7 @@ pub fn addCases(ctx: *TestContext) !void {
362362 \\ );
363363 \\ unreachable;
364364 \\}
365 ,
365 ,
366366 "",
367367 );
368368
......@@ -398,7 +398,7 @@ pub fn addCases(ctx: *TestContext) !void {
398398 \\ );
399399 \\ unreachable;
400400 \\}
401 ,
401 ,
402402 "",
403403 );
404404
......@@ -435,7 +435,7 @@ pub fn addCases(ctx: *TestContext) !void {
435435 \\ );
436436 \\ unreachable;
437437 \\}
438 ,
438 ,
439439 "",
440440 );
441441
......@@ -465,7 +465,7 @@ pub fn addCases(ctx: *TestContext) !void {
465465 \\ );
466466 \\ unreachable;
467467 \\}
468 ,
468 ,
469469 "",
470470 );
471471
......@@ -499,7 +499,7 @@ pub fn addCases(ctx: *TestContext) !void {
499499 \\ );
500500 \\ unreachable;
501501 \\}
502 ,
502 ,
503503 "",
504504 );
505505
......@@ -523,7 +523,7 @@ pub fn addCases(ctx: *TestContext) !void {
523523 \\ );
524524 \\ unreachable;
525525 \\}
526 ,
526 ,
527527 "",
528528 );
529529
......@@ -562,7 +562,7 @@ pub fn addCases(ctx: *TestContext) !void {
562562 \\ );
563563 \\ unreachable;
564564 \\}
565 ,
565 ,
566566 "hello\nhello\nhello\nhello\n",
567567 );
568568
......@@ -599,7 +599,7 @@ pub fn addCases(ctx: *TestContext) !void {
599599 \\ );
600600 \\ unreachable;
601601 \\}
602 ,
602 ,
603603 "",
604604 );
605605
......@@ -641,7 +641,7 @@ pub fn addCases(ctx: *TestContext) !void {
641641 \\ );
642642 \\ unreachable;
643643 \\}
644 ,
644 ,
645645 "",
646646 );
647647
......@@ -693,7 +693,7 @@ pub fn addCases(ctx: *TestContext) !void {
693693 \\ );
694694 \\ unreachable;
695695 \\}
696 ,
696 ,
697697 "",
698698 );
699699
......@@ -755,7 +755,7 @@ pub fn addCases(ctx: *TestContext) !void {
755755 \\ );
756756 \\ unreachable;
757757 \\}
758 ,
758 ,
759759 "",
760760 );
761761
......@@ -788,7 +788,7 @@ pub fn addCases(ctx: *TestContext) !void {
788788 \\ );
789789 \\ unreachable;
790790 \\}
791 ,
791 ,
792792 "",
793793 );
794794
......@@ -820,7 +820,7 @@ pub fn addCases(ctx: *TestContext) !void {
820820 \\ );
821821 \\ unreachable;
822822 \\}
823 ,
823 ,
824824 "",
825825 );
826826
......@@ -845,7 +845,7 @@ pub fn addCases(ctx: *TestContext) !void {
845845 \\ );
846846 \\ unreachable;
847847 \\}
848 ,
848 ,
849849 "",
850850 );
851851
......@@ -871,7 +871,7 @@ pub fn addCases(ctx: *TestContext) !void {
871871 \\ );
872872 \\ unreachable;
873873 \\}
874 ,
874 ,
875875 "",
876876 );
877877
......@@ -904,7 +904,7 @@ pub fn addCases(ctx: *TestContext) !void {
904904 \\ );
905905 \\ unreachable;
906906 \\}
907 ,
907 ,
908908 "hello\nhello\nhello\nhello\nhello\n",
909909 );
910910 }
......@@ -923,7 +923,7 @@ pub fn addCases(ctx: *TestContext) !void {
923923 \\ bar();
924924 \\}
925925 \\fn bar() void {}
926 ,
926 ,
927927 "42\n",
928928 );
929929
......@@ -941,7 +941,7 @@ pub fn addCases(ctx: *TestContext) !void {
941941 \\ bar();
942942 \\}
943943 \\fn bar() void {}
944 ,
944 ,
945945 "42\n",
946946 );
947947
......@@ -957,7 +957,7 @@ pub fn addCases(ctx: *TestContext) !void {
957957 \\ bar();
958958 \\}
959959 \\fn bar() void {}
960 ,
960 ,
961961 // This is what you get when you take the bits of the IEE-754
962962 // representation of 42.0 and reinterpret them as an unsigned
963963 // integer. Guess that's a bug in wasmtime.
test/stage2/zir.zig+2-2
......@@ -1,5 +1,5 @@
11const std = @import("std");
2const TestContext = @import("../../src-self-hosted/test.zig").TestContext;
2const TestContext = @import("../../src/test.zig").TestContext;
33// self-hosted does not yet support PE executable files / COFF object files
44// or mach-o files. So we do the ZIR transform test cases cross compiling for
55// x86_64-linux.
......@@ -156,7 +156,7 @@ pub fn addCases(ctx: *TestContext) !void {
156156 \\ %0 = call(@a, [])
157157 \\ %1 = returnvoid()
158158 \\})
159 ,
159 ,
160160 &[_][]const u8{
161161 ":18:21: error: message",
162162 },