Skip to content

Commit c22de91

Browse files
committed
Don't compile tests for deposit/extract when unsupported
1 parent 7a78bb6 commit c22de91

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

test/behavior/deposit_extract_bits.zig

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,20 @@ const mem = std.mem;
44
const expect = std.testing.expect;
55
const expectEqual = std.testing.expectEqual;
66

7-
test "@depositBits" {
7+
fn runnerSupportsPextPdep(int_width: u16) bool {
88
switch (builtin.zig_backend) {
9-
.stage2_llvm, .stage2_x86_64 => {},
10-
else => return error.SkipZigTest, // TODO
9+
.stage2_llvm => return true,
10+
.stage2_x86_64 => {
11+
if (int_width > 64) return false;
12+
if (!builtin.cpu.features.isEnabled(@intFromEnum(std.Target.x86.Feature.bmi2))) return false;
13+
return true;
14+
},
15+
else => return false,
1116
}
17+
}
18+
19+
test "@depositBits" {
20+
if (comptime !runnerSupportsPextPdep(64)) return error.SkipZigTest; // TODO
1221

1322
const S = struct {
1423
pub fn doTheTest() !void {
@@ -37,7 +46,7 @@ test "@depositBits" {
3746
}
3847

3948
test "@depositBits u128" {
40-
if (builtin.zig_backend != .stage2_llvm) return error.SkipZigTest;
49+
if (comptime !runnerSupportsPextPdep(128)) return error.SkipZigTest; // TODO
4150

4251
const S = struct {
4352
pub fn doTheTest() !void {
@@ -56,10 +65,7 @@ test "@depositBits u128" {
5665
}
5766

5867
test "@extractBits" {
59-
switch (builtin.zig_backend) {
60-
.stage2_llvm, .stage2_x86_64 => {},
61-
else => return error.SkipZigTest, // TODO
62-
}
68+
if (comptime !runnerSupportsPextPdep(64)) return error.SkipZigTest; // TODO
6369

6470
const S = struct {
6571
pub fn doTheTest() !void {
@@ -88,7 +94,7 @@ test "@extractBits" {
8894
}
8995

9096
test "@extractBits u128" {
91-
if (builtin.zig_backend != .stage2_llvm) return error.SkipZigTest; // TODO
97+
if (comptime !runnerSupportsPextPdep(128)) return error.SkipZigTest; // TODO
9298

9399
const S = struct {
94100
pub fn doTheTest() !void {

0 commit comments

Comments
 (0)