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
signaturelock-open 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 @@
11Scratch pad for stuff to do before merging master
22=================================================
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
48get an empty file compiling successfully (with no panic fn override)
59
610uncomment all the behavior tests
std/io.zig+10-10
......@@ -164,32 +164,32 @@ pub fn InStream(comptime ReadError: type) type {
164164
165165 /// Reads a native-endian integer
166166 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;
168168 try self.readNoEof(bytes[0..]);
169169 return mem.readIntNative(T, &bytes);
170170 }
171171
172172 /// Reads a foreign-endian integer
173173 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;
175175 try self.readNoEof(bytes[0..]);
176176 return mem.readIntForeign(T, &bytes);
177177 }
178178
179179 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;
181181 try self.readNoEof(bytes[0..]);
182182 return mem.readIntLittle(T, &bytes);
183183 }
184184
185185 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;
187187 try self.readNoEof(bytes[0..]);
188188 return mem.readIntBig(T, &bytes);
189189 }
190190
191191 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;
193193 try self.readNoEof(bytes[0..]);
194194 return mem.readInt(T, &bytes, endian);
195195 }
......@@ -249,32 +249,32 @@ pub fn OutStream(comptime WriteError: type) type {
249249
250250 /// Write a native-endian integer.
251251 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;
253253 mem.writeIntNative(T, &bytes, value);
254254 return self.writeFn(self, bytes);
255255 }
256256
257257 /// Write a foreign-endian integer.
258258 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;
260260 mem.writeIntForeign(T, &bytes, value);
261261 return self.writeFn(self, bytes);
262262 }
263263
264264 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;
266266 mem.writeIntLittle(T, &bytes, value);
267267 return self.writeFn(self, bytes);
268268 }
269269
270270 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;
272272 mem.writeIntBig(T, &bytes, value);
273273 return self.writeFn(self, bytes);
274274 }
275275
276276 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;
278278 mem.writeInt(T, &bytes, value, endian);
279279 return self.writeFn(self, bytes);
280280 }
std/os.zig+1-1
......@@ -2487,7 +2487,7 @@ pub fn toPosixPath(file_path: []const u8) ![PATH_MAX]u8 {
24872487/// if this happens the fix is to add the error code to the corresponding
24882488/// switch expression, possibly introduce a new error in the error set, and
24892489/// send a patch to Zig.
2490pub const unexpected_error_tracing = builtin.mode == .Debug;
2490pub const unexpected_error_tracing = false;
24912491
24922492pub const UnexpectedError = error{
24932493 /// The Operating System returned an undocumented error code.
std/special/panic.zig+4-20
......@@ -7,24 +7,8 @@ const builtin = @import("builtin");
77const std = @import("std");
88
99pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn {
10 @setCold(true);
11 switch (builtin.os) {
12 // TODO: fix panic in zen
13 builtin.Os.freestanding, builtin.Os.zen => {
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 }
10 const stderr = std.io.getStdErr() catch std.process.abort();
11 stderr.write("panic: ") catch std.process.abort();
12 stderr.write(msg) catch std.process.abort();
13 std.process.abort();
3014}
std/special/test_runner.zig+14-8
......@@ -2,28 +2,34 @@ const std = @import("std");
22const io = std.io;
33const builtin = @import("builtin");
44const 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
89 var ok_count: usize = 0;
910 var skip_count: usize = 0;
1011 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
1315 if (test_fn.func()) |_| {
1416 ok_count += 1;
15 warn("OK\n");
17 stderr.write("...OK\n") catch std.process.abort();
1618 } else |err| switch (err) {
1719 error.SkipZigTest => {
1820 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();
2027 },
21 else => return err,
2228 }
2329 }
2430 if (ok_count == test_fn_list.len) {
25 warn("All tests passed.\n");
31 stderr.write("All tests passed.\n") catch std.process.abort();
2632 } else {
27 warn("{} passed; {} skipped.\n", ok_count, skip_count);
33 stderr.write("Some tests skipped.\n") catch std.process.abort();
2834 }
2935}