Skip to content

Commit 24dac45

Browse files
committed
Improve testing framework for http registries
Improve integration of the http server introduced by the http-registry feature. Now the same HTTP server is used for serving downloads, the index, and the API. This makes it easier to write tests that deal with authentication and http registries.
1 parent 85e457e commit 24dac45

14 files changed

+723
-613
lines changed

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

+10-1
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)