mirror of
https://github.com/ziglang/zig.git
synced 2024-11-13 23:52:57 +00:00
c_import: extract behavior tests that use @cImport
This introduces the new test step `test-c-import`, and removes the ability of the behavior tests to `@cImport` paths relative to `test`. This allows the behavior tests to be run without translate c.
This commit is contained in:
parent
556db2ca36
commit
2291560424
17
build.zig
17
build.zig
@ -471,6 +471,7 @@ pub fn build(b: *std.Build) !void {
|
||||
.name = "behavior",
|
||||
.desc = "Run the behavior tests",
|
||||
.optimize_modes = optimization_modes,
|
||||
.include_paths = &.{},
|
||||
.skip_single_threaded = skip_single_threaded,
|
||||
.skip_non_native = skip_non_native,
|
||||
.skip_cross_glibc = skip_cross_glibc,
|
||||
@ -478,12 +479,26 @@ pub fn build(b: *std.Build) !void {
|
||||
.max_rss = 1 * 1024 * 1024 * 1024,
|
||||
}));
|
||||
|
||||
test_step.dependOn(tests.addModuleTests(b, .{
|
||||
.test_filter = test_filter,
|
||||
.root_src = "test/c_import.zig",
|
||||
.name = "c-import",
|
||||
.desc = "Run the @cImport tests",
|
||||
.optimize_modes = optimization_modes,
|
||||
.include_paths = &.{"test/c_import"},
|
||||
.skip_single_threaded = true,
|
||||
.skip_non_native = skip_non_native,
|
||||
.skip_cross_glibc = skip_cross_glibc,
|
||||
.skip_libc = skip_libc,
|
||||
}));
|
||||
|
||||
test_step.dependOn(tests.addModuleTests(b, .{
|
||||
.test_filter = test_filter,
|
||||
.root_src = "lib/compiler_rt.zig",
|
||||
.name = "compiler-rt",
|
||||
.desc = "Run the compiler_rt tests",
|
||||
.optimize_modes = optimization_modes,
|
||||
.include_paths = &.{},
|
||||
.skip_single_threaded = true,
|
||||
.skip_non_native = skip_non_native,
|
||||
.skip_cross_glibc = skip_cross_glibc,
|
||||
@ -496,6 +511,7 @@ pub fn build(b: *std.Build) !void {
|
||||
.name = "universal-libc",
|
||||
.desc = "Run the universal libc tests",
|
||||
.optimize_modes = optimization_modes,
|
||||
.include_paths = &.{},
|
||||
.skip_single_threaded = true,
|
||||
.skip_non_native = skip_non_native,
|
||||
.skip_cross_glibc = skip_cross_glibc,
|
||||
@ -527,6 +543,7 @@ pub fn build(b: *std.Build) !void {
|
||||
.name = "std",
|
||||
.desc = "Run the standard library tests",
|
||||
.optimize_modes = optimization_modes,
|
||||
.include_paths = &.{},
|
||||
.skip_single_threaded = skip_single_threaded,
|
||||
.skip_non_native = skip_non_native,
|
||||
.skip_cross_glibc = skip_cross_glibc,
|
||||
|
@ -99,11 +99,11 @@ unset CXX
|
||||
|
||||
ninja install
|
||||
|
||||
stage3/bin/zig test ../test/behavior.zig -I../test
|
||||
stage3/bin/zig test ../test/behavior.zig
|
||||
stage3/bin/zig build -p stage4 \
|
||||
-Dstatic-llvm \
|
||||
-Dtarget=native-native-musl \
|
||||
-Dno-lib \
|
||||
--search-prefix "$PREFIX" \
|
||||
--zig-lib-dir "$(pwd)/../lib"
|
||||
stage4/bin/zig test ../test/behavior.zig -I../test
|
||||
stage4/bin/zig test ../test/behavior.zig
|
||||
|
@ -99,11 +99,11 @@ unset CXX
|
||||
|
||||
ninja install
|
||||
|
||||
stage3/bin/zig test ../test/behavior.zig -I../test
|
||||
stage3/bin/zig test ../test/behavior.zig
|
||||
stage3/bin/zig build -p stage4 \
|
||||
-Dstatic-llvm \
|
||||
-Dtarget=native-native-musl \
|
||||
-Dno-lib \
|
||||
--search-prefix "$PREFIX" \
|
||||
--zig-lib-dir "$(pwd)/../lib"
|
||||
stage4/bin/zig test ../test/behavior.zig -I../test
|
||||
stage4/bin/zig test ../test/behavior.zig
|
||||
|
@ -25,8 +25,7 @@ rm -rf zig-out
|
||||
cc -o bootstrap bootstrap.c
|
||||
./bootstrap
|
||||
./zig2 build -Dno-lib
|
||||
# In order to run these behavior tests we need to move the `@cImport` ones to somewhere else.
|
||||
# ./zig-out/bin/zig test test/behavior.zig
|
||||
./zig-out/bin/zig test test/behavior.zig
|
||||
|
||||
export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
|
||||
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
|
||||
@ -108,11 +107,11 @@ unset CXX
|
||||
|
||||
ninja install
|
||||
|
||||
stage3/bin/zig test ../test/behavior.zig -I../test
|
||||
stage3/bin/zig test ../test/behavior.zig
|
||||
stage3/bin/zig build -p stage4 \
|
||||
-Dstatic-llvm \
|
||||
-Dtarget=native-native-musl \
|
||||
-Dno-lib \
|
||||
--search-prefix "$PREFIX" \
|
||||
--zig-lib-dir "$(pwd)/../lib"
|
||||
stage4/bin/zig test ../test/behavior.zig -I../test
|
||||
stage4/bin/zig test ../test/behavior.zig
|
||||
|
@ -25,8 +25,7 @@ rm -rf zig-out
|
||||
cc -o bootstrap bootstrap.c
|
||||
./bootstrap
|
||||
./zig2 build -Dno-lib
|
||||
# In order to run these behavior tests we need to move the `@cImport` ones to somewhere else.
|
||||
# ./zig-out/bin/zig test test/behavior.zig
|
||||
./zig-out/bin/zig test test/behavior.zig
|
||||
|
||||
export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
|
||||
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
|
||||
@ -125,11 +124,11 @@ unset CXX
|
||||
|
||||
ninja install
|
||||
|
||||
stage3/bin/zig test ../test/behavior.zig -I../test
|
||||
stage3/bin/zig test ../test/behavior.zig
|
||||
stage3/bin/zig build -p stage4 \
|
||||
-Dstatic-llvm \
|
||||
-Dtarget=native-native-musl \
|
||||
-Dno-lib \
|
||||
--search-prefix "$PREFIX" \
|
||||
--zig-lib-dir "$(pwd)/../lib"
|
||||
stage4/bin/zig test ../test/behavior.zig -I../test
|
||||
stage4/bin/zig test ../test/behavior.zig
|
||||
|
@ -31,8 +31,7 @@ rm -rf zig-out
|
||||
cc -o bootstrap bootstrap.c
|
||||
./bootstrap
|
||||
./zig2 build -Dno-lib
|
||||
# In order to run these behavior tests we need to move the `@cImport` ones to somewhere else.
|
||||
# ./zig-out/bin/zig test test/behavior.zig
|
||||
./zig-out/bin/zig test test/behavior.zig
|
||||
|
||||
rm -rf build
|
||||
mkdir build
|
||||
|
@ -66,8 +66,6 @@ Write-Output "Build x86_64-windows-msvc behavior tests using the C backend..."
|
||||
& "stage3-debug\bin\zig.exe" test `
|
||||
..\test\behavior.zig `
|
||||
--zig-lib-dir "$ZIG_LIB_DIR" `
|
||||
-I..\test `
|
||||
-I..\lib `
|
||||
-ofmt=c `
|
||||
-femit-bin="test-x86_64-windows-msvc.c" `
|
||||
--test-no-exec `
|
||||
|
@ -65,8 +65,6 @@ Write-Output "Build x86_64-windows-msvc behavior tests using the C backend..."
|
||||
& "stage3-release\bin\zig.exe" test `
|
||||
..\test\behavior.zig `
|
||||
--zig-lib-dir "$ZIG_LIB_DIR" `
|
||||
-I..\test `
|
||||
-I..\lib `
|
||||
-ofmt=c `
|
||||
-femit-bin="test-x86_64-windows-msvc.c" `
|
||||
--test-no-exec `
|
||||
|
@ -14,7 +14,6 @@ test {
|
||||
_ = @import("behavior/bool.zig");
|
||||
_ = @import("behavior/byteswap.zig");
|
||||
_ = @import("behavior/byval_arg_var.zig");
|
||||
_ = @import("behavior/c_char_signedness.zig");
|
||||
_ = @import("behavior/call.zig");
|
||||
_ = @import("behavior/call_tail.zig");
|
||||
_ = @import("behavior/cast.zig");
|
||||
@ -92,7 +91,6 @@ test {
|
||||
_ = @import("behavior/switch_prong_implicit_cast.zig");
|
||||
_ = @import("behavior/this.zig");
|
||||
_ = @import("behavior/threadlocal.zig");
|
||||
_ = @import("behavior/translate_c_macros.zig");
|
||||
_ = @import("behavior/truncate.zig");
|
||||
_ = @import("behavior/try.zig");
|
||||
_ = @import("behavior/tuple.zig");
|
||||
|
4
test/c_import.zig
Normal file
4
test/c_import.zig
Normal file
@ -0,0 +1,4 @@
|
||||
test {
|
||||
_ = @import("c_import/c_char_signedness.zig");
|
||||
_ = @import("c_import/macros.zig");
|
||||
}
|
@ -4,8 +4,8 @@ const expect = std.testing.expect;
|
||||
const expectEqual = std.testing.expectEqual;
|
||||
const expectEqualStrings = std.testing.expectEqualStrings;
|
||||
|
||||
const h = @cImport(@cInclude("behavior/translate_c_macros.h"));
|
||||
const latin1 = @cImport(@cInclude("behavior/translate_c_macros_not_utf8.h"));
|
||||
const h = @cImport(@cInclude("macros.h"));
|
||||
const latin1 = @cImport(@cInclude("macros_not_utf8.h"));
|
||||
|
||||
test "casting to void with a macro" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
@ -1037,6 +1037,7 @@ const ModuleTestOptions = struct {
|
||||
name: []const u8,
|
||||
desc: []const u8,
|
||||
optimize_modes: []const OptimizeMode,
|
||||
include_paths: []const []const u8,
|
||||
skip_single_threaded: bool,
|
||||
skip_non_native: bool,
|
||||
skip_cross_glibc: bool,
|
||||
@ -1140,7 +1141,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
|
||||
const use_lld = if (test_target.use_lld == false) "-no-lld" else "";
|
||||
const use_pic = if (test_target.pic == true) "-pic" else "";
|
||||
|
||||
these_tests.addIncludePath(.{ .path = "test" });
|
||||
for (options.include_paths) |include_path| these_tests.addIncludePath(.{ .path = include_path });
|
||||
|
||||
if (target.os.tag == .wasi) {
|
||||
// WASI's default stack size can be too small for some big tests.
|
||||
|
Loading…
Reference in New Issue
Block a user