Update tests to use config.toml instead

This commit is contained in:
Guillaume Gomez 2024-02-09 17:00:37 +01:00
parent 0b2402fdfc
commit 79241b8a4e
3 changed files with 19 additions and 2 deletions

7
Cargo.lock generated
View File

@ -23,6 +23,12 @@ version = "2.4.0"
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"
@ -185,6 +191,7 @@ checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78"
name = "rustc_codegen_gcc"
version = "0.1.0"
dependencies = [
"boml",
"gccjit",
"lang_tester",
"object",

View File

@ -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.

View File

@ -7,6 +7,7 @@
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 {