aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2020-03-06 18:49:26 -0500
committerAndrew Kelley <andrew@ziglang.org>2020-03-06 18:49:26 -0500
commit7f975bf09f4e6e81d68c9a573ac2e31b997b5816 (patch)
tree1fd5c25caa7321898f45c45e6a42f6623b94c760 /test
parentfa46bcb36864e6616ce4449965063f3b8720f8e1 (diff)
parent231a4b8fde6ff061198c76d02990a471ec48c977 (diff)
downloadzig-7f975bf09f4e6e81d68c9a573ac2e31b997b5816.tar.gz
zig-7f975bf09f4e6e81d68c9a573ac2e31b997b5816.zip
Merge branch 'daurnimator-less-buffer'
Closes #4405 Closes #4656
Diffstat (limited to 'test')
-rw-r--r--test/tests.zig16
1 files changed, 6 insertions, 10 deletions
diff --git a/test/tests.zig b/test/tests.zig
index 9cf4e7bd98..e324902579 100644
--- a/test/tests.zig
+++ b/test/tests.zig
@@ -566,14 +566,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) });
@@ -616,11 +615,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 " };