mirror of
https://github.com/rust-lang/rust.git
synced 2025-09-26 20:21:59 +00:00
move config check logic from get_toml to parse_inner
This commit is contained in:
parent
83b784fda1
commit
aaa82aea05
@ -308,14 +308,14 @@ mod sysroot_target_dirs {
|
||||
/// cg_gcc tests instead.
|
||||
#[test]
|
||||
fn test_test_compiler() {
|
||||
let config = configure_with_args(&["test", "compiler"], &[], &[TEST_TRIPLE_1]);
|
||||
let config = configure_with_args(&["test", "compiler"], &[&host_target()], &[TEST_TRIPLE_1]);
|
||||
let cache = run_build(&config.paths.clone(), config);
|
||||
|
||||
let compiler = cache.contains::<test::CrateLibrustc>();
|
||||
let cranelift = cache.contains::<test::CodegenCranelift>();
|
||||
let gcc = cache.contains::<test::CodegenGCC>();
|
||||
|
||||
assert_eq!((compiler, cranelift, gcc), (false, false, false));
|
||||
assert_eq!((compiler, cranelift, gcc), (true, false, false));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -424,6 +424,18 @@ impl Config {
|
||||
src = src_;
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
{
|
||||
if let Some(config_path) = flags_config.as_ref() {
|
||||
assert!(
|
||||
!config_path.starts_with(&src),
|
||||
"Path {config_path:?} should not be inside or equal to src dir {src:?}"
|
||||
);
|
||||
} else {
|
||||
panic!("During test the config should be explicitly added");
|
||||
}
|
||||
}
|
||||
|
||||
// Now load the TOML config, as soon as possible
|
||||
let (mut toml, toml_path) = load_toml_config(&src, flags_config, &get_toml);
|
||||
|
||||
|
@ -175,20 +175,14 @@ fn override_toml_duplicate() {
|
||||
|
||||
#[test]
|
||||
fn profile_user_dist() {
|
||||
fn get_toml(file: &Path) -> Result<TomlConfig, toml::de::Error> {
|
||||
let contents = if file.ends_with("bootstrap.toml")
|
||||
|| file.ends_with("config.toml")
|
||||
|| env::var_os("RUST_BOOTSTRAP_CONFIG").is_some()
|
||||
{
|
||||
"profile = \"user\"".to_owned()
|
||||
} else {
|
||||
assert!(file.ends_with("config.dist.toml") || file.ends_with("bootstrap.dist.toml"));
|
||||
std::fs::read_to_string(file).unwrap()
|
||||
};
|
||||
|
||||
toml::from_str(&contents).and_then(|table: toml::Value| TomlConfig::deserialize(table))
|
||||
}
|
||||
Config::parse_inner(Flags::parse(&["check".to_owned()]), get_toml);
|
||||
TestCtx::new()
|
||||
.config("check")
|
||||
.with_default_toml_config(
|
||||
r#"
|
||||
profile = "user"
|
||||
"#,
|
||||
)
|
||||
.create_config();
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -224,8 +218,6 @@ fn verify_file_integrity() {
|
||||
config
|
||||
.verify(&tempfile, "7e255dd9542648a8779268a0f268b891a198e9828e860ed23f826440e786eae5")
|
||||
);
|
||||
|
||||
remove_file(tempfile).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -648,6 +640,7 @@ fn test_include_precedence_over_profile() {
|
||||
.config("check")
|
||||
.with_default_toml_config(
|
||||
r#"
|
||||
profile = "dist"
|
||||
include = ["./extension.toml"]
|
||||
"#,
|
||||
)
|
||||
|
@ -152,12 +152,6 @@ impl Config {
|
||||
}
|
||||
|
||||
pub(crate) fn get_toml(file: &Path) -> Result<TomlConfig, toml::de::Error> {
|
||||
#[cfg(test)]
|
||||
{
|
||||
let tmp = std::env::temp_dir();
|
||||
assert!(file.starts_with(&tmp), "Expected path in temp dir {:?}, got {:?}", tmp, file);
|
||||
}
|
||||
|
||||
Self::get_toml_inner(file)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user