Skip to content

Commit

Permalink
Merge pull request #748 from lucacasonato/use_tester_not_rustc_test
Browse files Browse the repository at this point in the history
Use `tester` instead of `rustc-test`
  • Loading branch information
valenting authored Jan 31, 2022
2 parents 474560d + 26f5371 commit c34de27
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 27 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Coverage

on:
push:
branches: ['master']
branches: ["master"]
pull_request:

jobs:
Expand All @@ -16,9 +16,9 @@ jobs:
toolchain: stable
override: true
- uses: actions-rs/[email protected]
- uses: codecov/codecov-action@v1.0.2
with:
token: ${{secrets.CODECOV_TOKEN}}
- uses: codecov/codecov-action@v2.1.0
# A codecov token is not needed for public repos if the repo is linked
# on codecov.io. See https://docs.codecov.com/docs/frequently-asked-questions#where-is-the-repository-upload-token-found
- uses: actions/upload-artifact@v1
with:
name: code-coverage-report
Expand Down
2 changes: 1 addition & 1 deletion data-url/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ rust-version = "1.45"
matches = "0.1"

[dev-dependencies]
rustc-test = "0.3"
tester = "0.9"
serde = {version = "1.0", features = ["derive"]}
serde_json = "1.0"

Expand Down
36 changes: 22 additions & 14 deletions data-url/tests/wpt.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use tester as test;

#[macro_use]
extern crate serde;

Expand Down Expand Up @@ -32,7 +34,7 @@ fn run_data_url(

fn collect_data_url<F>(add_test: &mut F)
where
F: FnMut(String, bool, rustc_test::TestFn),
F: FnMut(String, bool, test::TestFn),
{
let known_failures = ["data://test:test/,X"];

Expand All @@ -53,9 +55,9 @@ where
add_test(
format!("data: URL {:?}", input),
should_panic,
rustc_test::TestFn::dyn_test_fn(move || {
test::TestFn::DynTestFn(Box::new(move || {
run_data_url(input, expected_mime, expected_body, should_panic)
}),
})),
);
}
}
Expand All @@ -72,7 +74,7 @@ fn run_base64(input: String, expected: Option<Vec<u8>>) {

fn collect_base64<F>(add_test: &mut F)
where
F: FnMut(String, bool, rustc_test::TestFn),
F: FnMut(String, bool, test::TestFn),
{
let known_failures = [];

Expand All @@ -83,7 +85,7 @@ where
add_test(
format!("base64 {:?}", input),
should_panic,
rustc_test::TestFn::dyn_test_fn(move || run_base64(input, expected)),
test::TestFn::DynTestFn(Box::new(move || run_base64(input, expected))),
);
}
}
Expand All @@ -100,7 +102,7 @@ fn run_mime(input: String, expected: Option<String>) {

fn collect_mime<F>(add_test: &mut F)
where
F: FnMut(String, bool, rustc_test::TestFn),
F: FnMut(String, bool, test::TestFn),
{
let known_failures = [];

Expand Down Expand Up @@ -136,24 +138,30 @@ where
format!("MIME type {:?}", input)
},
should_panic,
rustc_test::TestFn::dyn_test_fn(move || run_mime(input, expected)),
test::TestFn::DynTestFn(Box::new(move || run_mime(input, expected))),
);
}
}

fn main() {
let mut tests = Vec::new();
{
let mut add_one = |name: String, should_panic: bool, run: rustc_test::TestFn| {
let mut desc = rustc_test::TestDesc::new(rustc_test::DynTestName(name));
if should_panic {
desc.should_panic = rustc_test::ShouldPanic::Yes
}
tests.push(rustc_test::TestDescAndFn { desc, testfn: run })
let mut add_one = |name: String, should_panic: bool, run: test::TestFn| {
let desc = test::TestDesc {
name: test::DynTestName(name),
ignore: false,
should_panic: match should_panic {
true => test::ShouldPanic::Yes,
false => test::ShouldPanic::No,
},
allow_fail: false,
test_type: test::TestType::Unknown,
};
tests.push(test::TestDescAndFn { desc, testfn: run })
};
collect_data_url(&mut add_one);
collect_base64(&mut add_one);
collect_mime(&mut add_one);
}
rustc_test::test_main(&std::env::args().collect::<Vec<_>>(), tests)
test::test_main(&std::env::args().collect::<Vec<_>>(), tests, None)
}
2 changes: 1 addition & 1 deletion idna/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ name = "unit"
[dev-dependencies]
assert_matches = "1.3"
bencher = "0.1"
rustc-test = "0.3"
tester = "0.9"
serde_json = "1.0"

[dependencies]
Expand Down
4 changes: 2 additions & 2 deletions idna/tests/punycode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ pub fn collect_tests<F: FnMut(String, TestFn)>(add_test: &mut F) {
};
add_test(
test_name,
TestFn::dyn_test_fn(move || {
TestFn::DynTestFn(Box::new(move || {
one_test(get_string(&o, "decoded"), get_string(&o, "encoded"))
}),
})),
)
}
_ => panic!(),
Expand Down
12 changes: 9 additions & 3 deletions idna/tests/tests.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use rustc_test as test;
use tester as test;

mod punycode;
mod uts46;
Expand All @@ -8,12 +8,18 @@ fn main() {
{
let mut add_test = |name, run| {
tests.push(test::TestDescAndFn {
desc: test::TestDesc::new(test::DynTestName(name)),
desc: test::TestDesc {
name: test::DynTestName(name),
ignore: false,
should_panic: test::ShouldPanic::No,
allow_fail: false,
test_type: test::TestType::Unknown,
},
testfn: run,
})
};
punycode::collect_tests(&mut add_test);
uts46::collect_tests(&mut add_test);
}
test::test_main(&std::env::args().collect::<Vec<_>>(), tests)
test::test_main(&std::env::args().collect::<Vec<_>>(), tests, None)
}
4 changes: 2 additions & 2 deletions idna/tests/uts46.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub fn collect_tests<F: FnMut(String, TestFn)>(add_test: &mut F) {
let test_name = format!("UTS #46 line {}", i + 1);
add_test(
test_name,
TestFn::dyn_test_fn(move || {
TestFn::DynTestFn(Box::new(move || {
let config = idna::Config::default()
.use_std3_ascii_rules(true)
.verify_dns_length(true)
Expand Down Expand Up @@ -109,7 +109,7 @@ pub fn collect_tests<F: FnMut(String, TestFn)>(add_test: &mut F) {
to_ascii_t_result,
|e| e.starts_with('C') || e == "V2",
);
}),
})),
)
}
}
Expand Down

0 comments on commit c34de27

Please sign in to comment.