Skip to content

Printing with leading newline breaks build test output #15576

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ieeemma opened this issue May 4, 2023 · 1 comment
Closed

Printing with leading newline breaks build test output #15576

ieeemma opened this issue May 4, 2023 · 1 comment
Labels
bug Observed behavior contradicts documented or intended behavior

Comments

@ieeemma
Copy link
Contributor

ieeemma commented May 4, 2023

Zig Version

0.11.0-dev.2969+855493bb8

Steps to Reproduce and Observed Behavior

const std = @import("std");

pub fn main() void {}

test {
    std.debug.print("\nNew line!\n", .{});
    return error.ThisIsAnError;
}

Put this in a blank zig project and run zig build test. This causes this output:

run test: error: 'test_0' failed: New line!
/home/emma/zig-bugs/newline/src/main.zig:7:5: 0x20efe9 in test_0 (test)
    return error.ThisIsAnError;
    ^
run test: error: m

First, the leading newline before the message is stripped, and second an erroneous run test: error: m is printed.

Expected Behavior

Expected an output like this:

run test: error: 'test_0' failed:
New line!
/home/emma/zig-bugs/newline/src/main.zig:7:5: 0x20efe9 in test_0 (test)
    return error.ThisIsAnError;
    ^
@ieeemma ieeemma added the bug Observed behavior contradicts documented or intended behavior label May 4, 2023
@nektro
Copy link
Contributor

nektro commented May 4, 2023

duplicate #15091

since #14647 stdout is reserved for the runner in tests and it expects tests not to print. the issue is a discussion to change (or not) that assumption

@Vexu Vexu closed this as completed May 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

No branches or pull requests

3 participants