about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2024-12-11 22:44:38 +0100
committerGitHub <noreply@github.com>2024-12-11 22:44:38 +0100
commitcd3f69974fcfff27b285f225ad1222a361a534cd (patch)
treea5f9212f842d8d9930c25633a734912440a9799a
parenteb87eab2925e1c80fe43284718bda59a47338e78 (diff)
parent55fe6d97f104cfd19fc721a3917ad2bb46e42416 (diff)
downloadrust-cd3f69974fcfff27b285f225ad1222a361a534cd.tar.gz
rust-cd3f69974fcfff27b285f225ad1222a361a534cd.zip
Merge pull request #576 from onur-ozkan/bless-lang-tests
stabilize `lang_tests_common` config parsing logic
-rw-r--r--tests/lang_tests_common.rs22
1 files changed, 14 insertions, 8 deletions
diff --git a/tests/lang_tests_common.rs b/tests/lang_tests_common.rs
index aecea37ab5a..433b3d680b5 100644
--- a/tests/lang_tests_common.rs
+++ b/tests/lang_tests_common.rs
@@ -22,14 +22,20 @@ pub fn main_inner(profile: Profile) {
     let tempdir = TempDir::new().expect("temp dir");
     let current_dir = current_dir().expect("current dir");
     let current_dir = current_dir.to_str().expect("current dir").to_string();
-    let toml = Toml::parse(include_str!("../config.toml")).expect("Failed to parse `config.toml`");
-    let gcc_path = if let Ok(gcc_path) = toml.get_string("gcc-path") {
-        PathBuf::from(gcc_path.to_string())
-    } else {
-        // then we try to retrieve it from the `target` folder.
-        let commit = include_str!("../libgccjit.version").trim();
-        Path::new("build/libgccjit").join(commit)
-    };
+
+    let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR"));
+
+    let gcc_path = std::fs::read_to_string(manifest_dir.join("config.toml"))
+        .ok()
+        .and_then(|v| {
+            let toml = Toml::parse(&v).expect("Failed to parse `config.toml`");
+            toml.get_string("gcc-path").map(PathBuf::from).ok()
+        })
+        .unwrap_or_else(|| {
+            // then we try to retrieve it from the `target` folder.
+            let commit = include_str!("../libgccjit.version").trim();
+            Path::new("build/libgccjit").join(commit)
+        });
 
     let gcc_path = Path::new(&gcc_path)
         .canonicalize()