Skip to content

refactor(test): return Assert from ParkedChild::{kill,resume}() - #5203

Merged
rami3l merged 3 commits into
rust-lang:mainfrom
rami3l:test/parked-child-assert
Nov 9, 2026
Merged

rami3l merged 3 commits into
rust-lang:mainfrom
rami3l:test/parked-child-assert

Conversation

@rami3l

@rami3l rami3l commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Cherry-picked from #5194, this patch unifies the testing experience of regular subprocesses and ParkedChild by making the latter return the same Assert type upon finish as the former.

In other words, this allows returning code assertions and stdout/stderr snapshot testing on ParkedChild as one would normally do with regular subprocesses.

https://github.com/rust-lang/rustup/pull/5194/changes#diff-c6c864ad9d6d36c77a5ba7036d549e1c24a55bea1002c562f98e574db19240e9 gives an example that demonstrates how this can be helpful:

// TODO: Two processes downloading the same file share the same `.partial` path. Whichever finishes
// first renames it to its final name, and the other one then fails to find it.
//
// See: <https://github.com/rust-lang/rustup/issues/4607>
#[tokio::test]
async fn concurrent_download_of_same_file_fails() {
    let cx = CliTestContext::new(Scenario::SimpleV2).await;

    let parked = cx.spawn_at(
        CHECKPOINT_DOWNLOAD_BEFORE_RENAME,
        ["rustup", "toolchain", "install", "nightly"],
    );
    cx.config
        .expect(["rustup", "toolchain", "install", "nightly"])
        .await
        .is_ok();

    parked
        .resume()
        .with_stderr(snapbox::str![[r#"
...
error: component download failed for [..]: could not rename 'downloaded' file from '[..].partial' to '[..]':[..]
...
"#]])
        .is_err();
}

@rami3l
rami3l force-pushed the test/parked-child-assert branch 2 times, most recently from 720fd61 to 3c49c21 Compare November 9, 2026 09:04
@rami3l
rami3l force-pushed the test/parked-child-assert branch from 3c49c21 to 07d7916 Compare November 9, 2026 09:04
@rami3l
rami3l marked this pull request as ready for review November 9, 2026 09:05
@rami3l
rami3l requested a review from djc November 9, 2026 09:07
@rami3l
rami3l added this pull request to the merge queue Nov 9, 2026
Merged via the queue into rust-lang:main with commit baa72a5 Nov 9, 2026
29 checks passed
@rami3l
rami3l deleted the test/parked-child-assert branch November 9, 2026 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants