#[cfg(test)]
mod tests;
+const FAKE_SRC_BASE: &str = "fake-test-src-base";
+
#[cfg(windows)]
fn disable_error_reporting<F: FnOnce() -> R, R>(f: F) -> R {
use std::sync::Mutex;
return;
}
+ // On Windows, translate all '\' path separators to '/'
+ let file_name = format!("{}", self.testpaths.file.display()).replace(r"\", "/");
+
// On Windows, keep all '\' path separators to match the paths reported in the JSON output
// from the compiler
- let os_file_name = self.testpaths.file.display().to_string();
-
- // on windows, translate all '\' path separators to '/'
- let file_name = format!("{}", self.testpaths.file.display()).replace(r"\", "/");
+ let diagnostic_file_name = if self.props.remap_src_base {
+ let mut p = PathBuf::from(FAKE_SRC_BASE);
+ p.push(&self.testpaths.relative_dir);
+ p.push(self.testpaths.file.file_name().unwrap());
+ p.display().to_string()
+ } else {
+ self.testpaths.file.display().to_string()
+ };
// If the testcase being checked contains at least one expected "help"
// message, then we'll ensure that all "help" messages are expected.
let expect_note = expected_errors.iter().any(|ee| ee.kind == Some(ErrorKind::Note));
// Parse the JSON output from the compiler and extract out the messages.
- let actual_errors = json::parse_output(&os_file_name, &proc_res.stderr, proc_res);
+ let actual_errors = json::parse_output(&diagnostic_file_name, &proc_res.stderr, proc_res);
let mut unexpected = Vec::new();
let mut found = vec![false; expected_errors.len()];
for actual_error in &actual_errors {
}
}
+ if self.props.remap_src_base {
+ rustc.arg(format!(
+ "--remap-path-prefix={}={}",
+ self.config.src_base.display(),
+ FAKE_SRC_BASE,
+ ));
+ }
+
match emit {
Emit::None => {}
Emit::Metadata if is_rustdoc => {}
let parent_dir = self.testpaths.file.parent().unwrap();
normalize_path(parent_dir, "$DIR");
+ if self.props.remap_src_base {
+ let mut remapped_parent_dir = PathBuf::from(FAKE_SRC_BASE);
+ if self.testpaths.relative_dir != Path::new("") {
+ remapped_parent_dir.push(&self.testpaths.relative_dir);
+ }
+ normalize_path(&remapped_parent_dir, "$DIR");
+ }
+
let source_bases = &[
// Source base on the current filesystem (calculated as parent of `tests/$suite`):
Some(self.config.src_base.parent().unwrap().parent().unwrap().into()),