about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2024-02-09 17:00:37 +0100
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2024-02-11 23:15:50 +0100
commit79241b8a4e511a4e59761477c0bdffea24bd7201 (patch)
treef82c2d58d295ca9a07dca71d468c7c2cf19e1d95
parent0b2402fdfcf0f126abb3c2f2ce11fd8ac79f5c38 (diff)
downloadrust-79241b8a4e511a4e59761477c0bdffea24bd7201.tar.gz
rust-79241b8a4e511a4e59761477c0bdffea24bd7201.zip
Update tests to use `config.toml` instead
-rw-r--r--Cargo.lock7
-rw-r--r--Cargo.toml1
-rw-r--r--tests/lang_tests_common.rs13
3 files changed, 19 insertions, 2 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 26dc7c535f8..a19de10d0d2 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -24,6 +24,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635"
 
 [[package]]
+name = "boml"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "85fdb93f04c73bff54305fa437ffea5449c41edcaadfe882f35836206b166ac5"
+
+[[package]]
 name = "cc"
 version = "1.0.79"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -185,6 +191,7 @@ checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78"
 name = "rustc_codegen_gcc"
 version = "0.1.0"
 dependencies = [
+ "boml",
  "gccjit",
  "lang_tester",
  "object",
diff --git a/Cargo.toml b/Cargo.toml
index b0b3aeecdbd..a280ac73de0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -37,6 +37,7 @@ tempfile = "3.7.1"
 [dev-dependencies]
 lang_tester = "0.3.9"
 tempfile = "3.1.0"
+boml = "0.3.1"
 
 [profile.dev]
 # By compiling dependencies with optimizations, performing tests gets much faster.
diff --git a/tests/lang_tests_common.rs b/tests/lang_tests_common.rs
index af0133aad46..029a3b98ff2 100644
--- a/tests/lang_tests_common.rs
+++ b/tests/lang_tests_common.rs
@@ -7,6 +7,7 @@ use std::{
 
 use lang_tester::LangTester;
 use tempfile::TempDir;
+use boml::Toml;
 
 /// Controls the compile options (e.g., optimization level) used to compile
 /// test code.
@@ -20,8 +21,16 @@ 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 gcc_path = include_str!("../gcc_path");
-    let gcc_path = gcc_path.trim();
+    let gcc_path = Toml::parse(include_str!("../config.toml"))
+        .expect("Failed to parse `config.toml`")
+        .get_string("gcc-path")
+        .expect("Missing `gcc-path` key in `config.toml`")
+        .to_string();
+    let gcc_path = Path::new(&gcc_path)
+        .canonicalize()
+        .expect("failed to get absolute path of `gcc-path`")
+        .display()
+        .to_string();
     env::set_var("LD_LIBRARY_PATH", gcc_path);
 
     fn rust_filter(filename: &Path) -> bool {