File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3617,4 +3617,47 @@ proc_macro false
36173617
36183618 assert_eq ! ( h. profile, Some ( "foo-a1b6419f8321841f.profraw" . into( ) ) ) ;
36193619 }
3620+
3621+ #[ test]
3622+ fn test_parse_target ( ) {
3623+ // Parse a --target argument that is a string (not a path to a .json file).
3624+ let h = parses ! (
3625+ "--crate-name" ,
3626+ "foo" ,
3627+ "--crate-type" ,
3628+ "lib" ,
3629+ "./src/lib.rs" ,
3630+ "--emit=dep-info,link" ,
3631+ "--out-dir" ,
3632+ "/out" ,
3633+ "--target" ,
3634+ "string"
3635+ ) ;
3636+ assert ! ( h. arguments. contains( & Argument :: WithValue (
3637+ "--target" ,
3638+ ArgData :: Target ( ArgTarget :: Name ( "string" . to_owned( ) ) ) ,
3639+ ArgDisposition :: Separated
3640+ ) ) ) ;
3641+ assert ! ( h. target_json. is_none( ) ) ;
3642+
3643+ // Parse a --target argument that is a path.
3644+ let h = parses ! (
3645+ "--crate-name" ,
3646+ "foo" ,
3647+ "--crate-type" ,
3648+ "lib" ,
3649+ "./src/lib.rs" ,
3650+ "--emit=dep-info,link" ,
3651+ "--out-dir" ,
3652+ "/out" ,
3653+ "--target" ,
3654+ "/path/to/target.json"
3655+ ) ;
3656+ assert ! ( h. arguments. contains( & Argument :: WithValue (
3657+ "--target" ,
3658+ ArgData :: Target ( ArgTarget :: Path ( PathBuf :: from( "/path/to/target.json" ) ) ) ,
3659+ ArgDisposition :: Separated
3660+ ) ) ) ;
3661+ assert_eq ! ( h. target_json, Some ( PathBuf :: from( "/path/to/target.json" ) ) ) ;
3662+ }
36203663}
You can’t perform that action at this time.
0 commit comments