Skip to content
Merged
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ __pycache__/
/plans/
/workspace/
/e2e-consolidated-report.md
# Default outputs of the rocm-dash-tui gen_cast and gen_screenshots examples when
# run from the repository root.
/rocm-dash.cast
/screenshots/

# Sphinx docs: _toc.yml is generated from _toc.yml.in at build time
docs/rocm-docs/sphinx/_toc.yml
Expand Down
5 changes: 0 additions & 5 deletions crates/rocm-dash-collectors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ tokio = { version = "1", features = ["full"] }
reqwest = { version = "0.12", default-features = false }

[dev-dependencies]
# Test-only: `write_fake_executable` plants the fake `amd-smi` the timeout tests
# run without the intermittent "Text file busy" failure that `std::fs::write`
# followed by a chmod hits. `rocm-core` is also a normal dependency above
# (`amd_smi.rs` uses `device_readable_bounded`), so this entry only restates it.
rocm-core = { path = "../rocm-core" }
tokio = { version = "1", features = ["full"] }
tempfile = "3"
wiremock = "0.6"
Expand Down
19 changes: 16 additions & 3 deletions crates/rocm-dash-tui/examples/gen_cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ const DEFAULT_BG: (u8, u8, u8) = (13, 15, 18);
)]
struct Args {
/// Session NDJSON recording to render (`PersistedEntry` lines).
#[arg(long, default_value = "/tmp/mi355x-demo.ndjson")]
#[arg(long)]
input: PathBuf,

/// Output cast file. Parent dir created if absent. The default is relative
/// to the working directory.
#[arg(long, default_value = "../marketing/asciinema/rocm-dash.cast")]
/// to the working directory. It is git-ignored only when produced at the
/// repository root; a run from elsewhere writes the file there instead,
/// uncovered by that rule.
#[arg(long, default_value = "rocm-dash.cast")]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just confirming the reasoning here rather than asking for a change — the PR body says this was a deliberate call, so I expect the answer is "yes, on purpose."

The new default writes into the working directory, which does match the usage each example documents. The cost is two .gitignore entries at the repo root for what are really developer-tool artifacts. The alternative would be making --output (and --output-dir in gen_screenshots.rs) required, symmetric with what you've just done to --input, which would need no .gitignore change at all.

Was the convenience of a default deliberately preferred over that symmetry?

output: PathBuf,

/// Terminal grid (cols × rows) the cast is rendered at.
Expand Down Expand Up @@ -370,6 +372,17 @@ const fn resolve_color(c: Option<Color>, default: (u8, u8, u8)) -> (u8, u8, u8)
mod tests {
use super::*;

#[test]
fn input_is_required_and_output_defaults_to_the_working_directory() {
let err = Args::try_parse_from(["gen_cast"])
.err()
.expect("no recording is produced at a fixed path, so --input has no default");
assert_eq!(err.kind(), clap::error::ErrorKind::MissingRequiredArgument);
let args = Args::try_parse_from(["gen_cast", "--input", "session.ndjson"])
.expect("--input alone is enough");
assert_eq!(args.output, PathBuf::from("rocm-dash.cast"));
}

#[test]
fn generated_cast_is_marked_simulated() {
let mut state = build_state();
Expand Down
24 changes: 17 additions & 7 deletions crates/rocm-dash-tui/examples/gen_screenshots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,17 @@ use rocm_dash_tui::app::{ActiveTab, AppState, ConnState, Modal};
use rocm_dash_tui::ui;

#[derive(Parser)]
#[command(
name = "gen_screenshots",
about = "Render TUI views to SVG for marketing"
)]
#[command(name = "gen_screenshots", about = "Render TUI views to SVG")]
struct Args {
/// Session NDJSON recording to render (`PersistedEntry` lines).
#[arg(long, default_value = "/tmp/mi355x-demo.ndjson")]
#[arg(long)]
input: PathBuf,

/// Output directory. Created if absent. SVGs are named per view. The
/// default is relative to the working directory.
#[arg(long, default_value = "../marketing/screenshots")]
/// default is relative to the working directory. It is git-ignored only
/// when produced at the repository root; a run from elsewhere writes the
/// files there instead, uncovered by that rule.
#[arg(long, default_value = "screenshots")]
output_dir: PathBuf,

/// How many snapshots to replay before capturing. Higher = fuller
Expand Down Expand Up @@ -450,6 +449,17 @@ fn xml_escape(s: &str) -> String {
mod tests {
use super::*;

#[test]
fn input_is_required_and_output_dir_defaults_to_the_working_directory() {
let err = Args::try_parse_from(["gen_screenshots"])
.err()
.expect("no recording is produced at a fixed path, so --input has no default");
assert_eq!(err.kind(), clap::error::ErrorKind::MissingRequiredArgument);
let args = Args::try_parse_from(["gen_screenshots", "--input", "session.ndjson"])
.expect("--input alone is enough");
assert_eq!(args.output_dir, PathBuf::from("screenshots"));
}

#[test]
fn generated_screenshot_is_marked_simulated() {
let mut state = build_state("default-dark", &[], 0);
Expand Down
Loading