Skip to content

Commit

Permalink
Merge pull request #243 from oli-obk/semicolon
Browse files Browse the repository at this point in the history
Avoid extraneous semicolons
  • Loading branch information
oli-obk authored Aug 2, 2024
2 parents 96d47dc + 4055b97 commit e935347
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 70 deletions.
105 changes: 51 additions & 54 deletions src/status_emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ impl StatusEmitter for Text {

fn finalize(
&self,
failures: usize,
_failures: usize,
succeeded: usize,
ignored: usize,
filtered: usize,
Expand All @@ -436,76 +436,73 @@ impl StatusEmitter for Text {
println!();
}
// Print all errors in a single thread to show reliable output
if failures == 0 {
println!();
print!("test result: {}.", "ok".green());
if succeeded > 0 {
print!(" {} passed;", succeeded.to_string().green());
}
if ignored > 0 {
print!(" {} ignored;", ignored.to_string().yellow());
}
if filtered > 0 {
print!(" {} filtered out;", filtered.to_string().yellow());
}
println!();
println!();
Box::new(())
} else {
struct Summarizer {
failures: Vec<String>,
succeeded: usize,
ignored: usize,
filtered: usize,
}

impl Summary for Summarizer {
fn test_failure(&mut self, status: &dyn TestStatus, errors: &Errors) {
for error in errors {
print_error(error, status.path());
}
struct Summarizer {
failures: Vec<String>,
succeeded: usize,
ignored: usize,
filtered: usize,
}

self.failures.push(if status.revision().is_empty() {
format!(" {}", display(status.path()))
} else {
format!(
" {} (revision {})",
display(status.path()),
status.revision()
)
});
impl Summary for Summarizer {
fn test_failure(&mut self, status: &dyn TestStatus, errors: &Errors) {
for error in errors {
print_error(error, status.path());
}

self.failures.push(if status.revision().is_empty() {
format!(" {}", display(status.path()))
} else {
format!(
" {} (revision {})",
display(status.path()),
status.revision()
)
});
}
}

impl Drop for Summarizer {
fn drop(&mut self) {
impl Drop for Summarizer {
fn drop(&mut self) {
if self.failures.is_empty() {
println!();
print!("test result: {}.", "ok".green());
} else {
println!("{}", "FAILURES:".bright_red().underline().bold());
for line in &self.failures {
println!("{line}");
}
println!();
print!("test result: {}.", "FAIL".bright_red());
print!(" {} failed;", self.failures.len().to_string().green());
if self.succeeded > 0 {
print!(" {} passed;", self.succeeded.to_string().green());
print!(" {} failed", self.failures.len().to_string().green());
if self.succeeded > 0 || self.ignored > 0 || self.filtered > 0 {
print!(";");
}
if self.ignored > 0 {
print!(" {} ignored;", self.ignored.to_string().yellow());
}
if self.succeeded > 0 {
print!(" {} passed", self.succeeded.to_string().green());
if self.ignored > 0 || self.filtered > 0 {
print!(";");
}
}
if self.ignored > 0 {
print!(" {} ignored", self.ignored.to_string().yellow());
if self.filtered > 0 {
print!(" {} filtered out;", self.filtered.to_string().yellow());
print!(";");
}
println!();
println!();
}
if self.filtered > 0 {
print!(" {} filtered out", self.filtered.to_string().yellow());
}
println!();
println!();
}
Box::new(Summarizer {
failures: vec![],
succeeded,
ignored,
filtered,
})
}
Box::new(Summarizer {
failures: vec![],
succeeded,
ignored,
filtered,
})
}
}

Expand Down
6 changes: 1 addition & 5 deletions tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fn main() -> Result<()> {
let path = Path::new(file!()).parent().unwrap();
let root_dir = path.join("integrations");
let mut config = Config {
bless_command: Some("cargo test".to_string()),
bless_command: Some("cargo test -- -- --bless".to_string()),
..Config::cargo(root_dir.clone())
};

Expand Down Expand Up @@ -113,10 +113,6 @@ fn main() -> Result<()> {
.to_str()
.unwrap()
.ends_with("-fail");
if cfg!(windows) && path.components().any(|c| c.as_os_str() == "basic-bin") {
// on windows there's also a .pdb file, so we get additional errors that aren't there on other platforms
return Some(false);
}
if !path.ends_with("Cargo.toml") {
return None;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/basic-bin/Cargo.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; fini
Building dependencies ... ok
tests/actual_tests/foomp.rs ... ok

test result: ok. 1 passed;
test result: ok. 1 passed

2 changes: 1 addition & 1 deletion tests/integrations/basic-fail-mode/Cargo.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; fini
Building dependencies ... ok
tests/actual_tests/foomp.rs ... ok

test result: ok. 1 passed;
test result: ok. 1 passed


running 0 tests
Expand Down
10 changes: 5 additions & 5 deletions tests/integrations/basic-fail/Cargo.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ FAILURES:
tests/actual_tests/touching_above_below.rs
tests/actual_tests/touching_above_below_chain.rs

test result: FAIL. 15 failed; 1 passed;
test result: FAIL. 15 failed; 1 passed

Building dependencies ... ok
tests/actual_tests_bless/abort.rs (revision `run`) ... FAILED
Expand Down Expand Up @@ -1078,7 +1078,7 @@ FAILURES:
tests/actual_tests_bless/unknown_revision2.rs
tests/actual_tests_bless/wrong_diagnostic_code.rs

test result: FAIL. 23 failed; 24 passed; 3 ignored;
test result: FAIL. 23 failed; 24 passed; 3 ignored

Building dependencies ... ok
tests/actual_tests_bless_yolo/revisions_bad.rs (revision `foo`) ... ok
Expand Down Expand Up @@ -1129,7 +1129,7 @@ full stdout:
FAILURES:
tests/actual_tests_bless_yolo/rustfix-multiple-fail.2.fixed

test result: FAIL. 1 failed; 7 passed;
test result: FAIL. 1 failed; 7 passed

tests/actual_tests/bad_pattern.rs ... FAILED
tests/actual_tests/executable.rs ... FAILED
Expand Down Expand Up @@ -1475,7 +1475,7 @@ FAILURES:
tests/actual_tests/touching_above_below.rs
tests/actual_tests/touching_above_below_chain.rs

test result: FAIL. 15 failed;
test result: FAIL. 15 failed

tests/actual_tests/bad_pattern.rs ... FAILED
tests/actual_tests/executable.rs ... FAILED
Expand Down Expand Up @@ -1707,7 +1707,7 @@ FAILURES:
tests/actual_tests/touching_above_below.rs
tests/actual_tests/touching_above_below_chain.rs

test result: FAIL. 15 failed;
test result: FAIL. 15 failed


running 0 tests
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/basic/Cargo.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ tests/actual_tests/unicode.rs ... ok
tests/actual_tests/windows_paths.rs ... ok
tests/actual_tests/subdir/aux_proc_macro.rs ... ok

test result: ok. 31 passed;
test result: ok. 31 passed


running 0 tests
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/cargo-run/Cargo.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ tests/actual_tests/matching_stdin.rs ... ok
tests/actual_tests/mismatching_stdin.rs ... ok
tests/actual_tests/no_stdin.rs ... ok

test result: ok. 4 passed;
test result: ok. 4 passed

2 changes: 1 addition & 1 deletion tests/integrations/dep-fail/Cargo.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ BuildFinished { success: false }
FAILURES:
tests/ui/basic_test.rs

test result: FAIL. 1 failed;
test result: FAIL. 1 failed


running 0 tests
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/ui_test_dep_bug/Cargo.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; fini
Building dependencies ... ok
tests/ui/basic_test.rs ... ok

test result: ok. 1 passed;
test result: ok. 1 passed


running 0 tests
Expand Down

0 comments on commit e935347

Please sign in to comment.