Skip to content

Commit a013915

Browse files
committed
Allow {{rust-src-base}} in test headers
1 parent febce52 commit a013915

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/tools/compiletest/src/header.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::collections::HashSet;
22
use std::env;
33
use std::fs::File;
4+
use std::fs::canonicalize;
45
use std::io::prelude::*;
56
use std::io::BufReader;
67
use std::path::{Path, PathBuf};
@@ -795,6 +796,7 @@ fn expand_variables(mut value: String, config: &Config) -> String {
795796
const CWD: &str = "{{cwd}}";
796797
const SRC_BASE: &str = "{{src-base}}";
797798
const BUILD_BASE: &str = "{{build-base}}";
799+
const RUST_SRC_BASE: &str = "{{rust-src-base}}";
798800

799801
if value.contains(CWD) {
800802
let cwd = env::current_dir().unwrap();
@@ -809,6 +811,12 @@ fn expand_variables(mut value: String, config: &Config) -> String {
809811
value = value.replace(BUILD_BASE, &config.build_base.to_string_lossy());
810812
}
811813

814+
if value.contains(RUST_SRC_BASE) {
815+
let src = config.sysroot_base.join("lib/rustlib/src/rust");
816+
let canonical = canonicalize(&src).unwrap();
817+
value = value.replace(RUST_SRC_BASE, &canonical.to_string_lossy());
818+
}
819+
812820
value
813821
}
814822

0 commit comments

Comments
 (0)