Skip to content

Commit 44887e4

Browse files
committed
test(report): HTML replay snapshot
This adds a log file generated by ``` cargod build --timings -Zsection-timings -p cargo-util-schemas ``` With this we can track what changed in HTML report.
1 parent ffba21a commit 44887e4

File tree

7 files changed

+5549
-1
lines changed

7 files changed

+5549
-1
lines changed

.ignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,8 @@ src/etc/man
1212
!src/doc/src/commands/index.md
1313
!src/doc/src/commands/manifest-commands.md
1414
!src/doc/src/commands/package-commands.md
15-
!src/doc/src/commands/publishg-commands.md
15+
!src/doc/src/commands/publishing-commands.md
16+
17+
# Snapshots of HTML reports and log files are just too large
18+
tests/testsuite/**/*.jsonl
19+
tests/testsuite/**/*.html

src/cargo/ops/cargo_report/timings.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ pub fn report_timings(gctx: &GlobalContext, opts: ReportTimingsOptions<'_>) -> C
7777
let timings_dir = target_dir.join("cargo-timings");
7878
paths::create_dir_all(&timings_dir)?;
7979
timings_dir
80+
} else if let Ok(path) = gctx.get_env("__CARGO_TEST_REPORT_TIMINGS_TEMPDIR") {
81+
PathBuf::from(path.to_owned())
8082
} else {
8183
TempDir::with_prefix("cargo-timings-")?.keep()
8284
};

tests/testsuite/cargo_report_timings/html_snapshot/in/cargo-home/log/20060724T012128000Z-b0fd440798ab3cfb.jsonl

Lines changed: 425 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
use crate::prelude::*;
2+
use cargo_test_support::Project;
3+
use cargo_test_support::compare::assert_ui;
4+
use cargo_test_support::current_dir;
5+
use cargo_test_support::file;
6+
use cargo_test_support::str;
7+
8+
#[cargo_test]
9+
fn case() {
10+
let project = Project::from_template(current_dir!().join("in"));
11+
let project_root = project.root();
12+
let cwd = &project_root;
13+
let cargo_home = project_root.join("cargo-home");
14+
15+
snapbox::cmd::Command::cargo_ui()
16+
.arg_line("report timings -Zbuild-analysis")
17+
.masquerade_as_nightly_cargo(&["build-analysis"])
18+
.current_dir(cwd)
19+
.env("CARGO_HOME", cargo_home)
20+
.env("__CARGO_TEST_REPORT_TIMINGS_TEMPDIR", cwd)
21+
.assert()
22+
.success()
23+
.stdout_eq(str![""])
24+
.stderr_eq(file!["stderr.term.svg"]);
25+
26+
assert_ui().subset_matches(current_dir!().join("out"), &project_root);
27+
}

0 commit comments

Comments
 (0)