Skip to content

Commit 8516a88

Browse files
committed
Use libtest from crates.io for compiletest
This fixes using latest nightly + local-rebuild=true for testing
1 parent ee621f4 commit 8516a88

File tree

4 files changed

+41
-23
lines changed

4 files changed

+41
-23
lines changed

Cargo.lock

+17
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ dependencies = [
470470
"getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)",
471471
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
472472
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
473+
"libtest 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
473474
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
474475
"miow 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
475476
"regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1307,6 +1308,15 @@ dependencies = [
13071308
"vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
13081309
]
13091310

1311+
[[package]]
1312+
name = "libtest"
1313+
version = "0.0.1"
1314+
source = "registry+https://github.com/rust-lang/crates.io-index"
1315+
dependencies = [
1316+
"getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)",
1317+
"rustc_term 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
1318+
]
1319+
13101320
[[package]]
13111321
name = "libz-sys"
13121322
version = "1.0.25"
@@ -2942,6 +2952,11 @@ dependencies = [
29422952
"serialize 0.0.0",
29432953
]
29442954

2955+
[[package]]
2956+
name = "rustc_term"
2957+
version = "0.0.1"
2958+
source = "registry+https://github.com/rust-lang/crates.io-index"
2959+
29452960
[[package]]
29462961
name = "rustc_tools_util"
29472962
version = "0.1.1"
@@ -4103,6 +4118,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
41034118
"checksum libgit2-sys 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)" = "48441cb35dc255da8ae72825689a95368bf510659ae1ad55dc4aa88cb1789bf1"
41044119
"checksum libnghttp2-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d75d7966bda4730b722d1eab8e668df445368a24394bae9fc1e8dc0ab3dbe4f4"
41054120
"checksum libssh2-sys 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "126a1f4078368b163bfdee65fbab072af08a1b374a5551b21e87ade27b1fbf9d"
4121+
"checksum libtest 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1a51ac59582b915cdfc426dada72c6d9eba95818a6b481ca340f5c7152166837"
41064122
"checksum libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "2eb5e43362e38e2bca2fd5f5134c4d4564a23a5c28e9b95411652021a8675ebe"
41074123
"checksum lock_api 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "949826a5ccf18c1b3a7c3d57692778d21768b79e46eb9dd07bfc4c2160036c54"
41084124
"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6"
@@ -4212,6 +4228,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
42124228
"checksum rustc-rayon 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8d98c51d9cbbe810c8b6693236d3412d8cd60513ff27a3e1b6af483dca0af544"
42134229
"checksum rustc-rayon-core 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "526e7b6d2707a5b9bec3927d424ad70fa3cfc68e0ac1b75e46cdbbc95adc5108"
42144230
"checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda"
4231+
"checksum rustc_term 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9c69abe7f181d2ea8d2f7b44a4aa86f4b4a567444bcfcf51ed45ede957fbf064"
42154232
"checksum rustc_tools_util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b3c5a95edfa0c893236ae4778bb7c4752760e4c0d245e19b5eff33c5aa5eb9dc"
42164233
"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
42174234
"checksum rustfix 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "af7c21531a91512a4a51b490be6ba1c8eff34fdda0dc5bf87dc28d86748aac56"

src/tools/compiletest/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ diff = "0.1.10"
99
env_logger = { version = "0.5", default-features = false }
1010
filetime = "0.2"
1111
getopts = "0.2"
12+
libtest = "0.0.1"
1213
log = "0.4"
1314
regex = "1.0"
1415
serde = "1.0"

src/tools/compiletest/src/common.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::fmt;
44
use std::path::{Path, PathBuf};
55
use std::str::FromStr;
66

7-
use test::ColorConfig;
7+
use libtest::ColorConfig;
88
use crate::util::PathBufExt;
99

1010
#[derive(Clone, Copy, PartialEq, Debug)]

src/tools/compiletest/src/main.rs

+22-22
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ extern crate log;
1010
extern crate lazy_static;
1111
#[macro_use]
1212
extern crate serde_derive;
13-
extern crate test;
1413

