diff options
| author | Mark Simulacrum <mark.simulacrum@gmail.com> | 2018-03-09 19:23:35 -0700 |
|---|---|---|
| committer | Mark Simulacrum <mark.simulacrum@gmail.com> | 2018-04-03 11:39:16 -0600 |
| commit | cd33d3a0e49f67fdeebb8e19593f10b95e5719ee (patch) | |
| tree | 990fab5b642a8f7a5f235ccbbe73d44b3844927e /src/bootstrap | |
| parent | e7342b8f4233b67093c62c4044273185312aac59 (diff) | |
| download | rust-cd33d3a0e49f67fdeebb8e19593f10b95e5719ee.tar.gz rust-cd33d3a0e49f67fdeebb8e19593f10b95e5719ee.zip | |
Stub out various functions during testing
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/builder.rs | 2 | ||||
| -rw-r--r-- | src/bootstrap/compile.rs | 4 | ||||
| -rw-r--r-- | src/bootstrap/doc.rs | 1 | ||||
| -rw-r--r-- | src/bootstrap/lib.rs | 29 | ||||
| -rw-r--r-- | src/bootstrap/native.rs | 12 | ||||
| -rw-r--r-- | src/bootstrap/tool.rs | 6 | ||||
| -rw-r--r-- | src/bootstrap/util.rs | 3 |
7 files changed, 45 insertions, 12 deletions
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 6ae19ac394e..c2a53e4590e 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -687,7 +687,7 @@ impl<'a> Builder<'a> { // the options through environment variables that are fetched and understood by both. // // FIXME: the guard against msvc shouldn't need to be here - if !target.contains("msvc") { + if !target.contains("msvc") && !cfg!(test) { let ccache = self.config.ccache.as_ref(); let ccacheify = |s: &Path| { let ccache = match ccache { diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index e6aa78fba52..54b0ed6bb35 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -690,6 +690,9 @@ impl Step for CodegenBackend { cargo.arg("--features").arg(features), &tmp_stamp, false); + if cfg!(test) { + return; + } let mut files = files.into_iter() .filter(|f| { let filename = f.file_name().unwrap().to_str().unwrap(); @@ -719,6 +722,7 @@ impl Step for CodegenBackend { fn copy_codegen_backends_to_sysroot(builder: &Builder, compiler: Compiler, target_compiler: Compiler) { + if cfg!(test) { return; } let build = builder.build; let target = target_compiler.host; diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index 44073a5b075..5f3d9ecfc04 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -817,6 +817,7 @@ impl Step for UnstableBookGen { } fn symlink_dir_force(src: &Path, dst: &Path) -> io::Result<()> { + if cfg!(test) { return Ok(()); } if let Ok(m) = fs::symlink_metadata(dst) { if m.file_type().is_dir() { try!(fs::remove_dir_all(dst)); diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index cad4a794cf0..a4287df677e 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -363,16 +363,19 @@ impl Build { 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); @@ -419,6 +422,7 @@ impl 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) { @@ -593,12 +597,14 @@ impl Build { /// 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) } @@ -607,6 +613,7 @@ impl Build { /// 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) } @@ -615,6 +622,7 @@ impl Build { /// 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) } @@ -685,6 +693,7 @@ impl Build { /// 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) diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index f923ad46bcb..f95f8e01dae 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -60,6 +60,9 @@ impl Step for Llvm { /// 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; @@ -336,6 +339,9 @@ impl Step for Lld { /// 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; @@ -389,6 +395,9 @@ impl Step for TestHelpers { /// 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); @@ -441,6 +450,9 @@ impl Step for Openssl { } fn run(self, builder: &Builder) { + if cfg!(test) { + return; + } let build = builder.build; let target = self.target; let out = match build.openssl_dir(target) { diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index 2bb46cc5171..362ec0c3b50 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -199,7 +199,11 @@ impl Step for ToolBuild { if !is_expected { if !is_ext_tool { - exit(1); + if cfg!(test) { + panic!("unexpected failure -- would have hard exited"); + } else { + exit(1); + } } else { return None; } diff --git a/src/bootstrap/util.rs b/src/bootstrap/util.rs index 492eceef05c..99d0548a05e 100644 --- a/src/bootstrap/util.rs +++ b/src/bootstrap/util.rs @@ -34,6 +34,7 @@ pub fn staticlib(name: &str, target: &str) -> String { /// 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. @@ -66,6 +67,7 @@ pub fn replace_in_file(path: &Path, replacements: &[(&str, &str)]) { } 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)); @@ -215,6 +217,7 @@ impl Drop for TimeIt { /// 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); |
