Rollup merge of #37176 - alexcrichton:no-write-to-root, r=brson

test: Don't write files into the source tree

Tweak a few run-make tests to emit files in the output directories, not directly
in the source tree.
This commit is contained in:
Eduard-Mihai Burtescu 2016-10-19 08:00:00 +03:00 committed by GitHub
commit 5c643435d1
3 changed files with 11 additions and 5 deletions

View File

@ -5,9 +5,12 @@
ifneq ($(shell uname),FreeBSD)
ifndef IS_WINDOWS
all:
$(RUSTC) --emit link,dep-info --crate-type=lib lib.rs
cp lib.rs $(TMPDIR)/
cp 'foo foo.rs' $(TMPDIR)/
cp bar.rs $(TMPDIR)/
$(RUSTC) --emit link,dep-info --crate-type=lib $(TMPDIR)/lib.rs
sleep 1
touch 'foo foo.rs'
touch $(TMPDIR)/'foo foo.rs'
-rm -f $(TMPDIR)/done
$(MAKE) -drf Makefile.foo
rm $(TMPDIR)/done

View File

@ -1,7 +1,7 @@
LIB := $(shell $(RUSTC) --print file-names --crate-type=lib lib.rs)
LIB := $(shell $(RUSTC) --print file-names --crate-type=lib $(TMPDIR)/lib.rs)
$(TMPDIR)/$(LIB):
$(RUSTC) --emit link,dep-info --crate-type=lib lib.rs
$(RUSTC) --emit link,dep-info --crate-type=lib $(TMPDIR)/lib.rs
touch $(TMPDIR)/done
-include $(TMPDIR)/lib.d

View File

@ -22,6 +22,7 @@ use rustc_driver::driver::CompileController;
use rustc_trans::ModuleSource;
use rustc::session::Session;
use syntax::codemap::FileLoader;
use std::env;
use std::io;
use std::path::{PathBuf, Path};
@ -75,9 +76,11 @@ fn main() {
path.pop();
path.pop();
let args: Vec<String> =
let mut args: Vec<String> =
format!("_ _ --sysroot {} --crate-type dylib", path.to_str().unwrap())
.split(' ').map(|s| s.to_string()).collect();
args.push("--out-dir".to_string());
args.push(env::var("TMPDIR").unwrap());
let (result, _) = rustc_driver::run_compiler(
&args, &mut JitCalls, Some(box JitLoader), None);