1514
use crate::common::CompareMode;
1615
use crate::common::{expected_output_path, output_base_dir, output_relative_path, UI_EXTENSIONS};
@@ -24,7 +23,7 @@ use std::fs;
2423
use std::io::{self, ErrorKind};
2524
use std::path::{Path, PathBuf};
2625
use std::process::Command;
27-
use test::ColorConfig;
26+
use libtest::ColorConfig;
2827
use crate::util::logv;
2928
use walkdir::WalkDir;
3029
use env_logger;
@@ -510,7 +509,7 @@ pub fn run_tests(config: &Config) {
510509
// Let tests know which target they're running as
511510
env::set_var("TARGET", &config.target);
512511

513-
let res = test::run_tests_console(&opts, tests);
512+
let res = libtest::run_tests_console(&opts, tests);
514513
match res {
515514
Ok(true) => {}
516515
Ok(false) => panic!("Some tests failed"),
@@ -520,19 +519,20 @@ pub fn run_tests(config: &Config) {
520519
}
521520
}
522521

523-
pub fn test_opts(config: &Config) -> test::TestOpts {
524-
test::TestOpts {
522+
pub fn test_opts(config: &Config) -> libtest::TestOpts {
523+
libtest::TestOpts {
524+
exclude_should_panic: false,
525525
filter: config.filter.clone(),
526526
filter_exact: config.filter_exact,
527527
run_ignored: if config.run_ignored {
528-
test::RunIgnored::Yes
528+
libtest::RunIgnored::Yes
529529
} else {
530-
test::RunIgnored::No
530+
libtest::RunIgnored::No
531531
},
532532
format: if config.quiet {
533-
test::OutputFormat::Terse
533+
libtest::OutputFormat::Terse
534534
} else {
535-
test::OutputFormat::Pretty
535+
libtest::OutputFormat::Pretty
536536
},
537537
logfile: config.logfile.clone(),
538538
run_tests: true,
@@ -545,11 +545,11 @@ pub fn test_opts(config: &Config) -> test::TestOpts {
545545
test_threads: None,
546546
skip: vec![],
547547
list: false,
548-
options: test::Options::new(),
548+
options: libtest::Options::new(),
549549
}
550550
}
551551

552-
pub fn make_tests(config: &Config) -> Vec<test::TestDescAndFn> {
552+
pub fn make_tests(config: &Config) -> Vec<libtest::TestDescAndFn> {
553553
debug!("making tests from {:?}", config.src_base.display());
554554
let mut tests = Vec::new();
555555
collect_tests_from_dir(
@@ -567,7 +567,7 @@ fn collect_tests_from_dir(
567567
base: &Path,
568568
dir: &Path,
569569
relative_dir_path: &Path,
570-
tests: &mut Vec<test::TestDescAndFn>,
570+
tests: &mut Vec<libtest::TestDescAndFn>,
571571
) -> io::Result<()> {
572572
// Ignore directories that contain a file named `compiletest-ignore-dir`.
573573
if dir.join("compiletest-ignore-dir").exists() {
@@ -632,7 +632,7 @@ pub fn is_test(file_name: &OsString) -> bool {
632632
!invalid_prefixes.iter().any(|p| file_name.starts_with(p))
633633
}
634634

635-
pub fn make_test(config: &Config, testpaths: &TestPaths) -> Vec<test::TestDescAndFn> {
635+
pub fn make_test(config: &Config, testpaths: &TestPaths) -> Vec<libtest::TestDescAndFn> {
636636
let early_props = if config.mode == Mode::RunMake {
637637
// Allow `ignore` directives to be in the Makefile.
638638
EarlyProps::from_file(config, &testpaths.file.join("Makefile"))
@@ -644,11 +644,11 @@ pub fn make_test(config: &Config, testpaths: &TestPaths) -> Vec<test::TestDescAn
644644
// since we run the pretty printer across all tests by default.
645645
// If desired, we could add a `should-fail-pretty` annotation.
646646
let should_panic = match config.mode {
647-
Pretty => test::ShouldPanic::No,
647+
Pretty => libtest::ShouldPanic::No,
648648
_ => if early_props.should_fail {
649-
test::ShouldPanic::Yes
649+
libtest::ShouldPanic::Yes
650650
} else {
651-
test::ShouldPanic::No
651+
libtest::ShouldPanic::No
652652
},
653653
};
654654

@@ -675,8 +675,8 @@ pub fn make_test(config: &Config, testpaths: &TestPaths) -> Vec<test::TestDescAn
675675
&& config.target.contains("emscripten"))
676676
|| (config.mode == DebugInfoGdb && !early_props.ignore.can_run_gdb())
677677
|| (config.mode == DebugInfoLldb && !early_props.ignore.can_run_lldb());
678-
test::TestDescAndFn {
679-
desc: test::TestDesc {
678+
libtest::TestDescAndFn {
679+
desc: libtest::TestDesc {
680680
name: make_test_name(config, testpaths, revision),
681681
ignore,
682682
should_panic,
@@ -786,7 +786,7 @@ fn make_test_name(
786786
config: &Config,
787787
testpaths: &TestPaths,
788788
revision: Option<&String>,
789-
) -> test::TestName {
789+
) -> libtest::TestName {
790790
// Convert a complete path to something like
791791
//
792792
// run-pass/foo/bar/baz.rs
@@ -797,7 +797,7 @@ fn make_test_name(
797797
Some(ref mode) => format!(" ({})", mode.to_str()),
798798
None => String::new(),
799799
};
800-
test::DynTestName(format!(
800+
libtest::DynTestName(format!(
801801
"[{}{}] {}{}",
802802
config.mode,
803803
mode_suffix,
@@ -811,7 +811,7 @@ fn make_test_closure(
811811
ignore: Ignore,
812812
testpaths: &TestPaths,
813813
revision: Option<&String>,
814-
) -> test::TestFn {
814+
) -> libtest::TestFn {
815815
let mut config = config.clone();
816816
if config.mode == DebugInfoBoth {
817817
// If both gdb and lldb were ignored, then the test as a whole
@@ -825,7 +825,7 @@ fn make_test_closure(
825825

826826
let testpaths = testpaths.clone();
827827
let revision = revision.cloned();
828-
test::DynTestFn(Box::new(move || {
828+
libtest::DynTestFn(Box::new(move || {
829829
runtest::run(config, &testpaths, revision.as_ref().map(|s| s.as_str()))
830830
}))
831831
}

0 commit comments

Comments
 (0)