From 56e4c82a38cfb2bcf7de2d6323dab0073a70726d Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 28 Nov 2013 18:03:38 -0800 Subject: [PATCH] Test fixes and merge conflicts --- mk/tests.mk | 5 +- src/etc/maketest.py | 1 + src/libextra/lib.rs | 1 + src/librustc/back/archive.rs | 16 ++++- src/librustc/back/link.rs | 7 +- src/librustc/driver/session.rs | 72 ------------------- src/librustc/front/feature_gate.rs | 2 +- src/librustc/lib.rs | 1 + src/librustc/metadata/creader.rs | 8 +-- src/librustc/metadata/decoder.rs | 4 +- src/librustc/metadata/loader.rs | 10 +-- src/librustc/middle/lint.rs | 4 +- src/librustuv/lib.rs | 1 + src/librustuv/uvll.rs | 2 +- src/libstd/lib.rs | 1 + src/test/run-make/tools.mk | 4 +- .../run-pass/anon-extern-mod-cross-crate-2.rs | 1 + src/test/run-pass/invoke-external-foreign.rs | 1 + 18 files changed, 44 insertions(+), 97 deletions(-) diff --git a/mk/tests.mk b/mk/tests.mk index 5b021eb48f15f..3b4a490f1adfc 100644 --- a/mk/tests.mk +++ b/mk/tests.mk @@ -924,9 +924,10 @@ $(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \ @rm -rf $(3)/test/run-make/$$* @mkdir -p $(3)/test/run-make/$$* @echo maketest: $$* - @python $(S)src/etc/maketest.py $$(dir $$<) \ + $$(Q)python $(S)src/etc/maketest.py $$(dir $$<) \ $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \ - $(3)/test/run-make/$$* + $(3)/test/run-make/$$* \ + "$$(CC_$(3)) $$(CFG_GCCISH_CFLAGS_$(3))" @touch $$@ endef diff --git a/src/etc/maketest.py b/src/etc/maketest.py index d42bf06565767..96c658e56864b 100644 --- a/src/etc/maketest.py +++ b/src/etc/maketest.py @@ -6,6 +6,7 @@ os.putenv('RUSTC', os.path.abspath(sys.argv[2])) os.putenv('TMPDIR', os.path.abspath(sys.argv[3])) +os.putenv('CC', sys.argv[4]) proc = subprocess.Popen(['make', '-C', sys.argv[1]], stdout = subprocess.PIPE, diff --git a/src/libextra/lib.rs b/src/libextra/lib.rs index 571891f1830a4..ce504d8bf6fcf 100644 --- a/src/libextra/lib.rs +++ b/src/libextra/lib.rs @@ -40,6 +40,7 @@ Rust extras are part of the standard Rust distribution. #[deny(non_camel_case_types)]; #[deny(missing_doc)]; +#[allow(attribute_usage)]; // NOTE: remove after the next snapshot use std::str::{StrSlice, OwnedStr}; diff --git a/src/librustc/back/archive.rs b/src/librustc/back/archive.rs index e3c8e859f72a4..9f5aaf3a42624 100644 --- a/src/librustc/back/archive.rs +++ b/src/librustc/back/archive.rs @@ -27,7 +27,7 @@ pub struct Archive { fn run_ar(sess: Session, args: &str, cwd: Option<&Path>, paths: &[&Path]) -> ProcessOutput { - let ar = sess.opts.ar.clone().unwrap_or(~"ar"); + let ar = sess.opts.ar.clone().unwrap_or_else(|| ~"ar"); let mut args = ~[args.to_owned()]; let mut paths = paths.iter().map(|p| p.as_str().unwrap().to_owned()); args.extend(&mut paths); @@ -64,7 +64,17 @@ impl Archive { /// Read a file in the archive pub fn read(&self, file: &str) -> ~[u8] { - run_ar(self.sess, "p", None, [&self.dst, &Path::new(file)]).output + // Apparently if "ar p" is used on windows, it generates a corrupt file + // which has bad headers and LLVM will immediately choke on it + if cfg!(windows) && cfg!(windows) { // FIXME(#10734) double-and + let loc = TempDir::new("rsar").unwrap(); + let archive = os::make_absolute(&self.dst); + run_ar(self.sess, "x", Some(loc.path()), [&archive, + &Path::init(file)]); + fs::File::open(&loc.path().join(file)).read_to_end() + } else { + run_ar(self.sess, "p", None, [&self.dst, &Path::init(file)]).output + } } /// Adds all of the contents of a native library to this archive. This will @@ -77,7 +87,7 @@ impl Archive { /// Adds all of the contents of the rlib at the specified path to this /// archive. pub fn add_rlib(&mut self, rlib: &Path) { - let name = rlib.filename_str().unwrap().split_iter('-').next().unwrap(); + let name = rlib.filename_str().unwrap().split('-').next().unwrap(); self.add_archive(rlib, name); } diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs index 98d5958ac4f31..8119618da57dc 100644 --- a/src/librustc/back/link.rs +++ b/src/librustc/back/link.rs @@ -1112,7 +1112,7 @@ fn link_args(sess: Session, // follow this flag. Thus, use it before specifing libraries to link to. args.push(~"-Wl,--as-needed"); - // GNU-style linkers supports optimization with -O. --gc-sections + // GNU-style linkers support optimization with -O. --gc-sections // removes metadata and potentially other useful things, so don't // include it. GNU ld doesn't need a numeric argument, but other linkers // do. @@ -1212,7 +1212,7 @@ fn add_upstream_rust_crates(args: &mut ~[~str], sess: Session, } } - // This is a fallback of three differnet cases of linking: + // This is a fallback of three different cases of linking: // // * When creating a dynamic library, all inputs are required to be dynamic // as well @@ -1223,7 +1223,8 @@ fn add_upstream_rust_crates(args: &mut ~[~str], sess: Session, let crates = cstore::get_used_crates(cstore, cstore::RequireDynamic); for &(cnum, ref path) in crates.iter() { let cratepath = match *path { - Some(ref p) => p.clone(), None => { + Some(ref p) => p.clone(), + None => { sess.err(format!("could not find dynamic library for: `{}`", cstore::get_crate_data(sess.cstore, cnum).name)); return diff --git a/src/librustc/driver/session.rs b/src/librustc/driver/session.rs index ba9e844941835..e45ea533f7937 100644 --- a/src/librustc/driver/session.rs +++ b/src/librustc/driver/session.rs @@ -420,75 +420,3 @@ pub fn sess_os_to_meta_os(os: abi::Os) -> metadata::loader::Os { abi::OsFreebsd => loader::OsFreebsd } } - -#[cfg(test)] -mod test { - use driver::session::{bin_crate, building_library, lib_crate}; - use driver::session::{unknown_crate}; - - use syntax::ast; - use syntax::attr; - use syntax::codemap; - - fn make_crate_type_attr(t: @str) -> ast::Attribute { - attr::mk_attr(attr::mk_name_value_item_str(@"crate_type", t)) - } - - fn make_crate(with_bin: bool, with_lib: bool) -> @ast::Crate { - let mut attrs = ~[]; - if with_bin { - attrs.push(make_crate_type_attr(@"bin")); - } - if with_lib { - attrs.push(make_crate_type_attr(@"lib")); - } - @ast::Crate { - module: ast::_mod { view_items: ~[], items: ~[] }, - attrs: attrs, - config: ~[], - span: codemap::dummy_sp(), - } - } - - #[test] - fn bin_crate_type_attr_results_in_bin_output() { - let crate = make_crate(true, false); - assert!(!building_library(unknown_crate, crate, false)); - } - - #[test] - fn lib_crate_type_attr_results_in_lib_output() { - let crate = make_crate(false, true); - assert!(building_library(unknown_crate, crate, false)); - } - - #[test] - fn bin_option_overrides_lib_crate_type() { - let crate = make_crate(false, true); - assert!(!building_library(bin_crate, crate, false)); - } - - #[test] - fn lib_option_overrides_bin_crate_type() { - let crate = make_crate(true, false); - assert!(building_library(lib_crate, crate, false)); - } - - #[test] - fn bin_crate_type_is_default() { - let crate = make_crate(false, false); - assert!(!building_library(unknown_crate, crate, false)); - } - - #[test] - fn test_option_overrides_lib_crate_type() { - let crate = make_crate(false, true); - assert!(!building_library(unknown_crate, crate, true)); - } - - #[test] - fn test_option_does_not_override_requested_lib_type() { - let crate = make_crate(false, false); - assert!(building_library(lib_crate, crate, true)); - } -} diff --git a/src/librustc/front/feature_gate.rs b/src/librustc/front/feature_gate.rs index 3cff0b81e875e..d18a8306812c9 100644 --- a/src/librustc/front/feature_gate.rs +++ b/src/librustc/front/feature_gate.rs @@ -135,7 +135,7 @@ impl Visitor<()> for Context { } } - ast::item_foreign_mod(*) => { + ast::item_foreign_mod(..) => { if attr::contains_name(i.attrs, "link_args") && cfg!(stage0, remove_this_on_next_snapshot) { // NOTE: snap self.gate_feature("link_args", i.span, diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 90a005568b6b6..e0073e7ce12e1 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -20,6 +20,7 @@ #[crate_type = "dylib"]; #[feature(macro_rules, globs, struct_variant, managed_boxes)]; +#[allow(attribute_usage)]; // NOTE: remove after the next snapshot extern mod extra; extern mod syntax; diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs index 1f10699b76500..9d28a5abed225 100644 --- a/src/librustc/metadata/creader.rs +++ b/src/librustc/metadata/creader.rs @@ -187,9 +187,9 @@ fn visit_item(e: &Env, i: @ast::item) { for m in link_args.iter() { match m.meta_item_list() { Some(items) => { - let kind = do items.iter().find |k| { + let kind = items.iter().find(|k| { "kind" == k.name() - }.and_then(|a| a.value_str()); + }).and_then(|a| a.value_str()); let kind = match kind { Some(k) if "static" == k => cstore::NativeStatic, Some(k) => { @@ -198,9 +198,9 @@ fn visit_item(e: &Env, i: @ast::item) { } None => cstore::NativeUnknown }; - let n = do items.iter().find |n| { + let n = items.iter().find(|n| { "name" == n.name() - }.and_then(|a| a.value_str()); + }).and_then(|a| a.value_str()); let n = match n { Some(n) => n, None => { diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index c43324456d1f7..441f1620e4d89 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -1533,9 +1533,9 @@ pub fn get_trait_of_method(cdata: Cmd, id: ast::NodeId, tcx: ty::ctxt) pub fn get_native_libraries(cdata: Cmd) -> ~[~str] { let libraries = reader::get_doc(reader::Doc(cdata.data), tag_native_libraries); let mut result = ~[]; - do reader::tagged_docs(libraries, tag_native_libraries_lib) |lib_doc| { + reader::tagged_docs(libraries, tag_native_libraries_lib, |lib_doc| { result.push(lib_doc.as_str()); true - }; + }); return result; } diff --git a/src/librustc/metadata/loader.rs b/src/librustc/metadata/loader.rs index 1aff16cc23c4b..40fca0f42f1a2 100644 --- a/src/librustc/metadata/loader.rs +++ b/src/librustc/metadata/loader.rs @@ -83,7 +83,7 @@ impl Context { let rlib_prefix = format!("lib{}-", crate_name); let mut matches = ~[]; - do filesearch::search(filesearch) |path| { + filesearch::search(filesearch, |path| { match path.filename_str() { None => FileDoesntMatch, Some(file) => { @@ -135,7 +135,7 @@ impl Context { } } } - } + }); match matches.len() { 0 => None, @@ -180,7 +180,7 @@ impl Context { lib.rlib = Some(path.clone()); return true; } - Some(*) | None => {} + Some(..) | None => {} } } return false; @@ -200,7 +200,7 @@ impl Context { lib.dylib = Some(path.clone()); return true; } - Some(*) | None => {} + Some(..) | None => {} } } return false; @@ -360,7 +360,7 @@ pub fn list_file_metadata(sess: Session, let crate_name = path.filename_str().unwrap(); let crate_name = if crate_name.starts_with("lib") { crate_name.slice_from(3) } else { crate_name }; - let crate_name = crate_name.split_iter('-').next().unwrap(); + let crate_name = crate_name.split('-').next().unwrap(); match get_metadata_section(sess, os, path, crate_name) { option::Some(bytes) => decoder::list_crate_metadata(intr, bytes, out), option::None => { diff --git a/src/librustc/middle/lint.rs b/src/librustc/middle/lint.rs index 4c6ca53694a0e..1b2ae78c627bc 100644 --- a/src/librustc/middle/lint.rs +++ b/src/librustc/middle/lint.rs @@ -808,7 +808,7 @@ fn check_heap_item(cx: &Context, it: &ast::item) { } static crate_attrs: &'static [&'static str] = &[ - "crate_type", "link", "feature", "no_uv", "no_main", "no_std", + "crate_type", "feature", "no_uv", "no_main", "no_std", "desc", "comment", "license", "copyright", // not used in rustc now ]; @@ -830,7 +830,7 @@ static other_attrs: &'static [&'static str] = &[ "deprecated", "experimental", "unstable", "stable", "locked", "frozen", //item stability "crate_map", "cfg", "doc", "export_name", "link_section", "no_freeze", "no_mangle", "no_send", "static_assert", "unsafe_no_drop_flag", - "packed", "simd", "repr", "deriving", "unsafe_destructor", + "packed", "simd", "repr", "deriving", "unsafe_destructor", "link", //mod-level "path", "link_name", "link_args", "nolink", "macro_escape", "no_implicit_prelude", diff --git a/src/librustuv/lib.rs b/src/librustuv/lib.rs index feb1c6b92bdec..a43759a6da7b0 100644 --- a/src/librustuv/lib.rs +++ b/src/librustuv/lib.rs @@ -46,6 +46,7 @@ via `close` and `delete` methods. #[crate_type = "dylib"]; #[feature(macro_rules, globs)]; +#[allow(attribute_usage)]; // NOTE: remove after the next snapshot use std::cast::transmute; use std::cast; diff --git a/src/librustuv/uvll.rs b/src/librustuv/uvll.rs index f62ac3450e6eb..ca5c75122a6ef 100644 --- a/src/librustuv/uvll.rs +++ b/src/librustuv/uvll.rs @@ -723,7 +723,7 @@ extern { } // various platform libraries required by libuv -#[cfg(not(stage0))] +#[cfg(not(stage0), not(target_os = "android"))] #[link(name = "pthread")] extern {} #[cfg(stage0)] diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 0489fff31f93a..296091d26e693 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -66,6 +66,7 @@ #[deny(non_camel_case_types)]; #[deny(missing_doc)]; +#[allow(attribute_usage)]; // NOTE: remove after the next snapshot // When testing libstd, bring in libuv as the I/O backend so tests can print // things and all of the std::io tests have an I/O interface to run on top diff --git a/src/test/run-make/tools.mk b/src/test/run-make/tools.mk index 9c7af7f52c188..2d670cb873fb2 100644 --- a/src/test/run-make/tools.mk +++ b/src/test/run-make/tools.mk @@ -19,9 +19,9 @@ endif %.a: %.o ar crus $@ $< %.dylib: %.o - ld -o $@ $< -dylib + $(CC) -dynamiclib -Wl,-dylib -o $@ $< %.so: %.o - ld -o $@ $< -shared + $(CC) -o $@ $< -shared $(TMPDIR)/lib%.o: %.c $(CC) -c -o $@ $< diff --git a/src/test/run-pass/anon-extern-mod-cross-crate-2.rs b/src/test/run-pass/anon-extern-mod-cross-crate-2.rs index 654212270546a..4c2e78db39845 100644 --- a/src/test/run-pass/anon-extern-mod-cross-crate-2.rs +++ b/src/test/run-pass/anon-extern-mod-cross-crate-2.rs @@ -9,6 +9,7 @@ // except according to those terms. // xfail-fast +// xfail-pretty // aux-build:anon-extern-mod-cross-crate-1.rs extern mod anonexternmod; diff --git a/src/test/run-pass/invoke-external-foreign.rs b/src/test/run-pass/invoke-external-foreign.rs index 6850e9d9bd251..ec531d391e422 100644 --- a/src/test/run-pass/invoke-external-foreign.rs +++ b/src/test/run-pass/invoke-external-foreign.rs @@ -9,6 +9,7 @@ // except according to those terms. // xfail-fast +// xfail-pretty // aux-build:foreign_lib.rs // The purpose of this test is to check that we can