Repository: servo/rust-url (rust)

Issue:
Remove `rustc-test` dev dependency
This dependency is causing some trouble:

a) it has not been updated in a long time
b) it depends on old versions of `term` (which depends on an old version of `winapi`)
c) it depends on `term`: `term` is unmaintained
d) it depends on a very old version of `time`
e) id depends on `rustc-serialize` which is deprecated. `serde` should be used instead.


Discussion:
This involves rewriting the testing frameworks used in the `idna` and `data-url`. I'll give this a shot today.

Patch:
diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml
--- a/.github/workflows/codecov.yml
+++ b/.github/workflows/codecov.yml
@@ -2,7 +2,7 @@ name: Coverage
 
 on:
   push:
-    branches: ['master']
+    branches: ["master"]
   pull_request:
 
 jobs:
@@ -16,9 +16,9 @@ jobs:
           toolchain: stable
           override: true
       - uses: actions-rs/tarpaulin@v0.1
-      - 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
diff --git a/data-url/Cargo.toml b/data-url/Cargo.toml
--- a/data-url/Cargo.toml
+++ b/data-url/Cargo.toml
@@ -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"
 
diff --git a/idna/Cargo.toml b/idna/Cargo.toml
--- a/idna/Cargo.toml
+++ b/idna/Cargo.toml
@@ -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]


Test patch:
diff --git a/data-url/tests/wpt.rs b/data-url/tests/wpt.rs
--- a/data-url/tests/wpt.rs
+++ b/data-url/tests/wpt.rs
@@ -1,3 +1,5 @@
+use tester as test;
+
 #[macro_use]
 extern crate serde;
 
@@ -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"];
 
@@ -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)
-            }),
+            })),
         );
     }
 }
@@ -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 = [];
 
@@ -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))),
         );
     }
 }
@@ -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 = [];
 
@@ -136,7 +138,7 @@ 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))),
         );
     }
 }
@@ -144,16 +146,22 @@ where
 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)
 }
diff --git a/idna/tests/punycode.rs b/idna/tests/punycode.rs
--- a/idna/tests/punycode.rs
+++ b/idna/tests/punycode.rs
@@ -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!(),
diff --git a/idna/tests/tests.rs b/idna/tests/tests.rs
--- a/idna/tests/tests.rs
+++ b/idna/tests/tests.rs
@@ -1,4 +1,4 @@
-use rustc_test as test;
+use tester as test;
 
 mod punycode;
 mod uts46;
@@ -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)
 }
diff --git a/idna/tests/uts46.rs b/idna/tests/uts46.rs
--- a/idna/tests/uts46.rs
+++ b/idna/tests/uts46.rs
@@ -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)
@@ -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",
                 );
-            }),
+            })),
         )
     }
 }