Skip to content

Move logic for test output generation forward #10979

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 17, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions src/librustc/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -722,17 +722,10 @@ pub fn link_binary(sess: Session,
obj_filename: &Path,
out_filename: &Path,
lm: &LinkMeta) -> ~[Path] {
// If we're generating a test executable, then ignore all other output
// styles at all other locations
let outputs = if sess.opts.test {
~[session::OutputExecutable]
} else {
(*sess.outputs).clone()
};

let mut out_filenames = ~[];
for output in outputs.move_iter() {
let out_file = link_binary_output(sess, trans, output, obj_filename, out_filename, lm);
for &output in sess.outputs.iter() {
let out_file = link_binary_output(sess, trans, output, obj_filename,
out_filename, lm);
out_filenames.push(out_file);
}

Expand Down
7 changes: 6 additions & 1 deletion src/librustc/driver/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,20 +405,25 @@ pub fn expect<T:Clone>(sess: Session, opt: Option<T>, msg: || -> ~str) -> T {
}

pub fn building_library(options: &options, crate: &ast::Crate) -> bool {
if options.test { return false }
for output in options.outputs.iter() {
match *output {
OutputExecutable => {}
OutputStaticlib | OutputDylib | OutputRlib => return true
}
}
if options.test { return false }
match syntax::attr::first_attr_value_str_by_name(crate.attrs, "crate_type") {
Some(s) => "lib" == s || "rlib" == s || "dylib" == s || "staticlib" == s,
_ => false
}
}

pub fn collect_outputs(options: &options, crate: &ast::Crate) -> ~[OutputStyle] {
// If we're generating a test executable, then ignore all other output
// styles at all other locations
if options.test {
return ~[OutputExecutable];
}
let mut base = options.outputs.clone();
let mut iter = crate.attrs.iter().filter_map(|a| {
if "crate_type" == a.name() {
Expand Down
7 changes: 7 additions & 0 deletions src/test/run-make/no-intermediate-extras/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Regression test for issue #10973

-include ../tools.mk

all:
$(RUSTC) --rlib --test foo.rs
rm $(TMPDIR)/foo.bc && exit 1 || exit 0
Empty file.