aboutsummaryrefslogtreecommitdiff
path: root/test/tests.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2020-03-07 12:18:41 -0500
committerAndrew Kelley <andrew@ziglang.org>2020-03-07 12:18:41 -0500
commit96c07674fc2293fa040212ab797c05436dc515b1 (patch)
tree67b0bc649f4b4c384259a031269254a90078c0bd /test/tests.zig
parentbc75c0de6c8227d1c01b59c0d63f4d012e05496f (diff)
parentabe7305e169be2047d65f96e6525d3828684f058 (diff)
downloadzig-96c07674fc2293fa040212ab797c05436dc515b1.tar.gz
zig-96c07674fc2293fa040212ab797c05436dc515b1.zip
Merge remote-tracking branch 'origin/master' into llvm10
Diffstat (limited to 'test/tests.zig')
-rw-r--r--test/tests.zig16
1 files changed, 6 insertions, 10 deletions
diff --git a/test/tests.zig b/test/tests.zig
index 0a7f6942ba..a22d3fccea 100644
--- a/test/tests.zig
+++ b/test/tests.zig
@@ -594,14 +594,13 @@ pub const StackTracesContext = struct {
}
child.spawn() catch |err| debug.panic("Unable to spawn {}: {}\n", .{ full_exe_path, @errorName(err) });
- var stdout = Buffer.initNull(b.allocator);
- var stderr = Buffer.initNull(b.allocator);
-
var stdout_file_in_stream = child.stdout.?.inStream();
var stderr_file_in_stream = child.stderr.?.inStream();
- stdout_file_in_stream.stream.readAllBuffer(&stdout, max_stdout_size) catch unreachable;
- stderr_file_in_stream.stream.readAllBuffer(&stderr, max_stdout_size) catch unreachable;
+ const stdout = stdout_file_in_stream.stream.readAllAlloc(b.allocator, max_stdout_size) catch unreachable;
+ defer b.allocator.free(stdout);
+ const stderr = stderr_file_in_stream.stream.readAllAlloc(b.allocator, max_stdout_size) catch unreachable;
+ defer b.allocator.free(stderr);
const term = child.wait() catch |err| {
debug.panic("Unable to spawn {}: {}\n", .{ full_exe_path, @errorName(err) });
@@ -644,11 +643,8 @@ pub const StackTracesContext = struct {
const got: []const u8 = got_result: {
var buf = try Buffer.initSize(b.allocator, 0);
defer buf.deinit();
- const bytes = if (stderr.endsWith("\n"))
- stderr.toSliceConst()[0 .. stderr.len() - 1]
- else
- stderr.toSliceConst()[0..stderr.len()];
- var it = mem.separate(bytes, "\n");
+ if (stderr.len != 0 and stderr[stderr.len - 1] == '\n') stderr = stderr[0 .. stderr.len - 1];
+ var it = mem.separate(stderr, "\n");
process_lines: while (it.next()) |line| {
if (line.len == 0) continue;
const delims = [_][]const u8{ ":", ":", ":", " in " };