Skip to content

Commit

Permalink
Improve testing framework for http registries
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
arlosi committed Jun 10, 2022
1 parent 85e457e commit 24dac45
Show file tree
Hide file tree
Showing 14 changed files with 723 additions and 613 deletions.
11 changes: 10 additions & 1 deletion crates/cargo-test-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,12 @@ impl Execs {
self
}

/// Writes the given lines to stdin.
pub fn with_stdin<S: ToString>(&mut self, expected: S) -> &mut Self {
self.expect_stdin = Some(expected.to_string());
self
}

/// Verifies the exit code from the process.
///
/// This is not necessary if the expected exit code is `0`.
Expand Down Expand Up @@ -820,7 +826,10 @@ impl Execs {
#[track_caller]
pub fn run(&mut self) {
self.ran = true;
let p = (&self.process_builder).clone().unwrap();
let mut p = (&self.process_builder).clone().unwrap();
if let Some(stdin) = self.expect_stdin.take() {
p.stdin(stdin);
}
if let Err(e) = self.match_process(&p) {
panic_error(&format!("test failed running {}", p), e);
}
Expand Down
Loading

0 comments on commit 24dac45

Please sign in to comment.