Use folder for example showcase reports and add show logs flag (#13198)
# Objective - The report_details flag currently dumps everything at the root of the repo which isn't ideal - When running the tool locally it's useful to see the logs as they appear ## Solution - Add a flag to show the logs - Write all the report files to a folder
This commit is contained in:
parent
96a6eee031
commit
6ca1b0728a
1
.gitignore
vendored
1
.gitignore
vendored
@ -21,3 +21,4 @@ crates/bevy_asset/imported_assets
|
|||||||
imported_assets
|
imported_assets
|
||||||
|
|
||||||
example_showcase_config.ron
|
example_showcase_config.ron
|
||||||
|
example-showcase-reports/
|
||||||
|
@ -25,6 +25,7 @@ struct Args {
|
|||||||
|
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
action: Action,
|
action: Action,
|
||||||
|
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
/// Pagination control - page number. To use with --per-page
|
/// Pagination control - page number. To use with --per-page
|
||||||
page: Option<usize>,
|
page: Option<usize>,
|
||||||
@ -62,6 +63,10 @@ enum Action {
|
|||||||
/// Report execution details in files
|
/// Report execution details in files
|
||||||
report_details: bool,
|
report_details: bool,
|
||||||
|
|
||||||
|
#[arg(long)]
|
||||||
|
/// Show the logs during execution
|
||||||
|
show_logs: bool,
|
||||||
|
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
/// File containing the list of examples to run, incompatible with pagination
|
/// File containing the list of examples to run, incompatible with pagination
|
||||||
example_list: Option<String>,
|
example_list: Option<String>,
|
||||||
@ -137,6 +142,7 @@ fn main() {
|
|||||||
in_ci,
|
in_ci,
|
||||||
ignore_stress_tests,
|
ignore_stress_tests,
|
||||||
report_details,
|
report_details,
|
||||||
|
show_logs,
|
||||||
example_list,
|
example_list,
|
||||||
only_default_features,
|
only_default_features,
|
||||||
} => {
|
} => {
|
||||||
@ -263,6 +269,12 @@ fn main() {
|
|||||||
|
|
||||||
let mut pb = ProgressBar::new(work_to_do().count() as u64);
|
let mut pb = ProgressBar::new(work_to_do().count() as u64);
|
||||||
|
|
||||||
|
let reports_path = "example-showcase-reports";
|
||||||
|
if report_details {
|
||||||
|
std::fs::create_dir(reports_path)
|
||||||
|
.expect("Failed to create example-showcase-reports directory");
|
||||||
|
}
|
||||||
|
|
||||||
for to_run in work_to_do() {
|
for to_run in work_to_do() {
|
||||||
let sh = Shell::new().unwrap();
|
let sh = Shell::new().unwrap();
|
||||||
let example = &to_run.technical_name;
|
let example = &to_run.technical_name;
|
||||||
@ -306,7 +318,7 @@ fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let before = Instant::now();
|
let before = Instant::now();
|
||||||
if report_details {
|
if report_details || show_logs {
|
||||||
cmd = cmd.ignore_status();
|
cmd = cmd.ignore_status();
|
||||||
}
|
}
|
||||||
let result = cmd.output();
|
let result = cmd.output();
|
||||||
@ -337,18 +349,23 @@ fn main() {
|
|||||||
failed_examples.push((to_run, duration));
|
failed_examples.push((to_run, duration));
|
||||||
}
|
}
|
||||||
|
|
||||||
if report_details {
|
if report_details || show_logs {
|
||||||
let result = result.unwrap();
|
let result = result.unwrap();
|
||||||
let stdout = String::from_utf8_lossy(&result.stdout);
|
let stdout = String::from_utf8_lossy(&result.stdout);
|
||||||
let stderr = String::from_utf8_lossy(&result.stderr);
|
let stderr = String::from_utf8_lossy(&result.stderr);
|
||||||
|
if show_logs {
|
||||||
println!("{}", stdout);
|
println!("{}", stdout);
|
||||||
println!("{}", stderr);
|
println!("{}", stderr);
|
||||||
let mut file = File::create(format!("{}.log", example)).unwrap();
|
}
|
||||||
|
if report_details {
|
||||||
|
let mut file =
|
||||||
|
File::create(format!("{reports_path}/{}.log", example)).unwrap();
|
||||||
file.write_all(b"==== stdout ====\n").unwrap();
|
file.write_all(b"==== stdout ====\n").unwrap();
|
||||||
file.write_all(stdout.as_bytes()).unwrap();
|
file.write_all(stdout.as_bytes()).unwrap();
|
||||||
file.write_all(b"\n==== stderr ====\n").unwrap();
|
file.write_all(b"\n==== stderr ====\n").unwrap();
|
||||||
file.write_all(stderr.as_bytes()).unwrap();
|
file.write_all(stderr.as_bytes()).unwrap();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
thread::sleep(Duration::from_secs(1));
|
thread::sleep(Duration::from_secs(1));
|
||||||
pb.inc();
|
pb.inc();
|
||||||
@ -357,7 +374,7 @@ fn main() {
|
|||||||
|
|
||||||
if report_details {
|
if report_details {
|
||||||
let _ = fs::write(
|
let _ = fs::write(
|
||||||
"successes",
|
format!("{reports_path}/successes"),
|
||||||
successful_examples
|
successful_examples
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(example, duration)| {
|
.map(|(example, duration)| {
|
||||||
@ -372,7 +389,7 @@ fn main() {
|
|||||||
.join("\n"),
|
.join("\n"),
|
||||||
);
|
);
|
||||||
let _ = fs::write(
|
let _ = fs::write(
|
||||||
"failures",
|
format!("{reports_path}/failures"),
|
||||||
failed_examples
|
failed_examples
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(example, duration)| {
|
.map(|(example, duration)| {
|
||||||
@ -388,7 +405,7 @@ fn main() {
|
|||||||
);
|
);
|
||||||
if screenshot {
|
if screenshot {
|
||||||
let _ = fs::write(
|
let _ = fs::write(
|
||||||
"no_screenshots",
|
format!("{reports_path}/no_screenshots"),
|
||||||
no_screenshot_examples
|
no_screenshot_examples
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(example, duration)| {
|
.map(|(example, duration)| {
|
||||||
|
Loading…
Reference in New Issue
Block a user