From 3f874e349b9640ec7bd7aa961582fc2941fe04a0 Mon Sep 17 00:00:00 2001 From: messense Date: Tue, 13 Mar 2018 22:13:32 +0800 Subject: [PATCH 1/3] Support stable rustc --- Cargo.toml | 2 ++ src/lib.rs | 9 +++++++-- src/runtest.rs | 16 ++++++++++++++++ test-project/Cargo.toml | 2 +- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a784e1d..24ffab5 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" +rustc-test = { git = "https://github.com/messense/rustc-test.git", branch = "sync-rustc", 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", "rustc-test"] diff --git a/src/lib.rs b/src/lib.rs index 37172d3..2481a67 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)] @@ -21,7 +21,10 @@ extern crate rustc; #[cfg(unix)] extern crate libc; +#[cfg(not(feature = "stable"))] extern crate test; +#[cfg(feature = "stable")] +extern crate rustc_test as test; #[cfg(feature = "tmp")] extern crate tempfile; @@ -272,6 +275,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..a4bd061 100644 --- a/test-project/Cargo.toml +++ b/test-project/Cargo.toml @@ -7,4 +7,4 @@ authors = ["Thomas Jespersen "] [dev-dependencies.compiletest_rs] path = ".." -features = ["tmp"] +features = ["tmp", "norustc"] From cb391837b144980df330a4d780db52cd3568d5b9 Mon Sep 17 00:00:00 2001 From: messense Date: Mon, 26 Mar 2018 21:57:50 +0800 Subject: [PATCH 2/3] Enable build on stable --- appveyor.yml | 7 +++++-- test-project/Cargo.toml | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) 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/test-project/Cargo.toml b/test-project/Cargo.toml index a4bd061..cb45865 100644 --- a/test-project/Cargo.toml +++ b/test-project/Cargo.toml @@ -7,4 +7,7 @@ authors = ["Thomas Jespersen "] [dev-dependencies.compiletest_rs] path = ".." -features = ["tmp", "norustc"] +features = ["tmp"] + +[features] +stable = ["compiletest_rs/stable"] From ebc7ef84e96bd85245deabbaeb8ec6f95deb24a1 Mon Sep 17 00:00:00 2001 From: messense Date: Tue, 27 Mar 2018 14:04:28 +0800 Subject: [PATCH 3/3] Use my forked version of rustc-test from crates.io --- Cargo.toml | 4 ++-- src/lib.rs | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 24ffab5..2919ab7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ tempfile = { version = "3.0", optional = true } serde = "1.0" serde_json = "1.0" serde_derive = "1.0" -rustc-test = { git = "https://github.com/messense/rustc-test.git", branch = "sync-rustc", optional = true } +tester = { version = "0.4", optional = true } [target."cfg(unix)".dependencies] libc = "0.2" @@ -35,4 +35,4 @@ winapi = { version = "0.3", features = ["winerror"] } [features] tmp = ["tempfile"] norustc = [] -stable = ["norustc", "rustc-test"] +stable = ["norustc", "tester"] diff --git a/src/lib.rs b/src/lib.rs index 2481a67..f24e84e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,10 +21,7 @@ extern crate rustc; #[cfg(unix)] extern crate libc; -#[cfg(not(feature = "stable"))] extern crate test; -#[cfg(feature = "stable")] -extern crate rustc_test as test; #[cfg(feature = "tmp")] extern crate tempfile;