Skip to content

Commit 161605a

Browse files
authored
test: ignore 502 in can_clone_keep_directory_structure (#8372)
1 parent 4dc9467 commit 161605a

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

crates/forge/tests/cli/cmd.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,21 @@ forgetest!(can_clone_keep_directory_structure, |prj, cmd| {
507507
"0x33e690aEa97E4Ef25F0d140F1bf044d663091DAf",
508508
])
509509
.arg(prj.root());
510-
cmd.assert_non_empty_stdout();
510+
let out = cmd.unchecked_output();
511+
if out.stdout_lossy().contains("502 Bad Gateway") {
512+
// etherscan nginx proxy issue, skip this test:
513+
//
514+
// stdout:
515+
// Downloading the source code of 0x33e690aEa97E4Ef25F0d140F1bf044d663091DAf from
516+
// Etherscan... 2024-07-05T11:40:11.801765Z ERROR etherscan: Failed to deserialize
517+
// response: expected value at line 1 column 1 res="<html>\r\n<head><title>502 Bad
518+
// Gateway</title></head>\r\n<body>\r\n<center><h1>502 Bad
519+
// Gateway</h1></center>\r\n<hr><center>nginx</center>\r\n</body>\r\n</html>\r\n"
520+
521+
eprintln!("Skipping test due to 502 Bad Gateway: {}", cmd.make_error_message(&out, false));
522+
return
523+
}
524+
cmd.ensure_success(&out).unwrap();
511525

512526
let s = read_string(&foundry_toml);
513527
let _config: BasicConfig = parse_with_profile(&s).unwrap().unwrap().1;

crates/test-utils/src/util.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,7 @@ impl TestCommand {
10271027
eyre::eyre!("{}", self.make_error_message(out, expected_fail))
10281028
}
10291029

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

10721072
/// Ensure the command wrote the expected data to `stderr`.
10731073
fn stderr_matches_path(&self, expected_path: impl AsRef<Path>);
1074+
1075+
/// Returns the stderr as lossy string
1076+
fn stderr_lossy(&self) -> String;
1077+
1078+
/// Returns the stdout as lossy string
1079+
fn stdout_lossy(&self) -> String;
10741080
}
10751081

10761082
/// Patterns to remove from fixtures before comparing output
@@ -1118,6 +1124,14 @@ impl OutputExt for Output {
11181124
let err = lossy_string(&self.stderr);
11191125
similar_asserts::assert_eq!(normalize_output(&err), normalize_output(&expected));
11201126
}
1127+
1128+
fn stderr_lossy(&self) -> String {
1129+
lossy_string(&self.stderr)
1130+
}
1131+
1132+
fn stdout_lossy(&self) -> String {
1133+
lossy_string(&self.stdout)
1134+
}
11211135
}
11221136

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

0 commit comments

Comments
 (0)