about summary refs log tree commit diff
path: root/src/doc/rustc-dev-guide
diff options
context:
space:
mode:
authorAlexey Shmalko <rasen.dubi@gmail.com>2019-04-17 11:55:14 +0300
committerWho? Me?! <mark-i-m@users.noreply.github.com>2019-04-17 22:28:36 -0500
commit43ac079bd120b1adc378f7f0e4dce62784ff736f (patch)
tree195e4d4461e172ecfef8c2fe0ff31da302f6faca /src/doc/rustc-dev-guide
parent8522ac2305ce41a7c19b38bb4519b6f66b58bc42 (diff)
downloadrust-43ac079bd120b1adc378f7f0e4dce62784ff736f.tar.gz
rust-43ac079bd120b1adc378f7f0e4dce62784ff736f.zip
Update test-implementation chapter to current code
`test_main_static` is now used instead of `test_static_main`.

The libsyntax no longer generates a `TESTS` constant but rather passes
all test cases directly into `test_main_static` as a slice.

Update the guide accordingly.
Diffstat (limited to 'src/doc/rustc-dev-guide')
-rw-r--r--src/doc/rustc-dev-guide/src/test-implementation.md18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/doc/rustc-dev-guide/src/test-implementation.md b/src/doc/rustc-dev-guide/src/test-implementation.md
index 3c93ad619ee..969d6d2e49d 100644
--- a/src/doc/rustc-dev-guide/src/test-implementation.md
+++ b/src/doc/rustc-dev-guide/src/test-implementation.md
@@ -81,20 +81,18 @@ Now that our tests are accessible from the root of our crate, we need to do
 something with them. `libsyntax` generates a module like so:
 
 ```rust,ignore
-pub mod __test {
+#[main]
+pub fn main() {
   extern crate test;
-  const TESTS: &'static [self::test::TestDescAndFn] = &[/*...*/];
-
-  #[main]
-  pub fn main() {
-    self::test::test_static_main(TESTS);
-  }
+  test::test_main_static(&[&path::to::test1, /*...*/]);
 }
 ```
 
+where `path::to::test1` is a constant of type `test::TestDescAndFn`.
+
 While this transformation is simple, it gives us a lot of insight into how
 tests are actually run. The tests are aggregated into an array and passed to
-a test runner called `test_static_main`. We'll come back to exactly what
+a test runner called `test_main_static`. We'll come back to exactly what
 `TestDescAndFn` is, but for now, the key takeaway is that there is a crate
 called [`test`][test] that is part of Rust core, that implements all of the
 runtime for testing. `test`'s interface is unstable, so the only stable way
@@ -119,7 +117,7 @@ configuration information as well. `test` encodes this configuration data
 into a struct called [`TestDesc`][TestDesc]. For each test function in a
 crate, `libsyntax` will parse its attributes and generate a `TestDesc`
 instance. It then combines the `TestDesc` and test function into the
-predictably named `TestDescAndFn` struct, that `test_static_main` operates
+predictably named `TestDescAndFn` struct, that `test_main_static` operates
 on. For a given test, the generated `TestDescAndFn` instance looks like so:
 
 ```rust,ignore
@@ -151,4 +149,4 @@ $ rustc my_mod.rs -Z unpretty=hir
 [Symbol]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax/ast/struct.Ident.html
 [Ident]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax/ast/struct.Ident.html
 [eRFC]: https://github.com/rust-lang/rfcs/blob/master/text/2318-custom-test-frameworks.md
-[libsyntax]: https://github.com/rust-lang/rust/tree/master/src/libsyntax
\ No newline at end of file
+[libsyntax]: https://github.com/rust-lang/rust/tree/master/src/libsyntax