Accept embedded layer names in CLI selectors
Resolve scope and display selectors against both revisions before projection. Keep display-only selection on the large-file comparison path and list numeric choices for ambiguous names.
This commit is contained in:
parent
4ae689cd1c
commit
87683db7e8
1 changed files with 209 additions and 35 deletions
|
|
@ -2164,6 +2164,85 @@ fn cli_scope_and_display_filters_have_distinct_exit_behavior() {
|
|||
fs::remove_dir_all(directory).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cli_resolves_layer_names_before_applying_scope_and_display_filters() {
|
||||
let directory = std::env::temp_dir().join(format!("pheon-named-layer-{}", std::process::id()));
|
||||
fs::create_dir_all(&directory).unwrap();
|
||||
struct Cleanup(PathBuf);
|
||||
impl Drop for Cleanup {
|
||||
fn drop(&mut self) {
|
||||
let _ = fs::remove_dir_all(&self.0);
|
||||
}
|
||||
}
|
||||
let _cleanup = Cleanup(directory.clone());
|
||||
let old = directory.join("old.gds");
|
||||
let new = directory.join("new.gds");
|
||||
let fixture = |shape, text, name| {
|
||||
layout(&[
|
||||
("CHIP", vec![shape, label((2, 0), text)]),
|
||||
(
|
||||
"legend",
|
||||
vec![label((900, 7), LAYER_SENTINEL), label((900, 7), name)],
|
||||
),
|
||||
])
|
||||
};
|
||||
fs::write(&old, fixture(square(), "before", "1:0:WG")).unwrap();
|
||||
fs::write(&new, fixture(triangle(), "after", "1:0:CORE")).unwrap();
|
||||
let command = || Command::new(env!("CARGO_BIN_EXE_pheon"));
|
||||
let diff = |options: &[&str]| {
|
||||
command()
|
||||
.arg("diff")
|
||||
.arg(&old)
|
||||
.arg(&new)
|
||||
.args(options)
|
||||
.output()
|
||||
.unwrap()
|
||||
};
|
||||
for (option, name) in [("--layer", "WG"), ("--show-layer", "CORE")] {
|
||||
for format in ["text", "json"] {
|
||||
let named = diff(&[option, name, "--cell", "CHIP", "--format", format]);
|
||||
let numeric = diff(&[option, "1/0", "--cell", "CHIP", "--format", format]);
|
||||
assert_eq!(
|
||||
named.status.code(),
|
||||
Some(1),
|
||||
"{}",
|
||||
String::from_utf8_lossy(&named.stderr)
|
||||
);
|
||||
assert_eq!(named.stdout, numeric.stdout);
|
||||
}
|
||||
}
|
||||
|
||||
let dump = |layer| {
|
||||
let output = command()
|
||||
.arg("dump")
|
||||
.arg(&old)
|
||||
.args(["--layer", layer])
|
||||
.output()
|
||||
.unwrap();
|
||||
assert!(output.status.success());
|
||||
output.stdout
|
||||
};
|
||||
assert_eq!(dump("WG"), dump("1/0"));
|
||||
|
||||
let unknown = diff(&["--show-layer", "wg", "--format", "json"]);
|
||||
assert_eq!(unknown.status.code(), Some(2));
|
||||
let report: serde_json::Value = serde_json::from_slice(&unknown.stdout).unwrap();
|
||||
assert_eq!(report["diagnostics"][0]["code"], "command_error");
|
||||
assert_eq!(
|
||||
report["diagnostics"][0]["message"],
|
||||
"--show-layer unknown layer name \"wg\""
|
||||
);
|
||||
|
||||
fs::write(&new, fixture(triangle(), "after", "2:0:WG")).unwrap();
|
||||
let ambiguous = diff(&["--layer", "WG"]);
|
||||
assert_eq!(ambiguous.status.code(), Some(2));
|
||||
assert_eq!(
|
||||
String::from_utf8(ambiguous.stderr).unwrap().trim_end(),
|
||||
"pheon: --layer ambiguous layer name \"WG\" (choose 1/0, 2/0)"
|
||||
);
|
||||
assert_eq!(diff(&["--layer", "1/0"]).status.code(), Some(1));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn large_polygons_and_billion_instance_arrays_stay_compact() {
|
||||
let mut points = vec![[0, 0], [0, 1]];
|
||||
|
|
|
|||
Loading…
Reference in a new issue