fix up compile tests

This commit is contained in:
Ashley Mannix 2018-05-17 09:46:05 +10:00
parent 288cd55f3a
commit afa05d22a5
11 changed files with 39 additions and 15 deletions

View File

@ -13,8 +13,10 @@ matrix:
- cargo bench --features nightly
- cargo test --features spin_no_std
- cargo bench --features spin_no_std
- cd compiletest
- cargo clean
- cargo test --features compiletest
- cargo test
- cd ../
- rust: nightly
before_script:

View File

@ -17,14 +17,9 @@ categories = [ "no-std", "rust-patterns", "memory-management" ]
version = "0.4.6"
optional = true
[dependencies.compiletest_rs]
version = "0.3"
optional = true
[features]
nightly = []
spin_no_std = ["nightly", "spin"]
compiletest = ["compiletest_rs"]
[badges]
appveyor = { repository = "rust-lang-nursery/lazy-static.rs" }

View File

@ -53,7 +53,9 @@ test_script:
- cargo build --verbose
- cargo test
- if [%CHANNEL%]==[nightly] (
cd compiletest &&
cargo clean &&
cargo build --verbose --features "compiletest" &&
cargo test --features "compiletest"
cargo build --verbose &&
cargo test &&
cd ../
)

11
compiletest/Cargo.toml Normal file
View File

@ -0,0 +1,11 @@
[package]
name = "lazy_static_compiletest"
version = "0.0.1"
publish = false
authors = ["lazy_static contributors"]
[dependencies.lazy_static]
path = "../"
[dependencies.compiletest_rs]
version = "0.3"

13
compiletest/src/lib.rs Normal file
View File

@ -0,0 +1,13 @@
/*
This library is a shim around `lazy_static` that disambiguates it with the `lazy_static`
that's shipped with the Rust toolchain. We re-export the entire public API of `lazy_static`
under a different crate name so that can be imported in the compile tests.
This currently appears to use the right local build of `lazy_static`.
*/
#![feature(use_extern_macros)]
extern crate lazy_static;
pub use self::lazy_static::*;

View File

@ -3,7 +3,7 @@ warning/note/help/error at compilation. Syntax of annotations is described in
[rust documentation](https://github.com/rust-lang/rust/blob/master/src/test/COMPILER_TESTS.md).
For more information check out [`compiletest` crate](https://github.com/laumann/compiletest-rs).
To run compile tests issue `cargo +nightly --test --features compiletest`.
To run compile tests issue `cargo +nightly --test`.
## Notes on working with `compiletest` crate

View File

@ -1,6 +1,6 @@
// incorrect visibility restriction
#[macro_use]
extern crate lazy_static;
extern crate lazy_static_compiletest as lazy_static;
lazy_static! {
pub(nonsense) static ref WRONG: () = ();

View File

@ -1,5 +1,5 @@
#[macro_use]
extern crate lazy_static;
extern crate lazy_static_compiletest as lazy_static;
mod outer {
pub mod inner {

View File

@ -1,6 +1,6 @@
// error-pattern:the trait bound `str: std::marker::Sized` is not satisfied
#[macro_use]
extern crate lazy_static;
extern crate lazy_static_compiletest as lazy_static;
lazy_static! {
pub static ref FOO: str = panic!();

View File

@ -1,7 +1,7 @@
// error-pattern:static item is never used: `UNUSED`
#![deny(dead_code)]
#[macro_use]
extern crate lazy_static;
extern crate lazy_static_compiletest as lazy_static;
lazy_static! {
static ref UNUSED: () = ();

View File

@ -1,14 +1,15 @@
#![cfg(feature="compiletest")]
extern crate compiletest_rs as compiletest;
fn run_mode(mode: &'static str) {
let mut config = compiletest::Config::default();
config.mode = mode.parse().expect("Invalid mode");
config.src_base = ["tests", mode].iter().collect();
config.target_rustcflags = Some("-L target/debug/ -L target/debug/deps/".to_owned());
config.verbose = true;
config.target_rustcflags = Some("-L target/debug/ -L target/debug/deps/".to_owned());
config.clean_rmeta();
compiletest::run_tests(&config);
}