Skip to content

compiletest --nocapture still delays prints #128565

Description

@lolbinarycat

add the following snippet to the top of any run-make test's main function:

   #![allow(unreachable_code)]
    println!("infinite loop");
    loop {}

then run COMPILETEST_FORCE_STAGE0=1 ./x test --stage 0 tests/run-make/TEST_NAME/ -- --nocapture

this should print "infinite loop" and then hang, but it does not print anything.

running the same piece of code on the playground works properly.

flushing stdout doesn't help either.

Activity

  1. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Aug 2, 2024
  2. added
    C-bugCategory: This is a bug.
    A-compiletestArea: The compiletest test runner
    A-run-makeArea: port run-make Makefiles to rmake.rs
    on Aug 2, 2024
  3. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Aug 2, 2024
  4. added
    T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
    E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.
    E-needs-investigationCall for participation: This issues needs some investigation to determine current status
    and removed
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Oct 17, 2024
  5. Ashutosh1910 commented on Sep 3, 2026

    @Ashutosh1910
    Contributor

    @rustbot claim

  6. Ashutosh1910 commented on Sep 12, 2026

    @Ashutosh1910
    Contributor
    • This occurs because the output of the child(executor) process in which the test runs is piped to parent (compiletest) process. So it's output cannot be read and printed till the process is complete. (in src/tools/compiletest/src/runtest/run_make.rs).
    let mut cmd = Command::new(&recipe_bin);
           cmd.current_dir(&rmake_out_dir)
               .stdout(Stdio::piped())
               .stderr(Stdio::piped())
    
    • But this is not required in the case where we want to run a test with --no-capture.
    • So a fix would be to use Stdio:inherit() and not reading the stdout of the executor process using self.read2_abbreviated(proc); when using the --no-capture flag .
    if self.config.capture {
                cmd.stdout(Stdio::piped()).stderr(Stdio::piped());
            } else {
                cmd.stdout(Stdio::inherit()).stderr(Stdio::inherit());
            }
    
  7. added a commit that references this issue on Sep 27, 2026
    7ebf544
  8. added a commit that references this issue on Sep 27, 2026
    2950705
  9. removed
    E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.
    on Oct 8, 2026
  10. added 2 commits that reference this issue on Oct 8, 2026
  11. added a commit that references this issue on Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-compiletestArea: The compiletest test runnerA-run-makeArea: port run-make Makefiles to rmake.rsC-bugCategory: This is a bug.E-needs-investigationCall for participation: This issues needs some investigation to determine current statusT-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions