From d675461aa9f47dad341f55ef104738e4babb8675 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Wed, 5 Jul 2023 02:03:58 +0200 Subject: [PATCH 1/2] improve explanation of placing tests in separate file --- src/tests/intro.md | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/tests/intro.md b/src/tests/intro.md index aad77e255..1d3d0b93c 100644 --- a/src/tests/intro.md +++ b/src/tests/intro.md @@ -43,9 +43,9 @@ The standard library relies very heavily on documentation tests to cover its fun However, unit tests and integration tests can also be used as needed. Almost all of the compiler packages have doctests disabled. -The standard library and compiler always place all unit tests in a separate `tests` file -(this is enforced in [tidy][tidy-unit-tests]). -This approach ensures that when the test file is changed, the crate does not need to be recompiled. +All standard library and compiler unit tests are placed in separate `tests` file +(which is enforced in [tidy][tidy-unit-tests]). +This ensures that when the test file is changed, the crate does not need to be recompiled. For example: ```rust,ignore @@ -53,10 +53,9 @@ For example: mod tests; ``` -If it wasn't done this way, and the tests were placed in the same file as the source, -then changing or adding a test would cause the crate you are working on to be recompiled. -If you were working on something like `core`, -then that would require recompiling the entire standard library, and the entirety of `rustc`. +If it wasn't done this way, +and you were working on something like `core`, +that would require recompiling the entire standard library, and the entirety of `rustc`. `./x test` includes some CLI options for controlling the behavior with these tests: From af4ab0c320295bd130151d913d7257b254bc575f Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sat, 8 Jul 2023 11:53:46 +0900 Subject: [PATCH 2/2] Update src/tests/intro.md --- src/tests/intro.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/intro.md b/src/tests/intro.md index 1d3d0b93c..647d1fbea 100644 --- a/src/tests/intro.md +++ b/src/tests/intro.md @@ -53,7 +53,7 @@ For example: mod tests; ``` -If it wasn't done this way, +If it wasn't done this way, and you were working on something like `core`, that would require recompiling the entire standard library, and the entirety of `rustc`.