Skip to content

Commit a69481e

Browse files
committed
stabilize lang_tests_common config parsing logic
Signed-off-by: onur-ozkan <[email protected]>
1 parent 9e90bed commit a69481e

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

Diff for: tests/lang_tests_common.rs

+12-8
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,18 @@ pub fn main_inner(profile: Profile) {
2222
let tempdir = TempDir::new().expect("temp dir");
2323
let current_dir = current_dir().expect("current dir");
2424
let current_dir = current_dir.to_str().expect("current dir").to_string();
25-
let toml = Toml::parse(include_str!("../config.toml")).expect("Failed to parse `config.toml`");
26-
let gcc_path = if let Ok(gcc_path) = toml.get_string("gcc-path") {
27-
PathBuf::from(gcc_path.to_string())
28-
} else {
29-
// then we try to retrieve it from the `target` folder.
30-
let commit = include_str!("../libgccjit.version").trim();
31-
Path::new("build/libgccjit").join(commit)
32-
};
25+
26+
let gcc_path = std::fs::read_to_string("../config.toml")
27+
.ok()
28+
.and_then(|v| {
29+
let toml = Toml::parse(&v).expect("Failed to parse `config.toml`");
30+
toml.get_string("gcc-path").map(PathBuf::from).ok()
31+
})
32+
.unwrap_or_else(|| {
33+
// then we try to retrieve it from the `target` folder.
34+
let commit = include_str!("../libgccjit.version").trim();
35+
Path::new("build/libgccjit").join(commit)
36+
});
3337

3438
let gcc_path = Path::new(&gcc_path)
3539
.canonicalize()

0 commit comments

Comments
 (0)