about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJohn Renner <john@jrenner.net>2018-08-30 13:40:33 -0700
committerJohn Renner <john@jrenner.net>2018-09-04 22:33:11 -0700
commite5ed10571690b2ee4fc64319967973b2e50b517f (patch)
treedd2f61c45a99bd3a6bcdb161ee3e5a71fb265331
parent08ea5b7c78a864da0b1a348c3c3425e8611cef76 (diff)
downloadrust-e5ed10571690b2ee4fc64319967973b2e50b517f.tar.gz
rust-e5ed10571690b2ee4fc64319967973b2e50b517f.zip
Document #[test_case] and #![test_runner]
-rw-r--r--src/doc/unstable-book/src/language-features/custom-test-frameworks.md33
-rw-r--r--src/test/ui/issues/issue-11692-2.rs2
-rw-r--r--src/test/ui/issues/issue-11692-2.stderr2
-rw-r--r--src/test/ui/test-shadowing/auxiliary/test_macro.rs2
-rw-r--r--src/test/ui/test-shadowing/test-cant-be-shadowed.rs2
5 files changed, 37 insertions, 4 deletions
diff --git a/src/doc/unstable-book/src/language-features/custom-test-frameworks.md b/src/doc/unstable-book/src/language-features/custom-test-frameworks.md
new file mode 100644
index 00000000000..3990b6ad2f0
--- /dev/null
+++ b/src/doc/unstable-book/src/language-features/custom-test-frameworks.md
@@ -0,0 +1,33 @@
+# `custom_test_frameworks`
+
+The tracking issue for this feature is: [#50297]
+
+[#50297]: https://github.com/rust-lang/rust/issues/50297
+
+------------------------
+
+The `custom_test_frameworks` feature allows the use of `#[test_case]` and `#![test_runner]`.
+Any function, const, or static can be annotated with `#[test_case]` causing it to be aggregated (like `#[test]`)
+and be passed to the test runner determined by the `#![test_runner]` crate attribute.
+
+```rust
+#![feature(custom_test_frameworks)]
+#![test_runner(my_runner)]
+
+fn my_runner(tests: &[&i32]) {
+    for t in tests {
+        if **t == 0 {
+            println!("PASSED");
+        } else {
+            println!("FAILED");
+        }
+    }
+}
+
+#[test_case]
+const WILL_PASS: i32 = 0;
+
+#[test_case]
+const WILL_FAIL: i32 = 4;
+```
+
diff --git a/src/test/ui/issues/issue-11692-2.rs b/src/test/ui/issues/issue-11692-2.rs
index d1f5712afb6..424cbd981c8 100644
--- a/src/test/ui/issues/issue-11692-2.rs
+++ b/src/test/ui/issues/issue-11692-2.rs
@@ -10,5 +10,5 @@
 
 fn main() {
     concat!(test!());
-    //~^ error: `test` can only be used in attributes
+    //~^ error: cannot find macro `test!` in this scope
 }
diff --git a/src/test/ui/issues/issue-11692-2.stderr b/src/test/ui/issues/issue-11692-2.stderr
index 6c21287bed3..51d6041e922 100644
--- a/src/test/ui/issues/issue-11692-2.stderr
+++ b/src/test/ui/issues/issue-11692-2.stderr
@@ -1,4 +1,4 @@
-error: `test` can only be used in attributes
+error: cannot find macro `test!` in this scope
   --> $DIR/issue-11692-2.rs:12:13
    |
 LL |     concat!(test!());
diff --git a/src/test/ui/test-shadowing/auxiliary/test_macro.rs b/src/test/ui/test-shadowing/auxiliary/test_macro.rs
index ba7ed73b822..2e9d2dcc410 100644
--- a/src/test/ui/test-shadowing/auxiliary/test_macro.rs
+++ b/src/test/ui/test-shadowing/auxiliary/test_macro.rs
@@ -11,4 +11,4 @@
 #[macro_export]
 macro_rules! test {
     () => {};
-}
\ No newline at end of file
+}
diff --git a/src/test/ui/test-shadowing/test-cant-be-shadowed.rs b/src/test/ui/test-shadowing/test-cant-be-shadowed.rs
index 4ae8b7ffe8b..4b1a437818f 100644
--- a/src/test/ui/test-shadowing/test-cant-be-shadowed.rs
+++ b/src/test/ui/test-shadowing/test-cant-be-shadowed.rs
@@ -15,4 +15,4 @@
 #[macro_use] extern crate test_macro;
 
 #[test]
-fn foo(){}
\ No newline at end of file
+fn foo(){}