authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-06-11 14:46:46-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-06-11 14:46:46-04:00
log60c386180570d9d3830f8375bbad761cf721c6d3
tree4c52ec54a8d706fe16f6251759a3fed2cf16f633
parent0ac566892df34daa179548aa32c170eea1794ed7
signature Commit is signed but in an unrecognized format.

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 commit

5 files changed, 33 insertions(+), 39 deletions(-)

BRANCH_TODO+4
...@@ -1,6 +1,10 @@...@@ -1,6 +1,10 @@
1Scratch pad for stuff to do before merging master1Scratch pad for stuff to do before merging master
2=================================================2=================================================
33
4restore test_runner.zig to master branch
5 - also the default panic function and unexpected_error_tracing. see the commit
6 that adds this text to BRANCH_TODO file.
7
4get an empty file compiling successfully (with no panic fn override)8get an empty file compiling successfully (with no panic fn override)
59
6uncomment all the behavior tests10uncomment all the behavior tests
std/io.zig+10-10
...@@ -164,32 +164,32 @@ pub fn InStream(comptime ReadError: type) type {...@@ -164,32 +164,32 @@ pub fn InStream(comptime ReadError: type) type {
164164
165 /// Reads a native-endian integer165 /// Reads a native-endian integer
166 pub fn readIntNative(self: *Self, comptime T: type) !T {166 pub fn readIntNative(self: *Self, comptime T: type) !T {
167 var bytes: [(T.bit_count + 7 )/ 8]u8 = undefined;167 var bytes: [(T.bit_count + 7) / 8]u8 = undefined;
168 try self.readNoEof(bytes[0..]);168 try self.readNoEof(bytes[0..]);
169 return mem.readIntNative(T, &bytes);169 return mem.readIntNative(T, &bytes);
170 }170 }
171171
172 /// Reads a foreign-endian integer172 /// Reads a foreign-endian integer
173 pub fn readIntForeign(self: *Self, comptime T: type) !T {173 pub fn readIntForeign(self: *Self, comptime T: type) !T {
174 var bytes: [(T.bit_count + 7 )/ 8]u8 = undefined;174 var bytes: [(T.bit_count + 7) / 8]u8 = undefined;
175 try self.readNoEof(bytes[0..]);175 try self.readNoEof(bytes[0..]);
176 return mem.readIntForeign(T, &bytes);176 return mem.readIntForeign(T, &bytes);
177 }177 }
178178
179 pub fn readIntLittle(self: *Self, comptime T: type) !T {179 pub fn readIntLittle(self: *Self, comptime T: type) !T {
180 var bytes: [(T.bit_count + 7 )/ 8]u8 = undefined;180 var bytes: [(T.bit_count + 7) / 8]u8 = undefined;
181 try self.readNoEof(bytes[0..]);181 try self.readNoEof(bytes[0..]);
182 return mem.readIntLittle(T, &bytes);182 return mem.readIntLittle(T, &bytes);
183 }183 }
184184
185 pub fn readIntBig(self: *Self, comptime T: type) !T {185 pub fn readIntBig(self: *Self, comptime T: type) !T {
186 var bytes: [(T.bit_count + 7 )/ 8]u8 = undefined;186 var bytes: [(T.bit_count + 7) / 8]u8 = undefined;
187 try self.readNoEof(bytes[0..]);187 try self.readNoEof(bytes[0..]);
188 return mem.readIntBig(T, &bytes);188 return mem.readIntBig(T, &bytes);
189 }189 }
190190
191 pub fn readInt(self: *Self, comptime T: type, endian: builtin.Endian) !T {191 pub fn readInt(self: *Self, comptime T: type, endian: builtin.Endian) !T {
192 var bytes: [(T.bit_count + 7 )/ 8]u8 = undefined;192 var bytes: [(T.bit_count + 7) / 8]u8 = undefined;
193 try self.readNoEof(bytes[0..]);193 try self.readNoEof(bytes[0..]);
194 return mem.readInt(T, &bytes, endian);194 return mem.readInt(T, &bytes, endian);
195 }195 }
...@@ -249,32 +249,32 @@ pub fn OutStream(comptime WriteError: type) type {...@@ -249,32 +249,32 @@ pub fn OutStream(comptime WriteError: type) type {
249249
250 /// Write a native-endian integer.250 /// Write a native-endian integer.
251 pub fn writeIntNative(self: *Self, comptime T: type, value: T) Error!void {251 pub fn writeIntNative(self: *Self, comptime T: type, value: T) Error!void {
252 var bytes: [(T.bit_count + 7 )/ 8]u8 = undefined;252 var bytes: [(T.bit_count + 7) / 8]u8 = undefined;
253 mem.writeIntNative(T, &bytes, value);253 mem.writeIntNative(T, &bytes, value);
254 return self.writeFn(self, bytes);254 return self.writeFn(self, bytes);
255 }255 }
256256
257 /// Write a foreign-endian integer.257 /// Write a foreign-endian integer.
258 pub fn writeIntForeign(self: *Self, comptime T: type, value: T) Error!void {258 pub fn writeIntForeign(self: *Self, comptime T: type, value: T) Error!void {
259 var bytes: [(T.bit_count + 7 )/ 8]u8 = undefined;259 var bytes: [(T.bit_count + 7) / 8]u8 = undefined;
260 mem.writeIntForeign(T, &bytes, value);260 mem.writeIntForeign(T, &bytes, value);
261 return self.writeFn(self, bytes);261 return self.writeFn(self, bytes);
262 }262 }
263263
264 pub fn writeIntLittle(self: *Self, comptime T: type, value: T) Error!void {264 pub fn writeIntLittle(self: *Self, comptime T: type, value: T) Error!void {
265 var bytes: [(T.bit_count + 7 )/ 8]u8 = undefined;265 var bytes: [(T.bit_count + 7) / 8]u8 = undefined;
266 mem.writeIntLittle(T, &bytes, value);266 mem.writeIntLittle(T, &bytes, value);
267 return self.writeFn(self, bytes);267 return self.writeFn(self, bytes);
268 }268 }
269269
270 pub fn writeIntBig(self: *Self, comptime T: type, value: T) Error!void {270 pub fn writeIntBig(self: *Self, comptime T: type, value: T) Error!void {
271 var bytes: [(T.bit_count + 7 )/ 8]u8 = undefined;271 var bytes: [(T.bit_count + 7) / 8]u8 = undefined;
272 mem.writeIntBig(T, &bytes, value);272 mem.writeIntBig(T, &bytes, value);
273 return self.writeFn(self, bytes);273 return self.writeFn(self, bytes);
274 }274 }
275275
276 pub fn writeInt(self: *Self, comptime T: type, value: T, endian: builtin.Endian) Error!void {276 pub fn writeInt(self: *Self, comptime T: type, value: T, endian: builtin.Endian) Error!void {
277 var bytes: [(T.bit_count + 7 )/ 8]u8 = undefined;277 var bytes: [(T.bit_count + 7) / 8]u8 = undefined;
278 mem.writeInt(T, &bytes, value, endian);278 mem.writeInt(T, &bytes, value, endian);
279 return self.writeFn(self, bytes);279 return self.writeFn(self, bytes);
280 }280 }
std/os.zig+1-1
...@@ -2487,7 +2487,7 @@ pub fn toPosixPath(file_path: []const u8) ![PATH_MAX]u8 {...@@ -2487,7 +2487,7 @@ pub fn toPosixPath(file_path: []const u8) ![PATH_MAX]u8 {
2487/// if this happens the fix is to add the error code to the corresponding2487/// if this happens the fix is to add the error code to the corresponding
2488/// switch expression, possibly introduce a new error in the error set, and2488/// switch expression, possibly introduce a new error in the error set, and
2489/// send a patch to Zig.2489/// send a patch to Zig.
2490pub const unexpected_error_tracing = builtin.mode == .Debug;2490pub const unexpected_error_tracing = false;
24912491
2492pub const UnexpectedError = error{2492pub const UnexpectedError = error{
2493 /// The Operating System returned an undocumented error code.2493 /// The Operating System returned an undocumented error code.
std/special/panic.zig+4-20
...@@ -7,24 +7,8 @@ const builtin = @import("builtin");...@@ -7,24 +7,8 @@ const builtin = @import("builtin");
7const std = @import("std");7const std = @import("std");
88
9pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn {9pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn {
10 @setCold(true);10 const stderr = std.io.getStdErr() catch std.process.abort();
11 switch (builtin.os) {11 stderr.write("panic: ") catch std.process.abort();
12 // TODO: fix panic in zen12 stderr.write(msg) catch std.process.abort();
13 builtin.Os.freestanding, builtin.Os.zen => {13 std.process.abort();
14 while (true) {}
15 },
16 builtin.Os.wasi => {
17 std.debug.warn("{}", msg);
18 _ = std.os.wasi.proc_raise(std.os.wasi.SIGABRT);
19 unreachable;
20 },
21 builtin.Os.uefi => {
22 // TODO look into using the debug info and logging helpful messages
23 std.os.abort();
24 },
25 else => {
26 const first_trace_addr = @returnAddress();
27 std.debug.panicExtra(error_return_trace, first_trace_addr, "{}", msg);
28 },
29 }
30}14}
std/special/test_runner.zig+14-8
...@@ -2,28 +2,34 @@ const std = @import("std");...@@ -2,28 +2,34 @@ const std = @import("std");
2const io = std.io;2const io = std.io;
3const builtin = @import("builtin");3const builtin = @import("builtin");
4const test_fn_list = builtin.test_functions;4const test_fn_list = builtin.test_functions;
5const warn = std.debug.warn;
65
7pub fn main() !void {6pub fn main() void {
7 const stderr = io.getStdErr() catch std.process.abort();
8
8 var ok_count: usize = 0;9 var ok_count: usize = 0;
9 var skip_count: usize = 0;10 var skip_count: usize = 0;
10 for (test_fn_list) |test_fn, i| {11 for (test_fn_list) |test_fn, i| {
11 warn("{}/{} {}...", i + 1, test_fn_list.len, test_fn.name);12 stderr.write("test ") catch std.process.abort();
13 stderr.write(test_fn.name) catch std.process.abort();
1214
13 if (test_fn.func()) |_| {15 if (test_fn.func()) |_| {
14 ok_count += 1;16 ok_count += 1;
15 warn("OK\n");17 stderr.write("...OK\n") catch std.process.abort();
16 } else |err| switch (err) {18 } else |err| switch (err) {
17 error.SkipZigTest => {19 error.SkipZigTest => {
18 skip_count += 1;20 skip_count += 1;
19 warn("SKIP\n");21 stderr.write("...SKIP\n") catch std.process.abort();
22 },
23 else => {
24 stderr.write("error: ") catch std.process.abort();
25 stderr.write(@errorName(err)) catch std.process.abort();
26 std.process.abort();
20 },27 },
21 else => return err,
22 }28 }
23 }29 }
24 if (ok_count == test_fn_list.len) {30 if (ok_count == test_fn_list.len) {
25 warn("All tests passed.\n");31 stderr.write("All tests passed.\n") catch std.process.abort();
26 } else {32 } else {
27 warn("{} passed; {} skipped.\n", ok_count, skip_count);33 stderr.write("Some tests skipped.\n") catch std.process.abort();
28 }34 }
29}35}