cc_detect::find(&mut build);
build.verbose("running sanity check");
sanity::check(&mut build);
- // If local-rust is the same major.minor as the current version, then force a local-rebuild
- let local_version_verbose = output(
- Command::new(&build.initial_rustc).arg("--version").arg("--verbose"));
- let local_release = local_version_verbose
- .lines().filter(|x| x.starts_with("release:"))
- .next().unwrap().trim_left_matches("release:").trim();
- let my_version = channel::CFG_RELEASE_NUM;
- if local_release.split('.').take(2).eq(my_version.split('.').take(2)) {
- build.verbose(&format!("auto-detected local-rebuild {}", local_release));
- build.local_rebuild = true;
+ if !cfg!(test) {
+ // If local-rust is the same major.minor as the current version, then force a
+ // local-rebuild
+ let local_version_verbose = output(
+ Command::new(&build.initial_rustc).arg("--version").arg("--verbose"));
+ let local_release = local_version_verbose
+ .lines().filter(|x| x.starts_with("release:"))
+ .next().unwrap().trim_left_matches("release:").trim();
+ let my_version = channel::CFG_RELEASE_NUM;
+ if local_release.split('.').take(2).eq(my_version.split('.').take(2)) {
+ build.verbose(&format!("auto-detected local-rebuild {}", local_release));
+ build.local_rebuild = true;
+ }
}
build.verbose("learning about cargo");
metadata::build(&mut build);
///
/// After this executes, it will also ensure that `dir` exists.
fn clear_if_dirty(&self, dir: &Path, input: &Path) -> bool {
+ if cfg!(test) { return true; }
let stamp = dir.join(".stamp");
let mut cleared = false;
if mtime(&stamp) < mtime(input) {
/// Runs a command, printing out nice contextual information if it fails.
fn run(&self, cmd: &mut Command) {
+ if cfg!(test) { return; }
self.verbose(&format!("running: {:?}", cmd));
run_silent(cmd)
}
/// Runs a command, printing out nice contextual information if it fails.
fn run_quiet(&self, cmd: &mut Command) {
+ if cfg!(test) { return; }
self.verbose(&format!("running: {:?}", cmd));
run_suppressed(cmd)
}
/// Exits if the command failed to execute at all, otherwise returns its
/// `status.success()`.
fn try_run(&self, cmd: &mut Command) -> bool {
+ if cfg!(test) { return true; }
self.verbose(&format!("running: {:?}", cmd));
try_run_silent(cmd)
}
/// Exits if the command failed to execute at all, otherwise returns its
/// `status.success()`.
fn try_run_quiet(&self, cmd: &mut Command) -> bool {
+ if cfg!(test) { return true; }
self.verbose(&format!("running: {:?}", cmd));
try_run_suppressed(cmd)
}
/// Returns the path to the linker for the given target if it needs to be overridden.
fn linker(&self, target: Interned<String>) -> Option<&Path> {
+ if cfg!(test) { return None; }
if let Some(linker) = self.config.target_config.get(&target)
.and_then(|c| c.linker.as_ref()) {
Some(linker)
/// Compile LLVM for `target`.
fn run(self, builder: &Builder) -> PathBuf {
+ if cfg!(test) {
+ return PathBuf::from("llvm-config-test-generated");
+ }
let build = builder.build;
let target = self.target;
let emscripten = self.emscripten;
/// Compile LLVM for `target`.
fn run(self, builder: &Builder) -> PathBuf {
+ if cfg!(test) {
+ return PathBuf::from("lld-out-dir-test-gen");
+ }
let target = self.target;
let build = builder.build;
/// Compiles the `rust_test_helpers.c` library which we used in various
/// `run-pass` test suites for ABI testing.
fn run(self, builder: &Builder) {
+ if cfg!(test) {
+ return;
+ }
let build = builder.build;
let target = self.target;
let dst = build.test_helpers_out(target);
}
fn run(self, builder: &Builder) {
+ if cfg!(test) {
+ return;
+ }
let build = builder.build;
let target = self.target;
let out = match build.openssl_dir(target) {
/// Copies a file from `src` to `dst`
pub fn copy(src: &Path, dst: &Path) {
+ if cfg!(test) { return; }
let _ = fs::remove_file(&dst);
// Attempt to "easy copy" by creating a hard link (symlinks don't work on
// windows), but if that fails just fall back to a slow `copy` operation.
}
pub fn read_stamp_file(stamp: &Path) -> Vec<PathBuf> {
+ if cfg!(test) { return vec![]; }
let mut paths = Vec::new();
let mut contents = Vec::new();
t!(t!(File::open(stamp)).read_to_end(&mut contents));
/// Symlinks two directories, using junctions on Windows and normal symlinks on
/// Unix.
pub fn symlink_dir(src: &Path, dest: &Path) -> io::Result<()> {
+ if cfg!(test) { return Ok(()); }
let _ = fs::remove_dir(dest);
return symlink_dir_inner(src, dest);