Skip to content

Commit e42efed

Browse files
committed
Make rustc an opt-in feature, use tester for test crate
1 parent 4371d7d commit e42efed

File tree

8 files changed

+21
-29
lines changed

8 files changed

+21
-29
lines changed

.travis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ language: rust
22
matrix:
33
include:
44
- rust: nightly
5-
env: FEATURES=""
5+
env: FEATURES="--features rustc"
66
before_script:
77
rustup component add rustc-dev
88
- rust: beta
9-
env: FEATURES="--features stable"
9+
env: FEATURES=""
1010
- rust: stable
11-
env: FEATURES="--features stable"
11+
env: FEATURES=""
1212
- rust: nightly
13-
env: FEATURES="--features stable"
13+
env: FEATURES=""
1414

1515
script: cd test-project && cargo test $FEATURES
1616

Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ serde = "1.0"
2525
serde_json = "1.0"
2626
serde_derive = "1.0"
2727
rustfix = "0.4.1"
28-
tester = { version = "0.5", optional = true }
28+
tester = { version = "0.5" }
2929

3030
[target."cfg(unix)".dependencies]
3131
libc = "0.2"
@@ -36,5 +36,4 @@ winapi = { version = "0.3", features = ["winerror"] }
3636

3737
[features]
3838
tmp = ["tempfile"]
39-
norustc = []
40-
stable = ["norustc", "tester"]
39+
rustc = []

appveyor.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,16 @@ install:
99
- curl -sSf -o rustup-init.exe https://win.rustup.rs
1010
- rustup-init.exe --default-host %TARGET% --default-toolchain %CHANNEL% -y
1111
- set PATH=%PATH%;C:\Users\appveyor\.cargo\bin;C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin
12+
- if %CHANNEL%==nightly (rustup component add rustc-dev) else (true)
1213
- gcc --version
1314
- rustc -Vv
1415
- cargo -V
1516

1617
build: false
1718

1819
test_script:
19-
- if %CHANNEL%==stable (cargo build --features stable) else (cargo build)
20-
- cd test-project && if %CHANNEL%==stable (cargo test --features stable) else (cargo test)
20+
- if %CHANNEL%==nightly (cargo build --features rustc) else (cargo build)
21+
- cd test-project && if %CHANNEL%==nightly (cargo test --features rustc) else (cargo test)
2122

2223
branches:
2324
only:

build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::env;
22

33
pub fn main() {
4-
if env::var("CARGO_FEATURE_NORUSTC").is_ok() {
4+
if env::var("CARGO_FEATURE_RUSTC").is_err() {
55
println!("cargo:rustc-env=TARGET={}", env::var("TARGET").unwrap());
66
println!("cargo:rustc-env=HOST={}", env::var("HOST").unwrap());
77
}

src/common.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use std::fmt;
1414
use std::fs::{read_dir, remove_file};
1515
use std::str::FromStr;
1616
use std::path::PathBuf;
17-
#[cfg(not(feature = "norustc"))]
17+
#[cfg(feature = "rustc")]
1818
use rustc;
1919

2020
use test::ColorConfig;
@@ -331,7 +331,7 @@ pub use self::config_tempdir::ConfigWithTemp;
331331

332332
impl Default for Config {
333333
fn default() -> Config {
334-
#[cfg(not(feature = "norustc"))]
334+
#[cfg(feature = "rustc")]
335335
let platform = rustc::session::config::host_triple().to_string();
336336

337337
Config {
@@ -355,13 +355,13 @@ impl Default for Config {
355355
runtool: None,
356356
host_rustcflags: None,
357357
target_rustcflags: None,
358-
#[cfg(not(feature = "norustc"))]
358+
#[cfg(feature = "rustc")]
359359
target: platform.clone(),
360-
#[cfg(feature = "norustc")]
360+
#[cfg(not(feature = "rustc"))]
361361
target: env!("TARGET").to_string(),
362-
#[cfg(not(feature = "norustc"))]
362+
#[cfg(feature = "rustc")]
363363
host: platform.clone(),
364-
#[cfg(feature = "norustc")]
364+
#[cfg(not(feature = "rustc"))]
365365
host: env!("HOST").to_string(),
366366
rustfix_coverage: false,
367367
gdb: None,

src/lib.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@
1010

1111
#![crate_type = "lib"]
1212

13-
#![cfg_attr(not(feature = "norustc"), feature(rustc_private))]
14-
#![cfg_attr(not(feature = "stable"), feature(test))]
13+
#![cfg_attr(feature = "rustc", feature(rustc_private))]
1514

1615
#![deny(unused_imports)]
1716

18-
#[cfg(not(feature = "norustc"))]
17+
#[cfg(feature = "rustc")]
1918
extern crate rustc;
2019

2120
#[cfg(unix)]
@@ -110,8 +109,6 @@ pub fn test_opts(config: &Config) -> test::TestOpts {
110109
test::TestOpts {
111110
filter: config.filter.clone(),
112111
filter_exact: config.filter_exact,
113-
#[cfg(not(feature = "stable"))]
114-
exclude_should_panic: false,
115112
run_ignored: if config.run_ignored { test::RunIgnored::Yes } else { test::RunIgnored::No },
116113
format: if config.quiet { test::OutputFormat::Terse } else { test::OutputFormat::Pretty },
117114
logfile: config.logfile.clone(),
@@ -126,8 +123,6 @@ pub fn test_opts(config: &Config) -> test::TestOpts {
126123
skip: vec![],
127124
list: false,
128125
options: test::Options::new(),
129-
#[cfg(not(feature = "stable"))]
130-
time_options: None,
131126
}
132127
}
133128

@@ -259,8 +254,6 @@ pub fn make_test(config: &Config, testpaths: &TestPaths) -> test::TestDescAndFn
259254
ignore: early_props.ignore,
260255
should_panic: should_panic,
261256
allow_fail: false,
262-
#[cfg(not(feature = "stable"))]
263-
test_type: test::TestType::IntegrationTest,
264257
},
265258
testfn: make_test_closure(config, testpaths),
266259
}
@@ -291,7 +284,6 @@ pub fn make_test_closure(config: &Config, testpaths: &TestPaths) -> test::TestFn
291284
let config = config.clone();
292285
let testpaths = testpaths.clone();
293286
test::DynTestFn(Box::new(move || {
294-
#[cfg(feature = "stable")]
295287
let config = config.clone(); // FIXME: why is this needed?
296288
runtest::run(config, &testpaths)
297289
}))

test-project/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ path = ".."
1010
features = ["tmp"]
1111

1212
[features]
13-
stable = ["compiletest_rs/stable"]
13+
rustc = ["compiletest_rs/rustc"]

test-project/tests/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ fn compile_test() {
2222
run_mode("run-pass", None);
2323
run_mode("ui", None);
2424

25-
#[cfg(not(feature = "stable"))]
25+
#[cfg(feature = "rustc")]
2626
run_mode("pretty", None);
27-
#[cfg(not(feature = "stable"))]
27+
#[cfg(feature = "rustc")]
2828
run_mode("ui", Some("nightly"));
2929
}

0 commit comments

Comments
 (0)