about summary refs log tree commit diff
path: root/src/test/ui/custom_test_frameworks
diff options
context:
space:
mode:
authorAlbert Larsan <74931857+albertlarsan68@users.noreply.github.com>2023-01-05 09:13:28 +0100
committerAlbert Larsan <74931857+albertlarsan68@users.noreply.github.com>2023-01-11 09:32:08 +0000
commitcf2dff2b1e3fa55fa5415d524200070d0d7aacfe (patch)
tree40a88d9a46aaf3e8870676eb2538378b75a263eb /src/test/ui/custom_test_frameworks
parentca855e6e42787ecd062d81d53336fe6788ef51a9 (diff)
downloadrust-cf2dff2b1e3fa55fa5415d524200070d0d7aacfe.tar.gz
rust-cf2dff2b1e3fa55fa5415d524200070d0d7aacfe.zip
Move /src/test to /tests
Diffstat (limited to 'src/test/ui/custom_test_frameworks')
-rw-r--r--src/test/ui/custom_test_frameworks/auxiliary/dynamic_runner.rs35
-rw-r--r--src/test/ui/custom_test_frameworks/auxiliary/example_runner.rs10
-rw-r--r--src/test/ui/custom_test_frameworks/dynamic.rs35
-rw-r--r--src/test/ui/custom_test_frameworks/full.rs28
-rw-r--r--src/test/ui/custom_test_frameworks/mismatch.rs10
-rw-r--r--src/test/ui/custom_test_frameworks/mismatch.stderr14
6 files changed, 0 insertions, 132 deletions
diff --git a/src/test/ui/custom_test_frameworks/auxiliary/dynamic_runner.rs b/src/test/ui/custom_test_frameworks/auxiliary/dynamic_runner.rs
deleted file mode 100644
index a56e0b1f5f0..00000000000
--- a/src/test/ui/custom_test_frameworks/auxiliary/dynamic_runner.rs
+++ /dev/null
@@ -1,35 +0,0 @@
-use std::process::exit;
-
-pub trait Testable {
-    // Name of the test
-    fn name(&self) -> String;
-
-    // Tests pass by default
-    fn run(&self) -> bool {
-        true
-    }
-
-    // A test can generate subtests
-    fn subtests(&self) -> Vec<Box<dyn Testable>> {
-        vec![]
-    }
-}
-
-fn run_test(t: &dyn Testable) -> bool {
-    let success = t.subtests().into_iter().all(|sub_t| run_test(&*sub_t)) && t.run();
-    println!("{}...{}", t.name(), if success { "SUCCESS" } else { "FAIL" });
-    success
-}
-
-pub fn runner(tests: &[&dyn Testable]) {
-    let mut failed = false;
-    for t in tests {
-        if !run_test(*t) {
-            failed = true;
-        }
-    }
-
-    if failed {
-        exit(1);
-    }
-}
diff --git a/src/test/ui/custom_test_frameworks/auxiliary/example_runner.rs b/src/test/ui/custom_test_frameworks/auxiliary/example_runner.rs
deleted file mode 100644
index dd68c0685ac..00000000000
--- a/src/test/ui/custom_test_frameworks/auxiliary/example_runner.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-pub trait Testable {
-    fn name(&self) -> String;
-    fn run(&self) -> Option<String>; // None will be success, Some is the error message
-}
-
-pub fn runner(tests: &[&dyn Testable]) {
-    for t in tests {
-        print!("{}........{}", t.name(), t.run().unwrap_or_else(|| "SUCCESS".to_string()));
-    }
-}
diff --git a/src/test/ui/custom_test_frameworks/dynamic.rs b/src/test/ui/custom_test_frameworks/dynamic.rs
deleted file mode 100644
index 6766ec542b1..00000000000
--- a/src/test/ui/custom_test_frameworks/dynamic.rs
+++ /dev/null
@@ -1,35 +0,0 @@
-// run-pass
-// aux-build:dynamic_runner.rs
-// compile-flags:--test
-#![feature(custom_test_frameworks)]
-#![test_runner(dynamic_runner::runner)]
-
-extern crate dynamic_runner;
-
-pub struct AllFoo(&'static str);
-struct IsFoo(String);
-
-impl dynamic_runner::Testable for AllFoo {
-    fn name(&self) -> String {
-        String::from(self.0)
-    }
-
-    fn subtests(&self) -> Vec<Box<dyn dynamic_runner::Testable>> {
-        self.0.split(" ").map(|word|
-            Box::new(IsFoo(word.into())) as Box<dyn dynamic_runner::Testable>
-        ).collect()
-    }
-}
-
-impl dynamic_runner::Testable for IsFoo {
-    fn name(&self) -> String {
-        self.0.clone()
-    }
-
-    fn run(&self) -> bool {
-        self.0 == "foo"
-    }
-}
-
-#[test_case]
-const TEST_2: AllFoo = AllFoo("foo foo");
diff --git a/src/test/ui/custom_test_frameworks/full.rs b/src/test/ui/custom_test_frameworks/full.rs
deleted file mode 100644
index 8c818826857..00000000000
--- a/src/test/ui/custom_test_frameworks/full.rs
+++ /dev/null
@@ -1,28 +0,0 @@
-// run-pass
-// aux-build:example_runner.rs
-// compile-flags:--test
-
-#![feature(custom_test_frameworks)]
-#![test_runner(example_runner::runner)]
-extern crate example_runner;
-
-pub struct IsFoo(&'static str);
-
-impl example_runner::Testable for IsFoo {
-    fn name(&self) -> String {
-        self.0.to_string()
-    }
-
-    fn run(&self) -> Option<String> {
-        if self.0 != "foo" {
-            return Some(format!("{} != foo", self.0));
-        }
-        None
-    }
-}
-
-#[test_case]
-const TEST_1: IsFoo = IsFoo("hello");
-
-#[test_case]
-const TEST_2: IsFoo = IsFoo("foo");
diff --git a/src/test/ui/custom_test_frameworks/mismatch.rs b/src/test/ui/custom_test_frameworks/mismatch.rs
deleted file mode 100644
index ac850552b5b..00000000000
--- a/src/test/ui/custom_test_frameworks/mismatch.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-// aux-build:example_runner.rs
-// compile-flags:--test
-#![feature(custom_test_frameworks)]
-#![test_runner(example_runner::runner)]
-
-extern crate example_runner;
-
-#[test]
-fn wrong_kind(){}
-//~^ ERROR trait bound `TestDescAndFn: Testable` is not satisfied
diff --git a/src/test/ui/custom_test_frameworks/mismatch.stderr b/src/test/ui/custom_test_frameworks/mismatch.stderr
deleted file mode 100644
index 61061ae529d..00000000000
--- a/src/test/ui/custom_test_frameworks/mismatch.stderr
+++ /dev/null
@@ -1,14 +0,0 @@
-error[E0277]: the trait bound `TestDescAndFn: Testable` is not satisfied
-  --> $DIR/mismatch.rs:9:1
-   |
-LL | #[test]
-   | ------- in this procedural macro expansion
-LL | fn wrong_kind(){}
-   | ^^^^^^^^^^^^^^^^^ the trait `Testable` is not implemented for `TestDescAndFn`
-   |
-   = note: required for the cast from `TestDescAndFn` to the object type `dyn Testable`
-   = note: this error originates in the attribute macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0277`.