Skip to content

Commit 965044a

Browse files
cfredricUebelAndre
andauthored
Remove rust_test example which doesn't build. (#1267)
* Remove `rust_test` example which doesn't compile. * Regenerate documentation Co-authored-by: cfredric <cfredric@chromium.org> Co-authored-by: UebelAndre <github@uebelandre.com>
1 parent f6e7e0a commit 965044a

3 files changed

Lines changed: 15 additions & 41 deletions

File tree

docs/defs.md

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,9 @@ mod test {
468468
}
469469
```
470470

471-
To build and run the tests, simply add a `rust_test` rule with no `srcs` and only depends on the `hello_lib` `rust_library` target:
471+
To build and run the tests, simply add a `rust_test` rule with no `srcs`
472+
and only depends on the `hello_lib` `rust_library` target via the
473+
`crate` attribute:
472474

473475
`hello_lib/BUILD`:
474476
```python
@@ -479,25 +481,15 @@ rust_library(
479481
srcs = ["src/lib.rs"],
480482
)
481483

482-
rust_test(
483-
name = "hello_lib_test",
484-
deps = [":hello_lib"],
485-
)
486-
```
487-
488-
Run the test with `bazel build //hello_lib:hello_lib_test`.
489-
490-
To run a crate or lib with the `#[cfg(test)]` configuration, handling inline tests, you should specify the crate directly like so.
491-
492-
```python
493484
rust_test(
494485
name = "hello_lib_test",
495486
crate = ":hello_lib",
496487
# You may add other deps that are specific to the test configuration
497488
deps = ["//some/dev/dep"],
498-
)
499489
```
500490

491+
Run the test with `bazel build //hello_lib:hello_lib_test`.
492+
501493
### Example: `test` directory
502494

503495
Integration tests that live in the [`tests` directory][int-tests], they are essentially built as separate crates. Suppose you have the following directory structure where `greeting.rs` is an integration test for the `hello_lib` library crate:

docs/flatten.md

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,9 @@ mod test {
956956
}
957957
```
958958

959-
To build and run the tests, simply add a `rust_test` rule with no `srcs` and only depends on the `hello_lib` `rust_library` target:
959+
To build and run the tests, simply add a `rust_test` rule with no `srcs`
960+
and only depends on the `hello_lib` `rust_library` target via the
961+
`crate` attribute:
960962

961963
`hello_lib/BUILD`:
962964
```python
@@ -967,25 +969,15 @@ rust_library(
967969
srcs = ["src/lib.rs"],
968970
)
969971

970-
rust_test(
971-
name = "hello_lib_test",
972-
deps = [":hello_lib"],
973-
)
974-
```
975-
976-
Run the test with `bazel build //hello_lib:hello_lib_test`.
977-
978-
To run a crate or lib with the `#[cfg(test)]` configuration, handling inline tests, you should specify the crate directly like so.
979-
980-
```python
981972
rust_test(
982973
name = "hello_lib_test",
983974
crate = ":hello_lib",
984975
# You may add other deps that are specific to the test configuration
985976
deps = ["//some/dev/dep"],
986-
)
987977
```
988978

979+
Run the test with `bazel build //hello_lib:hello_lib_test`.
980+
989981
### Example: `test` directory
990982

991983
Integration tests that live in the [`tests` directory][int-tests], they are essentially built as separate crates. Suppose you have the following directory structure where `greeting.rs` is an integration test for the `hello_lib` library crate:

rust/private/rust.bzl

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,8 +1051,9 @@ rust_test = rule(
10511051
}
10521052
```
10531053
1054-
To build and run the tests, simply add a `rust_test` rule with no `srcs` and \
1055-
only depends on the `hello_lib` `rust_library` target:
1054+
To build and run the tests, simply add a `rust_test` rule with no `srcs`
1055+
and only depends on the `hello_lib` `rust_library` target via the
1056+
`crate` attribute:
10561057
10571058
`hello_lib/BUILD`:
10581059
```python
@@ -1063,26 +1064,15 @@ rust_test = rule(
10631064
srcs = ["src/lib.rs"],
10641065
)
10651066
1066-
rust_test(
1067-
name = "hello_lib_test",
1068-
deps = [":hello_lib"],
1069-
)
1070-
```
1071-
1072-
Run the test with `bazel build //hello_lib:hello_lib_test`.
1073-
1074-
To run a crate or lib with the `#[cfg(test)]` configuration, handling inline \
1075-
tests, you should specify the crate directly like so.
1076-
1077-
```python
10781067
rust_test(
10791068
name = "hello_lib_test",
10801069
crate = ":hello_lib",
10811070
# You may add other deps that are specific to the test configuration
10821071
deps = ["//some/dev/dep"],
1083-
)
10841072
```
10851073
1074+
Run the test with `bazel build //hello_lib:hello_lib_test`.
1075+
10861076
### Example: `test` directory
10871077
10881078
Integration tests that live in the [`tests` directory][int-tests], they are \

0 commit comments

Comments
 (0)