Skip to content

Commit

Permalink
Remove rust_test example which doesn't build. (#1267)
Browse files Browse the repository at this point in the history
* Remove `rust_test` example which doesn't compile.

* Regenerate documentation

Co-authored-by: cfredric <cfredric@chromium.org>
Co-authored-by: UebelAndre <github@uebelandre.com>
  • Loading branch information
3 people committed Apr 20, 2022
1 parent f6e7e0a commit 965044a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 41 deletions.
18 changes: 5 additions & 13 deletions docs/defs.md
Expand Up @@ -468,7 +468,9 @@ mod test {
}
```

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:
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 via the
`crate` attribute:

`hello_lib/BUILD`:
```python
Expand All @@ -479,25 +481,15 @@ rust_library(
srcs = ["src/lib.rs"],
)

rust_test(
name = "hello_lib_test",
deps = [":hello_lib"],
)
```

Run the test with `bazel build //hello_lib:hello_lib_test`.

To run a crate or lib with the `#[cfg(test)]` configuration, handling inline tests, you should specify the crate directly like so.

```python
rust_test(
name = "hello_lib_test",
crate = ":hello_lib",
# You may add other deps that are specific to the test configuration
deps = ["//some/dev/dep"],
)
```

Run the test with `bazel build //hello_lib:hello_lib_test`.

### Example: `test` directory

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:
Expand Down
18 changes: 5 additions & 13 deletions docs/flatten.md
Expand Up @@ -956,7 +956,9 @@ mod test {
}
```

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:
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 via the
`crate` attribute:

`hello_lib/BUILD`:
```python
Expand All @@ -967,25 +969,15 @@ rust_library(
srcs = ["src/lib.rs"],
)

rust_test(
name = "hello_lib_test",
deps = [":hello_lib"],
)
```

Run the test with `bazel build //hello_lib:hello_lib_test`.

To run a crate or lib with the `#[cfg(test)]` configuration, handling inline tests, you should specify the crate directly like so.

```python
rust_test(
name = "hello_lib_test",
crate = ":hello_lib",
# You may add other deps that are specific to the test configuration
deps = ["//some/dev/dep"],
)
```

Run the test with `bazel build //hello_lib:hello_lib_test`.

### Example: `test` directory

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:
Expand Down
20 changes: 5 additions & 15 deletions rust/private/rust.bzl
Expand Up @@ -1051,8 +1051,9 @@ rust_test = rule(
}
```
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:
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 via the
`crate` attribute:
`hello_lib/BUILD`:
```python
Expand All @@ -1063,26 +1064,15 @@ rust_test = rule(
srcs = ["src/lib.rs"],
)
rust_test(
name = "hello_lib_test",
deps = [":hello_lib"],
)
```
Run the test with `bazel build //hello_lib:hello_lib_test`.
To run a crate or lib with the `#[cfg(test)]` configuration, handling inline \
tests, you should specify the crate directly like so.
```python
rust_test(
name = "hello_lib_test",
crate = ":hello_lib",
# You may add other deps that are specific to the test configuration
deps = ["//some/dev/dep"],
)
```
Run the test with `bazel build //hello_lib:hello_lib_test`.
### Example: `test` directory
Integration tests that live in the [`tests` directory][int-tests], they are \
Expand Down

0 comments on commit 965044a

Please sign in to comment.