diff --git a/Cargo.toml b/Cargo.toml index a784e1d..2919ab7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,7 @@ tempfile = { version = "3.0", optional = true } serde = "1.0" serde_json = "1.0" serde_derive = "1.0" +tester = { version = "0.4", optional = true } [target."cfg(unix)".dependencies] libc = "0.2" @@ -34,3 +35,4 @@ winapi = { version = "0.3", features = ["winerror"] } [features] tmp = ["tempfile"] norustc = [] +stable = ["norustc", "tester"] diff --git a/appveyor.yml b/appveyor.yml index 871ea9e..2236633 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,6 +4,10 @@ environment: CHANNEL: nightly - TARGET: x86_64-pc-windows-msvc CHANNEL: nightly + - TARGET: x86_64-pc-windows-gnu + CHANNEL: stable + - TARGET: x86_64-pc-windows-msvc + CHANNEL: stable install: - curl -sSf -o rustup-init.exe https://win.rustup.rs @@ -15,8 +19,7 @@ install: build: false test_script: - - cargo build - - cargo build --features norustc + - if %CHANNEL%==stable (cargo build --features stable) else (cargo build) branches: only: diff --git a/src/lib.rs b/src/lib.rs index 37172d3..f24e84e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,8 +11,8 @@ #![crate_type = "lib"] #![cfg_attr(not(feature = "norustc"), feature(rustc_private))] -#![feature(test)] -#![feature(slice_rotate)] +#![cfg_attr(not(feature = "stable"), feature(test))] +#![cfg_attr(not(feature = "stable"), feature(slice_rotate))] #![deny(unused_imports)] @@ -272,6 +272,8 @@ pub fn make_test_closure(config: &Config, testpaths: &TestPaths) -> test::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? runtest::run(config, &testpaths) })) } diff --git a/src/runtest.rs b/src/runtest.rs index ba7ee83..d8f338a 100644 --- a/src/runtest.rs +++ b/src/runtest.rs @@ -2611,7 +2611,11 @@ fn read2_abbreviated(mut child: Child) -> io::Result { *skipped += data.len(); if data.len() <= TAIL_LEN { tail[..data.len()].copy_from_slice(data); + #[cfg(not(feature = "stable"))] tail.rotate_left(data.len()); + // FIXME: Remove this when rotate_left is stable in 1.26 + #[cfg(feature = "stable")] + rotate_left(tail, data.len()); } else { tail.copy_from_slice(&data[(data.len() - TAIL_LEN)..]); } @@ -2649,3 +2653,15 @@ fn read2_abbreviated(mut child: Child) -> io::Result { stderr: stderr.into_bytes(), }) } + +// FIXME: Remove this when rotate_left is stable in 1.26 +#[cfg(feature = "stable")] +fn rotate_left(slice: &mut [T], places: usize) { + // Rotation can be implemented by reversing the slice, + // splitting the slice in two, and then reversing the + // two sub-slices. + slice.reverse(); + let (a, b) = slice.split_at_mut(places); + a.reverse(); + b.reverse(); +} diff --git a/test-project/Cargo.toml b/test-project/Cargo.toml index 5431a9f..cb45865 100644 --- a/test-project/Cargo.toml +++ b/test-project/Cargo.toml @@ -8,3 +8,6 @@ authors = ["Thomas Jespersen "] [dev-dependencies.compiletest_rs] path = ".." features = ["tmp"] + +[features] +stable = ["compiletest_rs/stable"]