You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/defs.md
+5-13Lines changed: 5 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -468,7 +468,9 @@ mod test {
468
468
}
469
469
```
470
470
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:
472
474
473
475
`hello_lib/BUILD`:
474
476
```python
@@ -479,25 +481,15 @@ rust_library(
479
481
srcs= ["src/lib.rs"],
480
482
)
481
483
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
493
484
rust_test(
494
485
name="hello_lib_test",
495
486
crate=":hello_lib",
496
487
# You may add other deps that are specific to the test configuration
497
488
deps= ["//some/dev/dep"],
498
-
)
499
489
```
500
490
491
+
Run the test with`bazel build //hello_lib:hello_lib_test`.
492
+
501
493
### Example: `test` directory
502
494
503
495
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:
Copy file name to clipboardExpand all lines: docs/flatten.md
+5-13Lines changed: 5 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -956,7 +956,9 @@ mod test {
956
956
}
957
957
```
958
958
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:
960
962
961
963
`hello_lib/BUILD`:
962
964
```python
@@ -967,25 +969,15 @@ rust_library(
967
969
srcs= ["src/lib.rs"],
968
970
)
969
971
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
981
972
rust_test(
982
973
name="hello_lib_test",
983
974
crate=":hello_lib",
984
975
# You may add other deps that are specific to the test configuration
985
976
deps= ["//some/dev/dep"],
986
-
)
987
977
```
988
978
979
+
Run the test with`bazel build //hello_lib:hello_lib_test`.
980
+
989
981
### Example: `test` directory
990
982
991
983
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:
0 commit comments