Tests
This commit is contained in:
parent
534556a445
commit
baedc3b70f
9 changed files with 153 additions and 2 deletions
|
@ -1185,6 +1185,9 @@ pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec<c
|
|||
Some(ref n) if *n == "rlib" => {
|
||||
Some(config::CrateTypeRlib)
|
||||
}
|
||||
Some(ref n) if *n == "metadata" => {
|
||||
Some(config::CrateTypeMetadata)
|
||||
}
|
||||
Some(ref n) if *n == "dylib" => {
|
||||
Some(config::CrateTypeDylib)
|
||||
}
|
||||
|
|
17
src/test/compile-fail/auxiliary/rmeta_meta.rs
Normal file
17
src/test/compile-fail/auxiliary/rmeta_meta.rs
Normal file
|
@ -0,0 +1,17 @@
|
|||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// no-prefer-dynamic
|
||||
|
||||
#![crate_type="metadata"]
|
||||
|
||||
pub struct Foo {
|
||||
pub field: i32,
|
||||
}
|
15
src/test/compile-fail/auxiliary/rmeta_rlib.rs
Normal file
15
src/test/compile-fail/auxiliary/rmeta_rlib.rs
Normal file
|
@ -0,0 +1,15 @@
|
|||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![crate_type="rlib"]
|
||||
|
||||
pub struct Foo {
|
||||
pub field: i32,
|
||||
}
|
25
src/test/compile-fail/rmeta-lib-pass.rs
Normal file
25
src/test/compile-fail/rmeta-lib-pass.rs
Normal file
|
@ -0,0 +1,25 @@
|
|||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:rmeta_rlib.rs
|
||||
// no-prefer-dynamic
|
||||
// must-compile-successfully
|
||||
|
||||
// Check that building a metadata crate works with a dependent, rlib crate.
|
||||
// This is a cfail test since there is no executable to run.
|
||||
|
||||
#![crate_type="metadata"]
|
||||
|
||||
extern crate rmeta_rlib;
|
||||
use rmeta_rlib::Foo;
|
||||
|
||||
pub fn main() {
|
||||
let _ = Foo { field: 42 };
|
||||
}
|
26
src/test/compile-fail/rmeta-pass.rs
Normal file
26
src/test/compile-fail/rmeta-pass.rs
Normal file
|
@ -0,0 +1,26 @@
|
|||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:rmeta_meta.rs
|
||||
// no-prefer-dynamic
|
||||
// must-compile-successfully
|
||||
|
||||
// Check that building a metadata crate works with a dependent, metadata-only
|
||||
// crate.
|
||||
// This is a cfail test since there is no executable to run.
|
||||
|
||||
#![crate_type="metadata"]
|
||||
|
||||
extern crate rmeta_meta;
|
||||
use rmeta_meta::Foo;
|
||||
|
||||
pub fn main() {
|
||||
let _ = Foo { field: 42 };
|
||||
}
|
19
src/test/compile-fail/rmeta.rs
Normal file
19
src/test/compile-fail/rmeta.rs
Normal file
|
@ -0,0 +1,19 @@
|
|||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// no-prefer-dynamic
|
||||
|
||||
// Check that building a metadata crate finds an error.
|
||||
|
||||
#![crate_type="metadata"]
|
||||
|
||||
fn main() {
|
||||
let _ = Foo; //~ ERROR unresolved name `Foo`
|
||||
}
|
23
src/test/compile-fail/rmeta_lib.rs
Normal file
23
src/test/compile-fail/rmeta_lib.rs
Normal file
|
@ -0,0 +1,23 @@
|
|||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:rmeta_meta.rs
|
||||
// no-prefer-dynamic
|
||||
// error-pattern: crate `rmeta_meta` required to be available in rlib, but it was not available
|
||||
|
||||
// Check that building a non-metadata crate fails if a dependent crate is
|
||||
// metadata-only.
|
||||
|
||||
extern crate rmeta_meta;
|
||||
use rmeta_meta::Foo;
|
||||
|
||||
fn main() {
|
||||
let _ = Foo { field: 42 };
|
||||
}
|
24
src/test/compile-fail/rmeta_meta_main.rs
Normal file
24
src/test/compile-fail/rmeta_meta_main.rs
Normal file
|
@ -0,0 +1,24 @@
|
|||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:rmeta_meta.rs
|
||||
// no-prefer-dynamic
|
||||
|
||||
// Check that building a metadata crate finds an error with a dependent,
|
||||
// metadata-only crate.
|
||||
|
||||
#![crate_type="metadata"]
|
||||
|
||||
extern crate rmeta_meta;
|
||||
use rmeta_meta::Foo;
|
||||
|
||||
fn main() {
|
||||
let _ = Foo { field2: 42 }; //~ ERROR struct `rmeta_meta::Foo` has no field named `field2`
|
||||
}
|
|
@ -396,8 +396,7 @@ actual:\n\
|
|||
|
||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||
let mut args = vec!["-".to_owned(),
|
||||
"--emit".to_owned(),
|
||||
"metadata".to_owned(),
|
||||
"-Zno-trans".to_owned(),
|
||||
"--out-dir".to_owned(),
|
||||
out_dir.to_str().unwrap().to_owned(),
|
||||
format!("--target={}", target),
|
||||
|
|
Loading…
Reference in a new issue