mirror of
https://github.com/ziglang/zig.git
synced 2025-02-10 06:30:18 +00:00
fix regressed stage2 test harness
This commit is contained in:
parent
ead50ea665
commit
afac5d2895
@ -772,7 +772,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
|
|||||||
if (build_options.is_stage1 and comp.bin_file.options.use_llvm) {
|
if (build_options.is_stage1 and comp.bin_file.options.use_llvm) {
|
||||||
try comp.work_queue.writeItem(.{ .stage1_module = {} });
|
try comp.work_queue.writeItem(.{ .stage1_module = {} });
|
||||||
}
|
}
|
||||||
if (is_exe_or_dyn_lib) {
|
if (is_exe_or_dyn_lib and comp.bin_file.options.use_llvm) {
|
||||||
try comp.work_queue.writeItem(.{ .libcompiler_rt = {} });
|
try comp.work_queue.writeItem(.{ .libcompiler_rt = {} });
|
||||||
if (!comp.bin_file.options.link_libc) {
|
if (!comp.bin_file.options.link_libc) {
|
||||||
try comp.work_queue.writeItem(.{ .zig_libc = {} });
|
try comp.work_queue.writeItem(.{ .zig_libc = {} });
|
||||||
@ -1128,6 +1128,9 @@ pub fn performAllTheWork(self: *Compilation) error{OutOfMemory}!void {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
.stage1_module => {
|
.stage1_module => {
|
||||||
|
if (!build_options.is_stage1)
|
||||||
|
unreachable;
|
||||||
|
|
||||||
self.updateStage1Module() catch |err| {
|
self.updateStage1Module() catch |err| {
|
||||||
fatal("unable to build stage1 zig object: {}", .{@errorName(err)});
|
fatal("unable to build stage1 zig object: {}", .{@errorName(err)});
|
||||||
};
|
};
|
||||||
@ -1685,11 +1688,13 @@ pub fn classifyFileExt(filename: []const u8) FileExt {
|
|||||||
test "classifyFileExt" {
|
test "classifyFileExt" {
|
||||||
std.testing.expectEqual(FileExt.cpp, classifyFileExt("foo.cc"));
|
std.testing.expectEqual(FileExt.cpp, classifyFileExt("foo.cc"));
|
||||||
std.testing.expectEqual(FileExt.unknown, classifyFileExt("foo.nim"));
|
std.testing.expectEqual(FileExt.unknown, classifyFileExt("foo.nim"));
|
||||||
std.testing.expectEqual(FileExt.so, classifyFileExt("foo.so"));
|
std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so"));
|
||||||
std.testing.expectEqual(FileExt.so, classifyFileExt("foo.so.1"));
|
std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so.1"));
|
||||||
std.testing.expectEqual(FileExt.so, classifyFileExt("foo.so.1.2"));
|
std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so.1.2"));
|
||||||
std.testing.expectEqual(FileExt.so, classifyFileExt("foo.so.1.2.3"));
|
std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so.1.2.3"));
|
||||||
std.testing.expectEqual(FileExt.unknown, classifyFileExt("foo.so.1.2.3~"));
|
std.testing.expectEqual(FileExt.unknown, classifyFileExt("foo.so.1.2.3~"));
|
||||||
|
std.testing.expectEqual(FileExt.zig, classifyFileExt("foo.zig"));
|
||||||
|
std.testing.expectEqual(FileExt.zir, classifyFileExt("foo.zir"));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn haveFramePointer(comp: *Compilation) bool {
|
fn haveFramePointer(comp: *Compilation) bool {
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ABI warning: the types and declarations in this file must match both those in
|
// ABI warning: the types and declarations in this file must match both those in
|
||||||
// stage2.cpp and src-self-hosted/stage1.zig.
|
// stage2.cpp and src/stage1.zig.
|
||||||
|
|
||||||
// ABI warning
|
// ABI warning
|
||||||
enum Error {
|
enum Error {
|
||||||
|
14
src/test.zig
14
src/test.zig
@ -458,9 +458,15 @@ pub const TestContext = struct {
|
|||||||
.path = try std.fs.path.join(arena, &[_][]const u8{ bogus_path, "zig-cache" }),
|
.path = try std.fs.path.join(arena, &[_][]const u8{ bogus_path, "zig-cache" }),
|
||||||
};
|
};
|
||||||
|
|
||||||
const tmp_src_path = if (case.extension == .Zig) "test_case.zig" else if (case.extension == .ZIR) "test_case.zir" else unreachable;
|
const tmp_src_path = switch (case.extension) {
|
||||||
const root_pkg = try Package.create(allocator, tmp.dir, ".", tmp_src_path);
|
.Zig => "test_case.zig",
|
||||||
defer root_pkg.destroy(allocator);
|
.ZIR => "test_case.zir",
|
||||||
|
};
|
||||||
|
|
||||||
|
var root_pkg: Package = .{
|
||||||
|
.root_src_directory = .{ .path = bogus_path, .handle = tmp.dir },
|
||||||
|
.root_src_path = tmp_src_path,
|
||||||
|
};
|
||||||
|
|
||||||
const ofmt: ?std.builtin.ObjectFormat = if (case.cbe) .c else null;
|
const ofmt: ?std.builtin.ObjectFormat = if (case.cbe) .c else null;
|
||||||
const bin_name = try std.zig.binNameAlloc(arena, "test_case", target, case.output_mode, null, ofmt);
|
const bin_name = try std.zig.binNameAlloc(arena, "test_case", target, case.output_mode, null, ofmt);
|
||||||
@ -486,7 +492,7 @@ pub const TestContext = struct {
|
|||||||
// TODO: support testing optimizations
|
// TODO: support testing optimizations
|
||||||
.optimize_mode = .Debug,
|
.optimize_mode = .Debug,
|
||||||
.emit_bin = emit_bin,
|
.emit_bin = emit_bin,
|
||||||
.root_pkg = root_pkg,
|
.root_pkg = &root_pkg,
|
||||||
.keep_source_files_loaded = true,
|
.keep_source_files_loaded = true,
|
||||||
.object_format = ofmt,
|
.object_format = ofmt,
|
||||||
.is_native_os = case.target.isNativeOs(),
|
.is_native_os = case.target.isNativeOs(),
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
// ABI warning - src-self-hosted/windows_sdk.zig
|
// ABI warning - src/windows_sdk.zig
|
||||||
struct ZigWindowsSDK {
|
struct ZigWindowsSDK {
|
||||||
const char *path10_ptr;
|
const char *path10_ptr;
|
||||||
size_t path10_len;
|
size_t path10_len;
|
||||||
@ -34,7 +34,7 @@ struct ZigWindowsSDK {
|
|||||||
size_t msvc_lib_dir_len;
|
size_t msvc_lib_dir_len;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ABI warning - src-self-hosted/windows_sdk.zig
|
// ABI warning - src/windows_sdk.zig
|
||||||
enum ZigFindWindowsSdkError {
|
enum ZigFindWindowsSdkError {
|
||||||
ZigFindWindowsSdkErrorNone,
|
ZigFindWindowsSdkErrorNone,
|
||||||
ZigFindWindowsSdkErrorOutOfMemory,
|
ZigFindWindowsSdkErrorOutOfMemory,
|
||||||
@ -42,10 +42,10 @@ enum ZigFindWindowsSdkError {
|
|||||||
ZigFindWindowsSdkErrorPathTooLong,
|
ZigFindWindowsSdkErrorPathTooLong,
|
||||||
};
|
};
|
||||||
|
|
||||||
// ABI warning - src-self-hosted/windows_sdk.zig
|
// ABI warning - src/windows_sdk.zig
|
||||||
ZIG_EXTERN_C enum ZigFindWindowsSdkError zig_find_windows_sdk(struct ZigWindowsSDK **out_sdk);
|
ZIG_EXTERN_C enum ZigFindWindowsSdkError zig_find_windows_sdk(struct ZigWindowsSDK **out_sdk);
|
||||||
|
|
||||||
// ABI warning - src-self-hosted/windows_sdk.zig
|
// ABI warning - src/windows_sdk.zig
|
||||||
ZIG_EXTERN_C void zig_free_windows_sdk(struct ZigWindowsSDK *sdk);
|
ZIG_EXTERN_C void zig_free_windows_sdk(struct ZigWindowsSDK *sdk);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
// ATTENTION: If you modify this file, be sure to update the corresponding
|
// ATTENTION: If you modify this file, be sure to update the corresponding
|
||||||
// extern function declarations in the self-hosted compiler file
|
// extern function declarations in the self-hosted compiler file
|
||||||
// src-self-hosted/clang.zig.
|
// src/clang.zig.
|
||||||
|
|
||||||
struct ZigClangSourceLocation {
|
struct ZigClangSourceLocation {
|
||||||
unsigned ID;
|
unsigned ID;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const TestContext = @import("../../src-self-hosted/test.zig").TestContext;
|
const TestContext = @import("../../src/test.zig").TestContext;
|
||||||
|
|
||||||
// These tests should work with all platforms, but we're using linux_x64 for
|
// These tests should work with all platforms, but we're using linux_x64 for
|
||||||
// now for consistency. Will be expanded eventually.
|
// now for consistency. Will be expanded eventually.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const TestContext = @import("../../src-self-hosted/test.zig").TestContext;
|
const TestContext = @import("../../src/test.zig").TestContext;
|
||||||
|
|
||||||
const spu = std.zig.CrossTarget{
|
const spu = std.zig.CrossTarget{
|
||||||
.cpu_arch = .spu_2,
|
.cpu_arch = .spu_2,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const TestContext = @import("../../src-self-hosted/test.zig").TestContext;
|
const TestContext = @import("../../src/test.zig").TestContext;
|
||||||
|
|
||||||
// Self-hosted has differing levels of support for various architectures. For now we pass explicit
|
// Self-hosted has differing levels of support for various architectures. For now we pass explicit
|
||||||
// target parameters to each test case. At some point we will take this to the next level and have
|
// target parameters to each test case. At some point we will take this to the next level and have
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const TestContext = @import("../../src-self-hosted/test.zig").TestContext;
|
const TestContext = @import("../../src/test.zig").TestContext;
|
||||||
// self-hosted does not yet support PE executable files / COFF object files
|
// self-hosted does not yet support PE executable files / COFF object files
|
||||||
// or mach-o files. So we do the ZIR transform test cases cross compiling for
|
// or mach-o files. So we do the ZIR transform test cases cross compiling for
|
||||||
// x86_64-linux.
|
// x86_64-linux.
|
||||||
|
Loading…
Reference in New Issue
Block a user