Skip to content
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

[test] Output of subprocesses is lost when not using RUST_TEST_NOCAPTURE=1 #42814

Closed
Ekleog opened this issue Jun 21, 2017 · 2 comments
Closed
Labels
A-libtest Area: `#[test]` / the `test` library T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@Ekleog
Copy link

Ekleog commented Jun 21, 2017

With the following example:

extern crate libc;

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn it_works() {
        match unsafe { libc::fork() } {
            0 => {
                println!("Some stdout");
                unsafe { libc::exit(0) };
            },
            child => {
                let mut status = 0;
                unsafe { libc::waitpid(child, &mut status, 0) };
                println!("Child exited with exit code {}", status);
                panic!("Trigger a failure so that captured output is displayed");
            },
        }
    }
}

Running with cargo test doesn't show the Some stdout text, while running with RUST_TEST_NOCAPTURE=1 cargo test outputs it. Thus some output is lost when not running in RUST_TEST_NOCAPTURE=1 mode, which makes some complex tests less convenient to debug.

@Mark-Simulacrum Mark-Simulacrum added A-libtest Area: `#[test]` / the `test` library T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Jun 23, 2017
@alexcrichton
Copy link
Member

I believe this is a dupe of #12309, but thanks for the report!

@Ekleog
Copy link
Author

Ekleog commented Jun 25, 2017

Oh indeed it's a subset of this other bug (which I didn't manage to find, likely because the example uses no-longer-existent std::task, I guess).

Sorry for the noise and thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-libtest Area: `#[test]` / the `test` library T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants