Skip to content

Commit 6b8e192

Browse files
committed
Auto merge of #10738 - arlosi:auth-testingonly, r=ehuss
Improve testing framework for http registries Improve integration of the http server introduced by the http-registry feature. The same HTTP server is used for serving downloads, the index, and the API within the test framework. This makes it easier to write tests that deal with authentication and http registries. Most of this change is pulled from #10592. Getting it in separately should make the other change easier to review. r? `@Eh2406`
2 parents 1b3fce7 + 24dac45 commit 6b8e192

File tree

14 files changed

+723
-613
lines changed

14 files changed

+723
-613
lines changed

crates/cargo-test-support/src/lib.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,12 @@ impl Execs {
569569
self
570570
}
571571

572+
/// Writes the given lines to stdin.
573+
pub fn with_stdin<S: ToString>(&mut self, expected: S) -> &mut Self {
574+
self.expect_stdin = Some(expected.to_string());
575+
self
576+
}
577+
572578
/// Verifies the exit code from the process.
573579
///
574580
/// This is not necessary if the expected exit code is `0`.
@@ -820,7 +826,10 @@ impl Execs {
820826
#[track_caller]
821827
pub fn run(&mut self) {
822828
self.ran = true;
823-
let p = (&self.process_builder).clone().unwrap();
829+
let mut p = (&self.process_builder).clone().unwrap();
830+
if let Some(stdin) = self.expect_stdin.take() {
831+
p.stdin(stdin);
832+
}
824833
if let Err(e) = self.match_process(&p) {
825834
panic_error(&format!("test failed running {}", p), e);
826835
}

0 commit comments

Comments
 (0)