| author | |
| committer | |
| log | 60c386180570d9d3830f8375bbad761cf721c6d3 |
| tree | 4c52ec54a8d706fe16f6251759a3fed2cf16f633 |
| parent | 0ac566892df34daa179548aa32c170eea1794ed7 |
| signature | Commit is signed but in an unrecognized format. |
so that this branch can start passing behavior tests. after the tests
pass, go back and undo the changes in this commit5 files changed, 33 insertions(+), 39 deletions(-)
BRANCH_TODO+4| ... | @@ -1,6 +1,10 @@ | ... | @@ -1,6 +1,10 @@ |
| 1 | Scratch pad for stuff to do before merging master | 1 | Scratch pad for stuff to do before merging master |
| 2 | ================================================= | 2 | ================================================= |
| 3 | 3 | ||
| 4 | restore 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 | |||
| 4 | get an empty file compiling successfully (with no panic fn override) | 8 | get an empty file compiling successfully (with no panic fn override) |
| 5 | 9 | ||
| 6 | uncomment all the behavior tests | 10 | uncomment 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 { |
| 164 | 164 | ||
| 165 | /// Reads a native-endian integer | 165 | /// 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 | } |
| 171 | 171 | ||
| 172 | /// Reads a foreign-endian integer | 172 | /// 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 | } |
| 178 | 178 | ||
| 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 | } |
| 184 | 184 | ||
| 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 | } |
| 190 | 190 | ||
| 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 { |
| 249 | 249 | ||
| 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 | } |
| 256 | 256 | ||
| 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 | } |
| 263 | 263 | ||
| 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 | } |
| 269 | 269 | ||
| 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 | } |
| 275 | 275 | ||
| 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 corresponding | 2487 | /// 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, and | 2488 | /// switch expression, possibly introduce a new error in the error set, and |
| 2489 | /// send a patch to Zig. | 2489 | /// send a patch to Zig. |
| 2490 | pub const unexpected_error_tracing = builtin.mode == .Debug; | 2490 | pub const unexpected_error_tracing = false; |
| 2491 | 2491 | ||
| 2492 | pub const UnexpectedError = error{ | 2492 | pub 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"); |
| 7 | const std = @import("std"); | 7 | const std = @import("std"); |
| 8 | 8 | ||
| 9 | pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn { | 9 | pub 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 zen | 12 | 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"); |
| 2 | const io = std.io; | 2 | const io = std.io; |
| 3 | const builtin = @import("builtin"); | 3 | const builtin = @import("builtin"); |
| 4 | const test_fn_list = builtin.test_functions; | 4 | const test_fn_list = builtin.test_functions; |
| 5 | const warn = std.debug.warn; | ||
| 6 | 5 | ||
| 7 | pub fn main() !void { | 6 | pub 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(); | ||
| 12 | 14 | ||
| 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 | } |