Skip to content

Commit

Permalink
test: ignore 502 in can_clone_keep_directory_structure (#8372)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Jul 5, 2024
1 parent 4dc9467 commit 161605a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
16 changes: 15 additions & 1 deletion crates/forge/tests/cli/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,21 @@ forgetest!(can_clone_keep_directory_structure, |prj, cmd| {
"0x33e690aEa97E4Ef25F0d140F1bf044d663091DAf",
])
.arg(prj.root());
cmd.assert_non_empty_stdout();
let out = cmd.unchecked_output();
if out.stdout_lossy().contains("502 Bad Gateway") {
// etherscan nginx proxy issue, skip this test:
//
// stdout:
// Downloading the source code of 0x33e690aEa97E4Ef25F0d140F1bf044d663091DAf from
// Etherscan... 2024-07-05T11:40:11.801765Z ERROR etherscan: Failed to deserialize
// response: expected value at line 1 column 1 res="<html>\r\n<head><title>502 Bad
// Gateway</title></head>\r\n<body>\r\n<center><h1>502 Bad
// Gateway</h1></center>\r\n<hr><center>nginx</center>\r\n</body>\r\n</html>\r\n"

eprintln!("Skipping test due to 502 Bad Gateway: {}", cmd.make_error_message(&out, false));
return
}
cmd.ensure_success(&out).unwrap();

let s = read_string(&foundry_toml);
let _config: BasicConfig = parse_with_profile(&s).unwrap().unwrap().1;
Expand Down
16 changes: 15 additions & 1 deletion crates/test-utils/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,7 @@ impl TestCommand {
eyre::eyre!("{}", self.make_error_message(out, expected_fail))
}

fn make_error_message(&self, out: &Output, expected_fail: bool) -> String {
pub fn make_error_message(&self, out: &Output, expected_fail: bool) -> String {
let msg = if expected_fail {
"expected failure but command succeeded!"
} else {
Expand Down Expand Up @@ -1071,6 +1071,12 @@ pub trait OutputExt {

/// Ensure the command wrote the expected data to `stderr`.
fn stderr_matches_path(&self, expected_path: impl AsRef<Path>);

/// Returns the stderr as lossy string
fn stderr_lossy(&self) -> String;

/// Returns the stdout as lossy string
fn stdout_lossy(&self) -> String;
}

/// Patterns to remove from fixtures before comparing output
Expand Down Expand Up @@ -1118,6 +1124,14 @@ impl OutputExt for Output {
let err = lossy_string(&self.stderr);
similar_asserts::assert_eq!(normalize_output(&err), normalize_output(&expected));
}

fn stderr_lossy(&self) -> String {
lossy_string(&self.stderr)
}

fn stdout_lossy(&self) -> String {
lossy_string(&self.stdout)
}
}

/// Returns the fixture path depending on whether the current terminal is tty
Expand Down

0 comments on commit 161605a

Please sign in to comment.