Skip to content

Commit 36fe6b3

Browse files
committed
Added support for compiler tests
1 parent 1180240 commit 36fe6b3

File tree

6 files changed

+44
-6
lines changed

6 files changed

+44
-6
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ script:
1515
travis-cargo --only nightly build -- --features spin_no_std &&
1616
travis-cargo --only nightly test -- --features spin_no_std &&
1717
travis-cargo --only nightly bench -- --features spin_no_std &&
18+
travis-cargo --only nightly clean &&
19+
travis-cargo --only nightly build -- --features compiletest &&
20+
travis-cargo --only nightly test -- --features compiletest &&
21+
travis-cargo --only nightly clean &&
1822
travis-cargo --only stable doc
1923
after_success:
2024
- travis-cargo --only stable doc-upload

Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,14 @@ categories = [ "no-std", "rust-patterns" ]
1717
version = "0.4"
1818
optional = true
1919

20+
[dependencies.compiletest_rs]
21+
version = "0.3"
22+
optional = true
23+
2024
[features]
2125
nightly = []
2226
spin_no_std = ["nightly", "spin"]
27+
compiletest = ["compiletest_rs"]
2328

2429
[badges]
2530
appveyor = { repository = "rust-lang-nursery/lazy-static.rs" }

appveyor.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,10 @@ install:
5050
build: false
5151

5252
test_script:
53-
- cargo build --verbose --target %TARGET%
54-
- cargo test --target %TARGET%
53+
- cargo build --verbose
54+
- cargo test
55+
- if [%CHANNEL%]==[nightly] (
56+
cargo clean &&
57+
cargo build --verbose --features "compiletest" &&
58+
cargo test --features "compiletest"
59+
)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// error-pattern:static item is never used: `UNUSED`
2+
#![deny(dead_code)]
3+
#[macro_use]
4+
extern crate lazy_static;
5+
6+
lazy_static! {
7+
static ref UNUSED: () = ();
8+
}
9+
10+
fn main() { }

tests/compile_tests.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#![cfg(feature="compiletest")]
2+
extern crate compiletest_rs as compiletest;
3+
4+
fn run_mode(mode: &'static str) {
5+
let mut config = compiletest::Config::default();
6+
config.mode = mode.parse().expect("Invalid mode");
7+
config.src_base = ["tests", mode].iter().collect();
8+
config.target_rustcflags = Some("-L target/debug/ -L target/debug/deps/".to_owned());
9+
10+
config.verbose = true;
11+
12+
compiletest::run_tests(&config);
13+
}
14+
15+
#[test]
16+
fn compile_test() {
17+
run_mode("compile-fail");
18+
}

tests/test.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ lazy_static! {
2727
static ref UNSAFE: u32 = unsafe {
2828
std::mem::transmute::<i32, u32>(-1)
2929
};
30-
31-
// This *should* triggger warn(dead_code) by design.
32-
static ref UNUSED: () = ();
33-
3430
}
3531

3632
lazy_static! {

0 commit comments

Comments
 (0)