temporarily simplify test_runner.zig
so that this branch can start passing behavior tests. after the tests pass, go back and undo the changes in this commitmaster
parent
0ac566892d
commit
60c3861805
|
@ -1,6 +1,10 @@
|
|||
Scratch pad for stuff to do before merging master
|
||||
=================================================
|
||||
|
||||
restore test_runner.zig to master branch
|
||||
- also the default panic function and unexpected_error_tracing. see the commit
|
||||
that adds this text to BRANCH_TODO file.
|
||||
|
||||
get an empty file compiling successfully (with no panic fn override)
|
||||
|
||||
uncomment all the behavior tests
|
||||
|
|
20
std/io.zig
20
std/io.zig
|
@ -164,32 +164,32 @@ pub fn InStream(comptime ReadError: type) type {
|
|||
|
||||
/// Reads a native-endian integer
|
||||
pub fn readIntNative(self: *Self, comptime T: type) !T {
|
||||
var bytes: [(T.bit_count + 7 )/ 8]u8 = undefined;
|
||||
var bytes: [(T.bit_count + 7) / 8]u8 = undefined;
|
||||
try self.readNoEof(bytes[0..]);
|
||||
return mem.readIntNative(T, &bytes);
|
||||
}
|
||||
|
||||
/// Reads a foreign-endian integer
|
||||
pub fn readIntForeign(self: *Self, comptime T: type) !T {
|
||||
var bytes: [(T.bit_count + 7 )/ 8]u8 = undefined;
|
||||
var bytes: [(T.bit_count + 7) / 8]u8 = undefined;
|
||||
try self.readNoEof(bytes[0..]);
|
||||
return mem.readIntForeign(T, &bytes);
|
||||
}
|
||||
|
||||
pub fn readIntLittle(self: *Self, comptime T: type) !T {
|
||||
var bytes: [(T.bit_count + 7 )/ 8]u8 = undefined;
|
||||
var bytes: [(T.bit_count + 7) / 8]u8 = undefined;
|
||||
try self.readNoEof(bytes[0..]);
|
||||
return mem.readIntLittle(T, &bytes);
|
||||
}
|
||||
|
||||
pub fn readIntBig(self: *Self, comptime T: type) !T {
|
||||
var bytes: [(T.bit_count + 7 )/ 8]u8 = undefined;
|
||||
var bytes: [(T.bit_count + 7) / 8]u8 = undefined;
|
||||
try self.readNoEof(bytes[0..]);
|
||||
return mem.readIntBig(T, &bytes);
|
||||
}
|
||||
|
||||
pub fn readInt(self: *Self, comptime T: type, endian: builtin.Endian) !T {
|
||||
var bytes: [(T.bit_count + 7 )/ 8]u8 = undefined;
|
||||
var bytes: [(T.bit_count + 7) / 8]u8 = undefined;
|
||||
try self.readNoEof(bytes[0..]);
|
||||
return mem.readInt(T, &bytes, endian);
|
||||
}
|
||||
|
@ -249,32 +249,32 @@ pub fn OutStream(comptime WriteError: type) type {
|
|||
|
||||
/// Write a native-endian integer.
|
||||
pub fn writeIntNative(self: *Self, comptime T: type, value: T) Error!void {
|
||||
var bytes: [(T.bit_count + 7 )/ 8]u8 = undefined;
|
||||
var bytes: [(T.bit_count + 7) / 8]u8 = undefined;
|
||||
mem.writeIntNative(T, &bytes, value);
|
||||
return self.writeFn(self, bytes);
|
||||
}
|
||||
|
||||
/// Write a foreign-endian integer.
|
||||
pub fn writeIntForeign(self: *Self, comptime T: type, value: T) Error!void {
|
||||
var bytes: [(T.bit_count + 7 )/ 8]u8 = undefined;
|
||||
var bytes: [(T.bit_count + 7) / 8]u8 = undefined;
|
||||
mem.writeIntForeign(T, &bytes, value);
|
||||
return self.writeFn(self, bytes);
|
||||
}
|
||||
|
||||
pub fn writeIntLittle(self: *Self, comptime T: type, value: T) Error!void {
|
||||
var bytes: [(T.bit_count + 7 )/ 8]u8 = undefined;
|
||||
var bytes: [(T.bit_count + 7) / 8]u8 = undefined;
|
||||
mem.writeIntLittle(T, &bytes, value);
|
||||
return self.writeFn(self, bytes);
|
||||
}
|
||||
|
||||
pub fn writeIntBig(self: *Self, comptime T: type, value: T) Error!void {
|
||||
var bytes: [(T.bit_count + 7 )/ 8]u8 = undefined;
|
||||
var bytes: [(T.bit_count + 7) / 8]u8 = undefined;
|
||||
mem.writeIntBig(T, &bytes, value);
|
||||
return self.writeFn(self, bytes);
|
||||
}
|
||||
|
||||
pub fn writeInt(self: *Self, comptime T: type, value: T, endian: builtin.Endian) Error!void {
|
||||
var bytes: [(T.bit_count + 7 )/ 8]u8 = undefined;
|
||||
var bytes: [(T.bit_count + 7) / 8]u8 = undefined;
|
||||
mem.writeInt(T, &bytes, value, endian);
|
||||
return self.writeFn(self, bytes);
|
||||
}
|
||||
|
|
|
@ -2487,7 +2487,7 @@ pub fn toPosixPath(file_path: []const u8) ![PATH_MAX]u8 {
|
|||
/// if this happens the fix is to add the error code to the corresponding
|
||||
/// switch expression, possibly introduce a new error in the error set, and
|
||||
/// send a patch to Zig.
|
||||
pub const unexpected_error_tracing = builtin.mode == .Debug;
|
||||
pub const unexpected_error_tracing = false;
|
||||
|
||||
pub const UnexpectedError = error{
|
||||
/// The Operating System returned an undocumented error code.
|
||||
|
|
|
@ -7,24 +7,8 @@ const builtin = @import("builtin");
|
|||
const std = @import("std");
|
||||
|
||||
pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn {
|
||||
@setCold(true);
|
||||
switch (builtin.os) {
|
||||
// TODO: fix panic in zen
|
||||
builtin.Os.freestanding, builtin.Os.zen => {
|
||||
while (true) {}
|
||||
},
|
||||
builtin.Os.wasi => {
|
||||
std.debug.warn("{}", msg);
|
||||
_ = std.os.wasi.proc_raise(std.os.wasi.SIGABRT);
|
||||
unreachable;
|
||||
},
|
||||
builtin.Os.uefi => {
|
||||
// TODO look into using the debug info and logging helpful messages
|
||||
std.os.abort();
|
||||
},
|
||||
else => {
|
||||
const first_trace_addr = @returnAddress();
|
||||
std.debug.panicExtra(error_return_trace, first_trace_addr, "{}", msg);
|
||||
},
|
||||
}
|
||||
const stderr = std.io.getStdErr() catch std.process.abort();
|
||||
stderr.write("panic: ") catch std.process.abort();
|
||||
stderr.write(msg) catch std.process.abort();
|
||||
std.process.abort();
|
||||
}
|
||||
|
|
|
@ -2,28 +2,34 @@ const std = @import("std");
|
|||
const io = std.io;
|
||||
const builtin = @import("builtin");
|
||||
const test_fn_list = builtin.test_functions;
|
||||
const warn = std.debug.warn;
|
||||
|
||||
pub fn main() !void {
|
||||
pub fn main() void {
|
||||
const stderr = io.getStdErr() catch std.process.abort();
|
||||
|
||||
var ok_count: usize = 0;
|
||||
var skip_count: usize = 0;
|
||||
for (test_fn_list) |test_fn, i| {
|
||||
warn("{}/{} {}...", i + 1, test_fn_list.len, test_fn.name);
|
||||
stderr.write("test ") catch std.process.abort();
|
||||
stderr.write(test_fn.name) catch std.process.abort();
|
||||
|
||||
if (test_fn.func()) |_| {
|
||||
ok_count += 1;
|
||||
warn("OK\n");
|
||||
stderr.write("...OK\n") catch std.process.abort();
|
||||
} else |err| switch (err) {
|
||||
error.SkipZigTest => {
|
||||
skip_count += 1;
|
||||
warn("SKIP\n");
|
||||
stderr.write("...SKIP\n") catch std.process.abort();
|
||||
},
|
||||
else => {
|
||||
stderr.write("error: ") catch std.process.abort();
|
||||
stderr.write(@errorName(err)) catch std.process.abort();
|
||||
std.process.abort();
|
||||
},
|
||||
else => return err,
|
||||
}
|
||||
}
|
||||
if (ok_count == test_fn_list.len) {
|
||||
warn("All tests passed.\n");
|
||||
stderr.write("All tests passed.\n") catch std.process.abort();
|
||||
} else {
|
||||
warn("{} passed; {} skipped.\n", ok_count, skip_count);
|
||||
stderr.write("Some tests skipped.\n") catch std.process.abort();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue