diff --git a/.travis.yml b/.travis.yml index 4226a1b..c7f7227 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,13 +2,10 @@ language: rust matrix: include: - rust: nightly - env: FEATURES="" + env: FEATURES="--features unstable" - rust: beta - env: FEATURES="--features stable" - rust: stable - env: FEATURES="--features stable" - rust: nightly - env: FEATURES="--features stable" script: cd test-project && cargo test $FEATURES diff --git a/Cargo.toml b/Cargo.toml index b99fa4d..db22fe3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "compiletest_rs" -version = "0.3.20" +version = "0.4.0" authors = [ "The Rust Project Developers" , "Thomas Bracht Laumann Jespersen " , "Manish Goregaokar " @@ -25,8 +25,7 @@ serde = "1.0" serde_json = "1.0" serde_derive = "1.0" rustfix = "0.4.1" -tester = { version = "0.5", optional = true } -libtest = "0.0.1" +libtest = { git = "https://github.com/gnzlbg/libtest", branch = "clippy_ci" } [target."cfg(unix)".dependencies] libc = "0.2" @@ -37,5 +36,4 @@ winapi = { version = "0.3", features = ["winerror"] } [features] tmp = ["tempfile"] -norustc = [] -stable = ["norustc", "tester"] +unstable = [ "libtest/unstable" ] \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index 03c1229..ad2575e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -15,8 +15,8 @@ install: build: false test_script: - - if %CHANNEL%==stable (cargo build --features stable) else (cargo build) - - cd test-project && if %CHANNEL%==stable (cargo test --features stable) else (cargo test) + - if %CHANNEL%==stable (cargo build) else (cargo build --features=unstable) + - cd test-project && if %CHANNEL%==stable (cargo test) else (cargo test --features=unstable) branches: only: diff --git a/build.rs b/build.rs index 4976ab5..c7bb305 100644 --- a/build.rs +++ b/build.rs @@ -1,7 +1,7 @@ use std::env; pub fn main() { - if env::var("CARGO_FEATURE_NORUSTC").is_ok() { + if env::var("CARGO_FEATURE_UNSTABLE").is_err() { println!("cargo:rustc-env=TARGET={}", env::var("TARGET").unwrap()); println!("cargo:rustc-env=HOST={}", env::var("HOST").unwrap()); } diff --git a/src/common.rs b/src/common.rs index b812886..4b944f5 100644 --- a/src/common.rs +++ b/src/common.rs @@ -14,10 +14,10 @@ use std::fmt; use std::fs::{read_dir, remove_file}; use std::str::FromStr; use std::path::PathBuf; -#[cfg(not(feature = "norustc"))] +#[cfg(feature = "unstable")] use rustc; -use test::ColorConfig; +use libtest::ColorChoice; use runtest::dylib_env_var; #[derive(Clone, Copy, PartialEq, Debug)] @@ -210,7 +210,7 @@ pub struct Config { pub quiet: bool, /// Whether to use colors in test. - pub color: ColorConfig, + pub color: ColorChoice, /// where to find the remote test client process, if we're using it pub remote_test_client: Option, @@ -327,8 +327,15 @@ pub use self::config_tempdir::ConfigWithTemp; impl Default for Config { fn default() -> Config { - #[cfg(not(feature = "norustc"))] - let platform = rustc::session::config::host_triple().to_string(); + #[cfg(feature = "unstable")] + let (target, host) = { + let platform = rustc::session::config::host_triple().to_string(); + (platform.clone(), platform.clone()) + }; + #[cfg(not(feature = "unstable"))] + let (target, host) = { + (env!("TARGET").to_string(), env!("HOST").to_string()) + }; Config { compile_lib_path: PathBuf::from(""), @@ -351,14 +358,8 @@ impl Default for Config { runtool: None, host_rustcflags: None, target_rustcflags: None, - #[cfg(not(feature = "norustc"))] - target: platform.clone(), - #[cfg(feature = "norustc")] - target: env!("TARGET").to_string(), - #[cfg(not(feature = "norustc"))] - host: platform.clone(), - #[cfg(feature = "norustc")] - host: env!("HOST").to_string(), + target, + host, gdb: None, gdb_version: None, gdb_native_rust: false, @@ -372,7 +373,7 @@ impl Default for Config { lldb_python_dir: None, verbose: false, quiet: false, - color: ColorConfig::AutoColor, + color: ColorChoice::Auto, remote_test_client: None, cc: "cc".to_string(), cxx: "cxx".to_string(), diff --git a/src/lib.rs b/src/lib.rs index 0124c73..3c9c560 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,18 +9,15 @@ // except according to those terms. #![crate_type = "lib"] - -#![cfg_attr(not(feature = "norustc"), feature(rustc_private))] -#![cfg_attr(not(feature = "stable"), feature(test))] - #![deny(unused_imports)] +#![cfg_attr(feature = "unstable", feature(rustc_private))] -#[cfg(not(feature = "norustc"))] +#[cfg(feature = "unstable")] extern crate rustc; #[cfg(unix)] extern crate libc; -extern crate libtest as test; +extern crate libtest; #[cfg(feature = "tmp")] extern crate tempfile; @@ -84,7 +81,7 @@ pub fn run_tests(config: &Config) { // Prevent issue #21352 UAC blocking .exe containing 'patch' etc. on Windows // If #11207 is resolved (adding manifest to .exe) this becomes unnecessary env::set_var("__COMPAT_LAYER", "RunAsInvoker"); - let res = test::run_tests_console(&opts, tests.into_iter().collect()); + let res = libtest::run_tests_console(&opts, tests.into_iter().collect()); match res { Ok(true) => {} Ok(false) => panic!("Some tests failed"), @@ -94,14 +91,14 @@ pub fn run_tests(config: &Config) { } } -pub fn test_opts(config: &Config) -> test::TestOpts { - test::TestOpts { +pub fn test_opts(config: &Config) -> libtest::TestOpts { + libtest::TestOpts { filter: config.filter.clone(), filter_exact: config.filter_exact, #[cfg(not(feature = "stable"))] exclude_should_panic: false, - run_ignored: if config.run_ignored { test::RunIgnored::Yes } else { test::RunIgnored::No }, - format: if config.quiet { test::OutputFormat::Terse } else { test::OutputFormat::Pretty }, + run_ignored: if config.run_ignored { libtest::RunIgnored::Yes } else { libtest::RunIgnored::No }, + format: if config.quiet { libtest::OutputFormat::Terse } else { libtest::OutputFormat::Pretty }, logfile: config.logfile.clone(), run_tests: true, bench_benchmarks: true, @@ -109,15 +106,15 @@ pub fn test_opts(config: &Config) -> test::TestOpts { Ok(val) => &val != "0", Err(_) => false }, - color: test::AutoColor, + color: libtest::ColorChoice::Auto, test_threads: None, skip: vec![], list: false, - options: test::Options::new(), + options: libtest::Options::new(), } } -pub fn make_tests(config: &Config) -> Vec { +pub fn make_tests(config: &Config) -> Vec { debug!("making tests from {:?}", config.src_base.display()); let mut tests = Vec::new(); @@ -134,7 +131,7 @@ fn collect_tests_from_dir(config: &Config, base: &Path, dir: &Path, relative_dir_path: &Path, - tests: &mut Vec) + tests: &mut Vec) -> io::Result<()> { // Ignore directories that contain a file // `compiletest-ignore-dir`. @@ -224,23 +221,23 @@ pub fn is_test(file_name: &OsString) -> bool { !invalid_prefixes.iter().any(|p| file_name.starts_with(p)) } -pub fn make_test(config: &Config, testpaths: &TestPaths) -> test::TestDescAndFn { +pub fn make_test(config: &Config, testpaths: &TestPaths) -> libtest::TestDescAndFn { let early_props = EarlyProps::from_file(config, &testpaths.file); // The `should-fail` annotation doesn't apply to pretty tests, // since we run the pretty printer across all tests by default. // If desired, we could add a `should-fail-pretty` annotation. let should_panic = match config.mode { - Pretty => test::ShouldPanic::No, + Pretty => libtest::ShouldPanic::No, _ => if early_props.should_fail { - test::ShouldPanic::Yes + libtest::ShouldPanic::Yes } else { - test::ShouldPanic::No + libtest::ShouldPanic::No } }; - test::TestDescAndFn { - desc: test::TestDesc { + libtest::TestDescAndFn { + desc: libtest::TestDesc { name: make_test_name(config, testpaths), ignore: early_props.ignore, should_panic: should_panic, @@ -260,7 +257,7 @@ fn stamp(config: &Config, testpaths: &TestPaths) -> PathBuf { .join(stamp_name) } -pub fn make_test_name(config: &Config, testpaths: &TestPaths) -> test::TestName { +pub fn make_test_name(config: &Config, testpaths: &TestPaths) -> libtest::TestName { // Convert a complete path to something like // // run-pass/foo/bar/baz.rs @@ -268,15 +265,14 @@ pub fn make_test_name(config: &Config, testpaths: &TestPaths) -> test::TestName PathBuf::from(config.src_base.file_name().unwrap()) .join(&testpaths.relative_dir) .join(&testpaths.file.file_name().unwrap()); - test::DynTestName(format!("[{}] {}", config.mode, path.display())) + libtest::TestName::DynTestName(format!("[{}] {}", config.mode, path.display())) } -pub fn make_test_closure(config: &Config, testpaths: &TestPaths) -> test::TestFn { +pub fn make_test_closure(config: &Config, testpaths: &TestPaths) -> libtest::TestFn { let config = config.clone(); let testpaths = testpaths.clone(); - test::DynTestFn(Box::new(move || { - #[cfg(feature = "stable")] - let config = config.clone(); // FIXME: why is this needed? + libtest::TestFn::DynTestFn(Box::new(move || { + let config = config.clone(); runtest::run(config, &testpaths) })) } diff --git a/test-project/Cargo.toml b/test-project/Cargo.toml index cb45865..b3ac2fb 100644 --- a/test-project/Cargo.toml +++ b/test-project/Cargo.toml @@ -10,4 +10,4 @@ path = ".." features = ["tmp"] [features] -stable = ["compiletest_rs/stable"] +unstable = ["compiletest_rs/unstable"] diff --git a/test-project/tests/tests.rs b/test-project/tests/tests.rs index 39bef89..9867e7e 100644 --- a/test-project/tests/tests.rs +++ b/test-project/tests/tests.rs @@ -21,6 +21,6 @@ fn compile_test() { run_mode("run-pass"); run_mode("ui"); - #[cfg(not(feature = "stable"))] + #[cfg(feature = "unstable")] run_mode("pretty"); }