Skip to content

Commit 6e2ba65

Browse files
committed
Rip out rustc-test
Fixes #251
1 parent 33ab3b8 commit 6e2ba65

9 files changed

+35
-87
lines changed

Cargo.toml

-6
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ categories = ["parser-implementations", "web-programming"]
1010
keywords = ["html", "css-selectors", "parser", "rewriter", "streaming"]
1111
readme = "README.md"
1212
include = ["/Cargo.toml", "/LICENSE", "/README.md", "/media", "/src"]
13-
autotests = false
1413
edition = "2021"
1514

1615
[lib]
@@ -23,10 +22,6 @@ debug_trace = []
2322
# Unstable: for internal use only
2423
integration_test = []
2524

26-
[[test]]
27-
harness = false
28-
name = "integration_tests"
29-
3025
[[bench]]
3126
harness = false
3227
name = "bench"
@@ -55,7 +50,6 @@ serde_derive = "1.0.19"
5550
serde_json = "1.0.65"
5651
static_assertions = "1.1.0"
5752
rand = "0.8.5"
58-
rustc-test = "0.3.1"
5953
itertools = "0.13"
6054

6155
[lints.rust]

tests/fixtures/element_content_replacement.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,7 @@ impl TestFixture<TestCase> for ElementContentReplacementTests {
4949
}
5050
}
5151

52-
test_fixture!(ElementContentReplacementTests);
52+
#[test]
53+
fn test_element_content_replacement() {
54+
ElementContentReplacementTests::run_tests();
55+
}

tests/fixtures/mod.rs

-5
This file was deleted.

tests/fixtures/selector_matching.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,7 @@ impl TestFixture<TestCase> for SelectorMatchingTests {
8686
}
8787
}
8888

89-
test_fixture!(SelectorMatchingTests);
89+
#[test]
90+
fn test_selector_matching() {
91+
SelectorMatchingTests::run_tests();
92+
}

tests/fixtures/token_capturing.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -258,4 +258,7 @@ impl TestFixture<TestCase> for TokenCapturingTests {
258258
}
259259
}
260260

261-
test_fixture!(TokenCapturingTests);
261+
#[test]
262+
fn test_token_capturing() {
263+
TokenCapturingTests::run_tests();
264+
}

tests/harness/mod.rs

+12-46
Original file line numberDiff line numberDiff line change
@@ -17,56 +17,22 @@ pub mod suites;
1717

1818
pub use self::input::Input;
1919

20-
pub trait TestFixture<T> {
20+
pub trait TestFixture<T: std::fmt::Debug> {
2121
fn test_cases() -> Vec<T>;
2222
fn run(test: &T);
23-
}
24-
25-
macro_rules! create_test {
26-
($name:expr, $should_panic:expr, $body:tt) => {{
27-
use rustc_test::{TestDesc, TestDescAndFn, TestFn, TestName};
28-
29-
TestDescAndFn {
30-
desc: TestDesc {
31-
name: TestName::DynTestName($name),
32-
ignore: false,
33-
should_panic: $should_panic,
34-
allow_fail: false,
35-
},
36-
testfn: TestFn::DynTestFn(Box::new(move || $body)),
23+
fn run_tests() {
24+
for test in Self::test_cases() {
25+
let d = DumpOnPanic(&test);
26+
Self::run(&test);
27+
std::mem::forget(d);
3728
}
38-
}};
29+
}
3930
}
4031

41-
macro_rules! test_fixture {
42-
($fixture:ident) => {
43-
use rustc_test::{ShouldPanic, TestDescAndFn};
44-
45-
pub fn get_tests() -> Vec<TestDescAndFn> {
46-
$fixture::test_cases()
47-
.into_iter()
48-
.map(|t| {
49-
create_test!(t.description.to_owned(), ShouldPanic::No, {
50-
$fixture::run(&t);
51-
})
52-
})
53-
.collect()
54-
}
55-
};
32+
struct DumpOnPanic<'a, T: std::fmt::Debug>(&'a T);
33+
impl<T: std::fmt::Debug> Drop for DumpOnPanic<'_, T> {
34+
fn drop(&mut self) {
35+
eprintln!("test case failed: {:?}", self.0);
36+
}
5637
}
5738

58-
macro_rules! test_modules {
59-
($($m:ident),+) => {
60-
$(mod $m;)+
61-
62-
use rustc_test::TestDescAndFn;
63-
64-
pub fn get_tests() -> Vec<TestDescAndFn> {
65-
let mut tests = Vec::default();
66-
67-
$(tests.extend($m::get_tests());)+
68-
69-
tests
70-
}
71-
};
72-
}

tests/harness/suites/html5lib_tests/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub struct Bailout {
2424
pub parsed_chunk: String,
2525
}
2626

27-
#[derive(Deserialize, Clone)]
27+
#[derive(Deserialize, Clone, Debug)]
2828
#[serde(rename_all = "camelCase")]
2929
pub struct TestCase {
3030
pub description: String,

tests/harness/suites/selectors_tests.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ struct TestData {
2424
pub src: String,
2525
}
2626

27+
#[derive(Debug)]
2728
pub struct TestCase {
28-
pub description: String,
29+
pub _description: String,
2930
pub selector: String,
3031
pub input: Input,
3132
pub expected: String,
@@ -65,7 +66,7 @@ pub fn get_test_cases(suite: &'static str) -> Vec<TestCase> {
6566
}
6667

6768
test_cases.push(TestCase {
68-
description,
69+
_description: description,
6970
selector: selector.clone(),
7071
input,
7172
expected: read_test_file(suite, &expected_file),

tests/integration_tests.rs

+7-24
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,10 @@
1-
use cfg_if::cfg_if;
1+
#![cfg(feature = "integration_test")]
22

3-
cfg_if! {
4-
if #[cfg(feature="integration_test")] {
5-
#[macro_use]
6-
mod harness;
3+
#[macro_use]
4+
mod harness;
75

8-
mod fixtures;
9-
10-
use self::fixtures::get_tests;
11-
use rustc_test::test_main;
12-
13-
fn main() {
14-
let args: Vec<_> = ::std::env::args().collect();
15-
16-
test_main(&args, get_tests());
17-
}
18-
} else {
19-
fn main() {
20-
println!(concat![
21-
"Integration tests will not run. ",
22-
"To run integration tests either run `./scripts/test.sh` ",
23-
"or pass `--features=integration_test` flag to `cargo test`."
24-
]);
25-
}
26-
}
6+
mod fixtures {
7+
mod token_capturing;
8+
mod selector_matching;
9+
mod element_content_replacement;
2710
}

0 commit comments

Comments
 (0)