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 authored and sylvestre committed Dec 12, 2024
1 parent 56f145c commit 7e96849
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 @@ -3736,4 +3736,47 @@ proc_macro false

assert_eq!(h.profile, Some("foo-a1b6419f8321841f.profraw".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 7e96849

Please sign in to comment.