Skip to content

Commit cf6dc74

Browse files
committed
add coverage for explicit stage fields
Signed-off-by: onur-ozkan <[email protected]>
1 parent 37b18f8 commit cf6dc74

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

src/bootstrap/src/core/config/tests.rs

+57
Original file line numberDiff line numberDiff line change
@@ -454,3 +454,60 @@ fn check_rustc_if_unchanged_paths() {
454454
assert!(config.src.join(p).exists(), "{p} doesn't exist.");
455455
}
456456
}
457+
458+
#[test]
459+
fn test_explicit_stage() {
460+
let config = Config::parse_inner(
461+
Flags::parse(&["check".to_owned(), "--config=/does/not/exist".to_owned()]),
462+
|&_| {
463+
toml::from_str(
464+
r#"
465+
[build]
466+
test-stage = 1
467+
"#,
468+
)
469+
},
470+
);
471+
472+
assert!(!config.explicit_stage_from_cli);
473+
assert!(config.explicit_stage_from_config);
474+
475+
let config = Config::parse_inner(
476+
Flags::parse(&[
477+
"check".to_owned(),
478+
"--stage=2".to_owned(),
479+
"--config=/does/not/exist".to_owned(),
480+
]),
481+
|&_| toml::from_str(""),
482+
);
483+
484+
assert!(config.explicit_stage_from_cli);
485+
assert!(!config.explicit_stage_from_config);
486+
487+
let config = Config::parse_inner(
488+
Flags::parse(&[
489+
"check".to_owned(),
490+
"--stage=2".to_owned(),
491+
"--config=/does/not/exist".to_owned(),
492+
]),
493+
|&_| {
494+
toml::from_str(
495+
r#"
496+
[build]
497+
test-stage = 1
498+
"#,
499+
)
500+
},
501+
);
502+
503+
assert!(config.explicit_stage_from_cli);
504+
assert!(config.explicit_stage_from_config);
505+
506+
let config = Config::parse_inner(
507+
Flags::parse(&["check".to_owned(), "--config=/does/not/exist".to_owned()]),
508+
|&_| toml::from_str(""),
509+
);
510+
511+
assert!(!config.explicit_stage_from_cli);
512+
assert!(!config.explicit_stage_from_config);
513+
}

0 commit comments

Comments
 (0)