Skip to content

Commit

Permalink
Add a test for parsing the --target argument.
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinFinck committed Nov 18, 2024
1 parent 2d81c1e commit bb88bf5
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/compiler/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3617,4 +3617,47 @@ proc_macro false

assert_eq!(h.gcno, Some("foo-a1b6419f8321841f.gcno".into()));
}

#[test]
fn test_parse_target() {
// Parse a --target argument that is a string (not a path to a .json file).
let h = parses!(
"--crate-name",
"foo",
"--crate-type",
"lib",
"./src/lib.rs",
"--emit=dep-info,link",
"--out-dir",
"/out",
"--target",
"string"
);
assert!(h.arguments.contains(&Argument::WithValue(
"--target",
ArgData::Target(ArgTarget::Name("string".to_owned())),
ArgDisposition::Separated
)));
assert!(h.target_json.is_none());

// Parse a --target argument that is a path.
let h = parses!(
"--crate-name",
"foo",
"--crate-type",
"lib",
"./src/lib.rs",
"--emit=dep-info,link",
"--out-dir",
"/out",
"--target",
"/path/to/target.json"
);
assert!(h.arguments.contains(&Argument::WithValue(
"--target",
ArgData::Target(ArgTarget::Path(PathBuf::from("/path/to/target.json"))),
ArgDisposition::Separated
)));
assert_eq!(h.target_json, Some(PathBuf::from("/path/to/target.json")));
}
}

0 comments on commit bb88bf5

Please sign in to comment.