about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/bootstrap/src/core/builder/tests.rs4
-rw-r--r--src/bootstrap/src/core/config/config.rs12
-rw-r--r--src/bootstrap/src/core/config/tests.rs25
-rw-r--r--src/bootstrap/src/core/config/toml/mod.rs6
4 files changed, 23 insertions, 24 deletions
diff --git a/src/bootstrap/src/core/builder/tests.rs b/src/bootstrap/src/core/builder/tests.rs
index f838149977d..4555f0d2091 100644
--- a/src/bootstrap/src/core/builder/tests.rs
+++ b/src/bootstrap/src/core/builder/tests.rs
@@ -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]
diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs
index 280ae088f3f..1e207380a0a 100644
--- a/src/bootstrap/src/core/config/config.rs
+++ b/src/bootstrap/src/core/config/config.rs
@@ -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);
 
diff --git a/src/bootstrap/src/core/config/tests.rs b/src/bootstrap/src/core/config/tests.rs
index 3390e9586a4..4f2df76a156 100644
--- a/src/bootstrap/src/core/config/tests.rs
+++ b/src/bootstrap/src/core/config/tests.rs
@@ -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"]
     "#,
         )
diff --git a/src/bootstrap/src/core/config/toml/mod.rs b/src/bootstrap/src/core/config/toml/mod.rs
index 5f86d2e7281..f6dc5b67e10 100644
--- a/src/bootstrap/src/core/config/toml/mod.rs
+++ b/src/bootstrap/src/core/config/toml/mod.rs
@@ -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)
     }