Skip to content

Commit

Permalink
Use libtest from crates.io for compiletest
Browse files Browse the repository at this point in the history
This fixes using latest nightly + local-rebuild=true for testing
  • Loading branch information
bjorn3 committed Apr 14, 2019
1 parent ee621f4 commit 8516a88
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 23 deletions.
17 changes: 17 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ dependencies = [
"getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
"libtest 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"miow 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
Expand Down Expand Up @@ -1307,6 +1308,15 @@ dependencies = [
"vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "libtest"
version = "0.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_term 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "libz-sys"
version = "1.0.25"
Expand Down Expand Up @@ -2942,6 +2952,11 @@ dependencies = [
"serialize 0.0.0",
]

[[package]]
name = "rustc_term"
version = "0.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "rustc_tools_util"
version = "0.1.1"
Expand Down Expand Up @@ -4103,6 +4118,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum libgit2-sys 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)" = "48441cb35dc255da8ae72825689a95368bf510659ae1ad55dc4aa88cb1789bf1"
"checksum libnghttp2-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d75d7966bda4730b722d1eab8e668df445368a24394bae9fc1e8dc0ab3dbe4f4"
"checksum libssh2-sys 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "126a1f4078368b163bfdee65fbab072af08a1b374a5551b21e87ade27b1fbf9d"
"checksum libtest 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1a51ac59582b915cdfc426dada72c6d9eba95818a6b481ca340f5c7152166837"
"checksum libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "2eb5e43362e38e2bca2fd5f5134c4d4564a23a5c28e9b95411652021a8675ebe"
"checksum lock_api 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "949826a5ccf18c1b3a7c3d57692778d21768b79e46eb9dd07bfc4c2160036c54"
"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6"
Expand Down Expand Up @@ -4212,6 +4228,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum rustc-rayon 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8d98c51d9cbbe810c8b6693236d3412d8cd60513ff27a3e1b6af483dca0af544"
"checksum rustc-rayon-core 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "526e7b6d2707a5b9bec3927d424ad70fa3cfc68e0ac1b75e46cdbbc95adc5108"
"checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda"
"checksum rustc_term 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9c69abe7f181d2ea8d2f7b44a4aa86f4b4a567444bcfcf51ed45ede957fbf064"
"checksum rustc_tools_util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b3c5a95edfa0c893236ae4778bb7c4752760e4c0d245e19b5eff33c5aa5eb9dc"
"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
"checksum rustfix 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "af7c21531a91512a4a51b490be6ba1c8eff34fdda0dc5bf87dc28d86748aac56"
Expand Down
1 change: 1 addition & 0 deletions src/tools/compiletest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ diff = "0.1.10"
env_logger = { version = "0.5", default-features = false }
filetime = "0.2"
getopts = "0.2"
libtest = "0.0.1"
log = "0.4"
regex = "1.0"
serde = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion src/tools/compiletest/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::fmt;
use std::path::{Path, PathBuf};
use std::str::FromStr;

use test::ColorConfig;
use libtest::ColorConfig;
use crate::util::PathBufExt;

#[derive(Clone, Copy, PartialEq, Debug)]
Expand Down
44 changes: 22 additions & 22 deletions src/tools/compiletest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ extern crate log;
extern crate lazy_static;
#[macro_use]
extern crate serde_derive;
extern crate test;

use crate::common::CompareMode;
use crate::common::{expected_output_path, output_base_dir, output_relative_path, UI_EXTENSIONS};
Expand All @@ -24,7 +23,7 @@ use std::fs;
use std::io::{self, ErrorKind};
use std::path::{Path, PathBuf};
use std::process::Command;
use test::ColorConfig;
use libtest::ColorConfig;
use crate::util::logv;
use walkdir::WalkDir;
use env_logger;
Expand Down Expand Up @@ -510,7 +509,7 @@ pub fn run_tests(config: &Config) {
// Let tests know which target they're running as
env::set_var("TARGET", &config.target);

let res = test::run_tests_console(&opts, tests);
let res = libtest::run_tests_console(&opts, tests);
match res {
Ok(true) => {}
Ok(false) => panic!("Some tests failed"),
Expand All @@ -520,19 +519,20 @@ 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 {
exclude_should_panic: false,
filter: config.filter.clone(),
filter_exact: config.filter_exact,
run_ignored: if config.run_ignored {
test::RunIgnored::Yes
libtest::RunIgnored::Yes
} else {
test::RunIgnored::No
libtest::RunIgnored::No
},
format: if config.quiet {
test::OutputFormat::Terse
libtest::OutputFormat::Terse
} else {
test::OutputFormat::Pretty
libtest::OutputFormat::Pretty
},
logfile: config.logfile.clone(),
run_tests: true,
Expand All @@ -545,11 +545,11 @@ pub fn test_opts(config: &Config) -> test::TestOpts {
test_threads: None,
skip: vec![],
list: false,
options: test::Options::new(),
options: libtest::Options::new(),
}
}

pub fn make_tests(config: &Config) -> Vec<test::TestDescAndFn> {
pub fn make_tests(config: &Config) -> Vec<libtest::TestDescAndFn> {
debug!("making tests from {:?}", config.src_base.display());
let mut tests = Vec::new();
collect_tests_from_dir(
Expand All @@ -567,7 +567,7 @@ fn collect_tests_from_dir(
base: &Path,
dir: &Path,
relative_dir_path: &Path,
tests: &mut Vec<test::TestDescAndFn>,
tests: &mut Vec<libtest::TestDescAndFn>,
) -> io::Result<()> {
// Ignore directories that contain a file named `compiletest-ignore-dir`.
if dir.join("compiletest-ignore-dir").exists() {
Expand Down Expand Up @@ -632,7 +632,7 @@ 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) -> Vec<test::TestDescAndFn> {
pub fn make_test(config: &Config, testpaths: &TestPaths) -> Vec<libtest::TestDescAndFn> {
let early_props = if config.mode == Mode::RunMake {
// Allow `ignore` directives to be in the Makefile.
EarlyProps::from_file(config, &testpaths.file.join("Makefile"))
Expand All @@ -644,11 +644,11 @@ pub fn make_test(config: &Config, testpaths: &TestPaths) -> Vec<test::TestDescAn
// 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
},
};

Expand All @@ -675,8 +675,8 @@ pub fn make_test(config: &Config, testpaths: &TestPaths) -> Vec<test::TestDescAn
&& config.target.contains("emscripten"))
|| (config.mode == DebugInfoGdb && !early_props.ignore.can_run_gdb())
|| (config.mode == DebugInfoLldb && !early_props.ignore.can_run_lldb());
test::TestDescAndFn {
desc: test::TestDesc {
libtest::TestDescAndFn {
desc: libtest::TestDesc {
name: make_test_name(config, testpaths, revision),
ignore,
should_panic,
Expand Down Expand Up @@ -786,7 +786,7 @@ fn make_test_name(
config: &Config,
testpaths: &TestPaths,
revision: Option<&String>,
) -> test::TestName {
) -> libtest::TestName {
// Convert a complete path to something like
//
// run-pass/foo/bar/baz.rs
Expand All @@ -797,7 +797,7 @@ fn make_test_name(
Some(ref mode) => format!(" ({})", mode.to_str()),
None => String::new(),
};
test::DynTestName(format!(
libtest::DynTestName(format!(
"[{}{}] {}{}",
config.mode,
mode_suffix,
Expand All @@ -811,7 +811,7 @@ fn make_test_closure(
ignore: Ignore,
testpaths: &TestPaths,
revision: Option<&String>,
) -> test::TestFn {
) -> libtest::TestFn {
let mut config = config.clone();
if config.mode == DebugInfoBoth {
// If both gdb and lldb were ignored, then the test as a whole
Expand All @@ -825,7 +825,7 @@ fn make_test_closure(

let testpaths = testpaths.clone();
let revision = revision.cloned();
test::DynTestFn(Box::new(move || {
libtest::DynTestFn(Box::new(move || {
runtest::run(config, &testpaths, revision.as_ref().map(|s| s.as_str()))
}))
}
Expand Down

0 comments on commit 8516a88

Please sign in to comment.