mirror of
https://github.com/ziglang/zig.git
synced 2024-11-27 07:32:44 +00:00
test: recursively walk dir with tests
Prune incremental tests by moving non-incremental behavior tests to behavior test suite instead.
This commit is contained in:
parent
c8a0d8ff2b
commit
8d5acf7693
@ -1012,18 +1012,18 @@ pub const TestContext = struct {
|
||||
) !void {
|
||||
var cases = std.ArrayList(usize).init(ctx.arena);
|
||||
|
||||
var it = dir.iterate();
|
||||
var it = try dir.walk(ctx.arena);
|
||||
var filenames = std.ArrayList([]const u8).init(ctx.arena);
|
||||
|
||||
while (try it.next()) |entry| {
|
||||
if (entry.kind != .File) continue;
|
||||
|
||||
// Ignore stuff such as .swp files
|
||||
switch (Compilation.classifyFileExt(entry.name)) {
|
||||
switch (Compilation.classifyFileExt(entry.basename)) {
|
||||
.unknown => continue,
|
||||
else => {},
|
||||
}
|
||||
try filenames.append(try ctx.arena.dupe(u8, entry.name));
|
||||
try filenames.append(try ctx.arena.dupe(u8, entry.path));
|
||||
}
|
||||
|
||||
// Sort filenames, so that incremental tests are contiguous and in-order
|
||||
|
@ -69,8 +69,10 @@ test {
|
||||
_ = @import("behavior/bugs/7003.zig");
|
||||
_ = @import("behavior/bugs/7027.zig");
|
||||
_ = @import("behavior/bugs/7047.zig");
|
||||
_ = @import("behavior/bugs/7187.zig");
|
||||
_ = @import("behavior/bugs/7250.zig");
|
||||
_ = @import("behavior/bugs/9584.zig");
|
||||
_ = @import("behavior/bugs/10138.zig");
|
||||
_ = @import("behavior/bugs/10147.zig");
|
||||
_ = @import("behavior/bugs/10970.zig");
|
||||
_ = @import("behavior/bugs/11046.zig");
|
||||
|
@ -1,4 +1,11 @@
|
||||
pub fn main() void {
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
|
||||
test "registers get overwritten when ignoring return" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.cpu.arch != .x86_64 or builtin.os.tag != .linux) return error.SkipZigTest;
|
||||
|
||||
const fd = open();
|
||||
_ = write(fd, "a", 1);
|
||||
_ = close(fd);
|
||||
@ -25,7 +32,3 @@ fn close(fd: usize) usize {
|
||||
unreachable;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// run
|
||||
// target=x86_64-linux
|
||||
//
|
18
test/behavior/bugs/7187.zig
Normal file
18
test/behavior/bugs/7187.zig
Normal file
@ -0,0 +1,18 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const expect = std.testing.expect;
|
||||
|
||||
test "miscompilation with bool return type" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
|
||||
var x: usize = 1;
|
||||
var y: bool = getFalse();
|
||||
_ = y;
|
||||
|
||||
try expect(x == 1);
|
||||
}
|
||||
|
||||
fn getFalse() bool {
|
||||
return false;
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
var array = [_]usize{ 0, 42, 123, 34 };
|
||||
var slice: []const usize = &array;
|
||||
|
||||
pub fn main() void {
|
||||
assert(slice[0] == 0);
|
||||
assert(slice[1] == 42);
|
||||
assert(slice[2] == 123);
|
||||
assert(slice[3] == 34);
|
||||
}
|
||||
|
||||
fn assert(ok: bool) void {
|
||||
if (!ok) unreachable;
|
||||
}
|
||||
|
||||
// run
|
||||
// target=x86_64-linux,x86_64-macos
|
||||
//
|
@ -1,18 +0,0 @@
|
||||
pub fn main() void {
|
||||
var x: usize = 1;
|
||||
var y: bool = getFalse();
|
||||
_ = y;
|
||||
|
||||
assert(x == 1);
|
||||
}
|
||||
|
||||
fn getFalse() bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
fn assert(ok: bool) void {
|
||||
if (!ok) unreachable;
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
@ -1,16 +0,0 @@
|
||||
pub fn main() void {
|
||||
var x: u32 = undefined;
|
||||
set(&x);
|
||||
assert(x == 123);
|
||||
}
|
||||
|
||||
fn set(x: *u32) void {
|
||||
x.* = 123;
|
||||
}
|
||||
|
||||
fn assert(ok: bool) void {
|
||||
if (!ok) unreachable;
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
@ -1,16 +0,0 @@
|
||||
pub fn main() void {
|
||||
var x: u16 = undefined;
|
||||
set(&x);
|
||||
assert(x == 123);
|
||||
}
|
||||
|
||||
fn set(x: *u16) void {
|
||||
x.* = 123;
|
||||
}
|
||||
|
||||
fn assert(ok: bool) void {
|
||||
if (!ok) unreachable;
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
@ -1,16 +0,0 @@
|
||||
pub fn main() void {
|
||||
var x: u8 = undefined;
|
||||
set(&x);
|
||||
assert(x == 123);
|
||||
}
|
||||
|
||||
fn set(x: *u8) void {
|
||||
x.* = 123;
|
||||
}
|
||||
|
||||
fn assert(ok: bool) void {
|
||||
if (!ok) unreachable;
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
@ -1,16 +0,0 @@
|
||||
pub fn main() void {
|
||||
assert(callMe(2) == 24);
|
||||
}
|
||||
|
||||
fn callMe(a: u8) u8 {
|
||||
var b: u8 = a + 10;
|
||||
const c = 2 * b;
|
||||
return c;
|
||||
}
|
||||
|
||||
pub fn assert(ok: bool) void {
|
||||
if (!ok) unreachable; // assertion failure
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
@ -1,16 +0,0 @@
|
||||
pub fn main() void {
|
||||
assert(callMe(2) == 24);
|
||||
}
|
||||
|
||||
fn callMe(a: u16) u16 {
|
||||
var b: u16 = a + 10;
|
||||
const c = 2 * b;
|
||||
return c;
|
||||
}
|
||||
|
||||
pub fn assert(ok: bool) void {
|
||||
if (!ok) unreachable; // assertion failure
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
@ -1,16 +0,0 @@
|
||||
pub fn main() void {
|
||||
assert(callMe(2) == 24);
|
||||
}
|
||||
|
||||
fn callMe(a: u32) u32 {
|
||||
var b: u32 = a + 10;
|
||||
const c = 2 * b;
|
||||
return c;
|
||||
}
|
||||
|
||||
pub fn assert(ok: bool) void {
|
||||
if (!ok) unreachable; // assertion failure
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
@ -1,10 +0,0 @@
|
||||
pub fn main() void {
|
||||
sub(7, 4);
|
||||
}
|
||||
|
||||
fn sub(a: u32, b: u32) void {
|
||||
if (a - b != 3) unreachable;
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
@ -1,10 +0,0 @@
|
||||
pub fn main() void {
|
||||
maybeErr() catch unreachable;
|
||||
}
|
||||
|
||||
fn maybeErr() !void {
|
||||
return;
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
@ -1,11 +0,0 @@
|
||||
pub fn main() void {
|
||||
maybeErr() catch return;
|
||||
unreachable;
|
||||
}
|
||||
|
||||
fn maybeErr() !void {
|
||||
return error.NoWay;
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
Loading…
Reference in New Issue
Block a user