Skip to content

Commit

Permalink
replace <link> with an actual link; don't use logger for output
Browse files Browse the repository at this point in the history
  • Loading branch information
max-trunk committed Nov 1, 2024
1 parent 0452ac0 commit 547be9c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 30 deletions.
16 changes: 8 additions & 8 deletions cli-tests/src/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ fn validate_success() {
.args(&["validate", "--junit-paths", "./*"])
.assert()
.success()
.stderr(predicate::str::contains("0 validation errors"))
.stderr(predicate::str::contains("All 1 files are valid"));
.stdout(predicate::str::contains("0 validation errors"))
.stdout(predicate::str::contains("All 1 files are valid"));

println!("{assert}");
}
Expand Down Expand Up @@ -46,8 +46,8 @@ fn validate_invalid_junits() {
.args(&["validate", "--junit-paths", "./*"])
.assert()
.failure()
.stderr(predicate::str::contains("1 validation error"))
.stderr(predicate::str::contains(
.stdout(predicate::str::contains("1 validation error"))
.stdout(predicate::str::contains(
"INVALID - test suite name too short",
));

Expand All @@ -65,8 +65,8 @@ fn validate_invalid_xml() {
.args(&["validate", "--junit-paths", "./*"])
.assert()
.failure()
.stderr(predicate::str::contains("1 validation error"))
.stderr(predicate::str::contains(
.stdout(predicate::str::contains("1 validation error"))
.stdout(predicate::str::contains(
"INVALID - syntax error: tag not closed",
));

Expand All @@ -83,10 +83,10 @@ fn validate_suboptimal_junits() {
.args(&["validate", "--junit-paths", "./*"])
.assert()
.success()
.stderr(predicate::str::contains(
.stdout(predicate::str::contains(
"0 validation errors, 1 validation warning",
))
.stderr(predicate::str::contains(
.stdout(predicate::str::contains(
"OPTIONAL - report has stale (> 1 hour(s)) timestamps",
));

Expand Down
40 changes: 18 additions & 22 deletions cli/src/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,14 @@ fn parse_file_sets(file_sets: Vec<FileSet>) -> JunitFileToReportAndErrors {
}

fn print_matched_files(file_sets: &[FileSet], file_counter: FileSetCounter) {
log::info!("");
log::info!(
"Validating the following {} files:",
println!(
"\nValidating the following {} files:",
file_counter.get_count()
);
for file_set in file_sets {
log::info!(" File set matching {}:", file_set.glob);
println!(" File set matching {}:", file_set.glob);
for file in &file_set.files {
log::info!("\t{}", file.original_path_rel);
println!(" {}", file.original_path_rel);
}
}
}
Expand All @@ -126,9 +125,8 @@ fn print_parse_errors(parse_results: &JunitFileToReportAndErrors) {
return;
}

log::info!("");
log::warn!(
"Encountered the following {} non-fatal errors while parsing files:",
println!(
"\nEncountered the following {} non-fatal errors while parsing files:",
num_parse_errors.to_string().yellow()
);

Expand All @@ -137,10 +135,10 @@ fn print_parse_errors(parse_results: &JunitFileToReportAndErrors) {
continue;
}

log::warn!(" File: {}", parse_result.0);
println!(" File: {}", parse_result.0);

for parse_error in &parse_result.1 .1 {
log::warn!("\t{}", parse_error);
println!(" {}", parse_error);
}
}
}
Expand All @@ -150,7 +148,6 @@ fn print_summary_failure(
num_invalid_reports: usize,
num_suboptimal_reports: usize,
) {
log::info!("");
let num_validation_warnings_str = if num_suboptimal_reports > 0 {
format!(
", {} files have validation warnings",
Expand All @@ -159,8 +156,8 @@ fn print_summary_failure(
} else {
String::from("")
};
log::info!(
"{} files are valid, {} files are not valid{}{}",
println!(
"\n{} files are valid, {} files are not valid{}{}",
(num_reports - num_invalid_reports).to_string().green(),
num_invalid_reports.to_string().red(),
num_validation_warnings_str,
Expand All @@ -169,7 +166,6 @@ fn print_summary_failure(
}

fn print_summary_success(num_reports: usize, num_suboptimal_reports: usize) {
log::info!("");
let num_validation_warnings_str = if num_suboptimal_reports > 0 {
format!(
" ({} files with validation warnings)",
Expand All @@ -179,20 +175,20 @@ fn print_summary_success(num_reports: usize, num_suboptimal_reports: usize) {
String::from("")
};

log::info!(
"All {} files are valid!{}{}",
println!(
"\nAll {} files are valid!{}{}",
num_reports.to_string().green(),
num_validation_warnings_str,
Emoji(" ✅", ""),
);
log::info!(
"First time setting up Flaky Tests for this repo? Follow this link <link> to continue getting started.{}",
println!(
"First time setting up Flaky Tests for this repo? Follow this link https://app.trunk.io/onboarding?intent=flaky+tests to continue getting started.{}",
Emoji(" 🚀🧪", ""),
);
}

fn print_validation_errors(report_validations: &JunitFileToValidation) -> (usize, usize) {
log::info!("");
println!();
let mut num_invalid_reports: usize = 0;
let mut num_suboptimal_reports: usize = 0;
for report_validation in report_validations {
Expand Down Expand Up @@ -232,7 +228,7 @@ fn print_validation_errors(report_validations: &JunitFileToValidation) -> (usize
} else {
String::from("")
};
log::info!(
println!(
"{} - {} test suites, {} test cases, {} validation errors{}",
report_validation.0,
num_test_suites,
Expand All @@ -242,15 +238,15 @@ fn print_validation_errors(report_validations: &JunitFileToValidation) -> (usize
);

if let Some(parse_error) = report_parse_error {
log::info!(
println!(
" {} - {}",
print_validation_level(JunitValidationLevel::Invalid),
parse_error,
);
}

for issue in all_issues {
log::info!(
println!(
" {} - {}",
print_validation_level(issue.level),
issue.error_message,
Expand Down

0 comments on commit 547be9c

Please sign in to comment.