Skip to content

Commit 38b927d

Browse files
committed
Use stable libtest
1 parent 3e99253 commit 38b927d

File tree

6 files changed

+45
-53
lines changed

6 files changed

+45
-53
lines changed

.travis.yml

+1-4
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@ language: rust
22
matrix:
33
include:
44
- rust: nightly
5-
env: FEATURES=""
5+
env: FEATURES="--features unstable"
66
- rust: beta
7-
env: FEATURES="--features stable"
87
- rust: stable
9-
env: FEATURES="--features stable"
108
- rust: nightly
11-
env: FEATURES="--features stable"
129

1310
script: cd test-project && cargo test $FEATURES
1411

Cargo.toml

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "compiletest_rs"
3-
version = "0.3.20"
3+
version = "0.4.0"
44
authors = [ "The Rust Project Developers"
55
, "Thomas Bracht Laumann Jespersen <laumann.thomas@gmail.com>"
66
, "Manish Goregaokar <manishsmail@gmail.com>"
@@ -25,8 +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 }
29-
libtest = "0.0.1"
28+
libtest = { git = "https://github.com/gnzlbg/libtest", branch = "clippy_ci" }
3029

3130
[target."cfg(unix)".dependencies]
3231
libc = "0.2"
@@ -37,5 +36,4 @@ winapi = { version = "0.3", features = ["winerror"] }
3736

3837
[features]
3938
tmp = ["tempfile"]
40-
norustc = []
41-
stable = ["norustc", "tester"]
39+
unstable = [ "libtest/unstable" ]

appveyor.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ install:
1515
build: false
1616

1717
test_script:
18-
- if %CHANNEL%==stable (cargo build --features stable) else (cargo build)
19-
- cd test-project && if %CHANNEL%==stable (cargo test --features stable) else (cargo test)
18+
- if %CHANNEL%==stable (cargo build) else (cargo build --features=unstable)
19+
- cd test-project && if %CHANNEL%==stable (cargo test) else (cargo test --features=unstable)
2020

2121
branches:
2222
only:

build.rs

+1-1
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_UNSTABLE").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

+15-14
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ 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 = "unstable")]
1818
use rustc;
1919

20-
use test::ColorConfig;
20+
use libtest::ColorChoice;
2121
use runtest::dylib_env_var;
2222

2323
#[derive(Clone, Copy, PartialEq, Debug)]
@@ -210,7 +210,7 @@ pub struct Config {
210210
pub quiet: bool,
211211

212212
/// Whether to use colors in test.
213-
pub color: ColorConfig,
213+
pub color: ColorChoice,
214214

215215
/// where to find the remote test client process, if we're using it
216216
pub remote_test_client: Option<PathBuf>,
@@ -327,8 +327,15 @@ pub use self::config_tempdir::ConfigWithTemp;
327327

328328
impl Default for Config {
329329
fn default() -> Config {
330-
#[cfg(not(feature = "norustc"))]
331-
let platform = rustc::session::config::host_triple().to_string();
330+
#[cfg(feature = "unstable")]
331+
let (target, host) = {
332+
let platform = rustc::session::config::host_triple().to_string();
333+
(platform.clone(), platform.clone())
334+
};
335+
#[cfg(not(feature = "unstable"))]
336+
let (target, host) = {
337+
(env!("TARGET").to_string(), env!("HOST").to_string())
338+
};
332339

333340
Config {
334341
compile_lib_path: PathBuf::from(""),
@@ -351,14 +358,8 @@ impl Default for Config {
351358
runtool: None,
352359
host_rustcflags: None,
353360
target_rustcflags: None,
354-
#[cfg(not(feature = "norustc"))]
355-
target: platform.clone(),
356-
#[cfg(feature = "norustc")]
357-
target: env!("TARGET").to_string(),
358-
#[cfg(not(feature = "norustc"))]
359-
host: platform.clone(),
360-
#[cfg(feature = "norustc")]
361-
host: env!("HOST").to_string(),
361+
target,
362+
host,
362363
gdb: None,
363364
gdb_version: None,
364365
gdb_native_rust: false,
@@ -372,7 +373,7 @@ impl Default for Config {
372373
lldb_python_dir: None,
373374
verbose: false,
374375
quiet: false,
375-
color: ColorConfig::AutoColor,
376+
color: ColorChoice::Auto,
376377
remote_test_client: None,
377378
cc: "cc".to_string(),
378379
cxx: "cxx".to_string(),

src/lib.rs

+23-27
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,15 @@
99
// except according to those terms.
1010

1111
#![crate_type = "lib"]
12-
13-
#![cfg_attr(not(feature = "norustc"), feature(rustc_private))]
14-
#![cfg_attr(not(feature = "stable"), feature(test))]
15-
1612
#![deny(unused_imports)]
13+
#![cfg_attr(feature = "unstable", feature(rustc_private))]
1714

18-
#[cfg(not(feature = "norustc"))]
15+
#[cfg(feature = "unstable")]
1916
extern crate rustc;
2017

2118
#[cfg(unix)]
2219
extern crate libc;
23-
extern crate libtest as test;
20+
extern crate libtest;
2421

2522
#[cfg(feature = "tmp")] extern crate tempfile;
2623

@@ -84,7 +81,7 @@ pub fn run_tests(config: &Config) {
8481
// Prevent issue #21352 UAC blocking .exe containing 'patch' etc. on Windows
8582
// If #11207 is resolved (adding manifest to .exe) this becomes unnecessary
8683
env::set_var("__COMPAT_LAYER", "RunAsInvoker");
87-
let res = test::run_tests_console(&opts, tests.into_iter().collect());
84+
let res = libtest::run_tests_console(&opts, tests.into_iter().collect());
8885
match res {
8986
Ok(true) => {}
9087
Ok(false) => panic!("Some tests failed"),
@@ -94,30 +91,30 @@ pub fn run_tests(config: &Config) {
9491
}
9592
}
9693

97-
pub fn test_opts(config: &Config) -> test::TestOpts {
98-
test::TestOpts {
94+
pub fn test_opts(config: &Config) -> libtest::TestOpts {
95+
libtest::TestOpts {
9996
filter: config.filter.clone(),
10097
filter_exact: config.filter_exact,
10198
#[cfg(not(feature = "stable"))]
10299
exclude_should_panic: false,
103-
run_ignored: if config.run_ignored { test::RunIgnored::Yes } else { test::RunIgnored::No },
104-
format: if config.quiet { test::OutputFormat::Terse } else { test::OutputFormat::Pretty },
100+
run_ignored: if config.run_ignored { libtest::RunIgnored::Yes } else { libtest::RunIgnored::No },
101+
format: if config.quiet { libtest::OutputFormat::Terse } else { libtest::OutputFormat::Pretty },
105102
logfile: config.logfile.clone(),
106103
run_tests: true,
107104
bench_benchmarks: true,
108105
nocapture: match env::var("RUST_TEST_NOCAPTURE") {
109106
Ok(val) => &val != "0",
110107
Err(_) => false
111108
},
112-
color: test::AutoColor,
109+
color: libtest::ColorChoice::Auto,
113110
test_threads: None,
114111
skip: vec![],
115112
list: false,
116-
options: test::Options::new(),
113+
options: libtest::Options::new(),
117114
}
118115
}
119116

120-
pub fn make_tests(config: &Config) -> Vec<test::TestDescAndFn> {
117+
pub fn make_tests(config: &Config) -> Vec<libtest::TestDescAndFn> {
121118
debug!("making tests from {:?}",
122119
config.src_base.display());
123120
let mut tests = Vec::new();
@@ -134,7 +131,7 @@ fn collect_tests_from_dir(config: &Config,
134131
base: &Path,
135132
dir: &Path,
136133
relative_dir_path: &Path,
137-
tests: &mut Vec<test::TestDescAndFn>)
134+
tests: &mut Vec<libtest::TestDescAndFn>)
138135
-> io::Result<()> {
139136
// Ignore directories that contain a file
140137
// `compiletest-ignore-dir`.
@@ -224,23 +221,23 @@ pub fn is_test(file_name: &OsString) -> bool {
224221
!invalid_prefixes.iter().any(|p| file_name.starts_with(p))
225222
}
226223

227-
pub fn make_test(config: &Config, testpaths: &TestPaths) -> test::TestDescAndFn {
224+
pub fn make_test(config: &Config, testpaths: &TestPaths) -> libtest::TestDescAndFn {
228225
let early_props = EarlyProps::from_file(config, &testpaths.file);
229226

230227
// The `should-fail` annotation doesn't apply to pretty tests,
231228
// since we run the pretty printer across all tests by default.
232229
// If desired, we could add a `should-fail-pretty` annotation.
233230
let should_panic = match config.mode {
234-
Pretty => test::ShouldPanic::No,
231+
Pretty => libtest::ShouldPanic::No,
235232
_ => if early_props.should_fail {
236-
test::ShouldPanic::Yes
233+
libtest::ShouldPanic::Yes
237234
} else {
238-
test::ShouldPanic::No
235+
libtest::ShouldPanic::No
239236
}
240237
};
241238

242-
test::TestDescAndFn {
243-
desc: test::TestDesc {
239+
libtest::TestDescAndFn {
240+
desc: libtest::TestDesc {
244241
name: make_test_name(config, testpaths),
245242
ignore: early_props.ignore,
246243
should_panic: should_panic,
@@ -260,23 +257,22 @@ fn stamp(config: &Config, testpaths: &TestPaths) -> PathBuf {
260257
.join(stamp_name)
261258
}
262259

263-
pub fn make_test_name(config: &Config, testpaths: &TestPaths) -> test::TestName {
260+
pub fn make_test_name(config: &Config, testpaths: &TestPaths) -> libtest::TestName {
264261
// Convert a complete path to something like
265262
//
266263
// run-pass/foo/bar/baz.rs
267264
let path =
268265
PathBuf::from(config.src_base.file_name().unwrap())
269266
.join(&testpaths.relative_dir)
270267
.join(&testpaths.file.file_name().unwrap());
271-
test::DynTestName(format!("[{}] {}", config.mode, path.display()))
268+
libtest::TestName::DynTestName(format!("[{}] {}", config.mode, path.display()))
272269
}
273270

274-
pub fn make_test_closure(config: &Config, testpaths: &TestPaths) -> test::TestFn {
271+
pub fn make_test_closure(config: &Config, testpaths: &TestPaths) -> libtest::TestFn {
275272
let config = config.clone();
276273
let testpaths = testpaths.clone();
277-
test::DynTestFn(Box::new(move || {
278-
#[cfg(feature = "stable")]
279-
let config = config.clone(); // FIXME: why is this needed?
274+
libtest::TestFn::DynTestFn(Box::new(move || {
275+
let config = config.clone();
280276
runtest::run(config, &testpaths)
281277
}))
282278
}

0 commit comments

Comments
 (0)