);
pub(crate) fn prepare() {
+ if Path::new("download").exists() {
+ std::fs::remove_dir_all(Path::new("download")).unwrap();
+ }
+ std::fs::create_dir_all(Path::new("download")).unwrap();
+
prepare_sysroot();
// FIXME maybe install this only locally?
SIMPLE_RAYTRACER.fetch();
eprintln!("[LLVM BUILD] simple-raytracer");
- let build_cmd = cargo_command("cargo", "build", None, Path::new("simple-raytracer"));
+ let build_cmd = cargo_command("cargo", "build", None, &SIMPLE_RAYTRACER.source_dir());
spawn_and_wait(build_cmd);
fs::copy(
- Path::new("simple-raytracer/target/debug").join(get_file_name("main", "bin")),
- Path::new("simple-raytracer").join(get_file_name("raytracer_cg_llvm", "bin")),
+ SIMPLE_RAYTRACER
+ .source_dir()
+ .join("target")
+ .join("debug")
+ .join(get_file_name("main", "bin")),
+ SIMPLE_RAYTRACER.source_dir().join(get_file_name("raytracer_cg_llvm", "bin")),
)
.unwrap();
}
pub(crate) fn source_dir(&self) -> PathBuf {
match self.url {
- GitRepoUrl::Github { user: _, repo } => PathBuf::from(format!("{}", repo)),
+ GitRepoUrl::Github { user: _, repo } => {
+ std::env::current_dir().unwrap().join("download").join(repo)
+ }
}
}
return;
}
+ let downloads_dir = std::env::current_dir().unwrap().join("download");
+
let archive_url = format!("https://github.com/{}/{}/archive/{}.tar.gz", user, repo, rev);
- let archive_file = format!("{}.tar.gz", rev);
- let archive_dir = format!("{}-{}", repo, rev);
+ let archive_file = downloads_dir.join(format!("{}.tar.gz", rev));
+ let archive_dir = downloads_dir.join(format!("{}-{}", repo, rev));
eprintln!("[DOWNLOAD] {}/{} from {}", user, repo, archive_url);
// Unpack tar archive
let mut unpack_cmd = Command::new("tar");
- unpack_cmd.arg("xf").arg(&archive_file);
+ unpack_cmd.arg("xf").arg(&archive_file).current_dir(downloads_dir);
spawn_and_wait(unpack_cmd);
// Rename unpacked dir to the expected name
use super::build_sysroot;
use super::config;
+use super::prepare;
use super::rustc_info::get_wrapper_file_name;
use super::utils::{cargo_command, hyperfine_command, spawn_and_wait, spawn_and_wait_with_input};
use build_system::SysrootKind;
const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[
TestCase::new("test.rust-random/rand", &|runner| {
- runner.in_dir(["rand"], |runner| {
+ runner.in_dir(prepare::RAND.source_dir(), |runner| {
runner.run_cargo("clean", []);
if runner.host_triple == runner.target_triple {
});
}),
TestCase::new("bench.simple-raytracer", &|runner| {
- runner.in_dir(["simple-raytracer"], |runner| {
+ runner.in_dir(prepare::SIMPLE_RAYTRACER.source_dir(), |runner| {
let run_runs = env::var("RUN_RUNS").unwrap_or("10".to_string()).parse().unwrap();
if runner.host_triple == runner.target_triple {
});
}),
TestCase::new("test.libcore", &|runner| {
- runner.in_dir(["build_sysroot", "sysroot_src", "library", "core", "tests"], |runner| {
- runner.run_cargo("clean", []);
+ runner.in_dir(
+ std::env::current_dir()
+ .unwrap()
+ .join("build_sysroot")
+ .join("sysroot_src")
+ .join("library")
+ .join("core")
+ .join("tests"),
+ |runner| {
+ runner.run_cargo("clean", []);
- if runner.host_triple == runner.target_triple {
- runner.run_cargo("test", []);
- } else {
- eprintln!("Cross-Compiling: Not running tests");
- runner.run_cargo("build", ["--tests"]);
- }
- });
+ if runner.host_triple == runner.target_triple {
+ runner.run_cargo("test", []);
+ } else {
+ eprintln!("Cross-Compiling: Not running tests");
+ runner.run_cargo("build", ["--tests"]);
+ }
+ },
+ );
}),
TestCase::new("test.regex-shootout-regex-dna", &|runner| {
- runner.in_dir(["regex"], |runner| {
+ runner.in_dir(prepare::REGEX.source_dir(), |runner| {
runner.run_cargo("clean", []);
// newer aho_corasick versions throw a deprecation warning
});
}),
TestCase::new("test.regex", &|runner| {
- runner.in_dir(["regex"], |runner| {
+ runner.in_dir(prepare::REGEX.source_dir(), |runner| {
runner.run_cargo("clean", []);
// newer aho_corasick versions throw a deprecation warning
});
}),
TestCase::new("test.portable-simd", &|runner| {
- runner.in_dir(["portable-simd"], |runner| {
+ runner.in_dir(prepare::PORTABLE_SIMD.source_dir(), |runner| {
runner.run_cargo("clean", []);
runner.run_cargo("build", ["--all-targets", "--target", &runner.target_triple]);
}
}
- fn in_dir<'a, I, F>(&self, dir: I, callback: F)
- where
- I: IntoIterator<Item = &'a str>,
- F: FnOnce(&TestRunner),
- {
+ fn in_dir(&self, new: impl AsRef<Path>, callback: impl FnOnce(&TestRunner)) {
let current = env::current_dir().unwrap();
- let mut new = current.clone();
- for d in dir {
- new.push(d);
- }
env::set_current_dir(new).unwrap();
callback(self);