Skip to content

Commit 18e2f57

Browse files
committed
Add docs for building Fuchsia locally and in CI
1 parent 203ade3 commit 18e2f57

File tree

4 files changed

+123
-13
lines changed

4 files changed

+123
-13
lines changed

src/SUMMARY.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@
2424
- [Compiletest](./tests/compiletest.md)
2525
- [UI tests](./tests/ui.md)
2626
- [Test headers](./tests/headers.md)
27+
- [Integration testing](./tests/integration.md)
28+
- [Crater](./tests/crater.md)
29+
- [Fuchsia](./tests/fuchsia.md)
2730
- [Performance testing](./tests/perf.md)
28-
- [Crater](./tests/crater.md)
2931
- [Suggest tests tool](./tests/suggest-tests.md)
3032
- [Debugging the compiler](./compiler-debugging.md)
3133
- [Using the tracing/logging instrumentation](./tracing.md)

src/tests/fuchsia.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Fuchsia integration tests
2+
3+
[Fuchsia](https://fuchsia.dev) is an open-source operating system with about 2
4+
million lines of Rust code.[^loc] It has caught a large number of [regressions]
5+
in the past and was subsequently included in CI.
6+
7+
## Building Fuchsia in CI
8+
9+
Fuchsia builds as part of the suite of bors tests that run before a pull request
10+
is merged.
11+
12+
If you are worried that a pull request might break the Fuchsia builder and want to test it out before submitting it to the bors queue, simply add this line to your PR description:
13+
14+
> try-job: x86_64-gnu-integration
15+
16+
Then when you `@bors try` it will pick the job that builds Fuchsia.
17+
18+
## Building Fuchsia locally
19+
20+
Because Fuchsia uses languages other than Rust, it does not use Cargo as a build
21+
system. It also requires the toolchain build to be configured in a [certain
22+
way][build-toolchain].
23+
24+
The recommended way to build Fuchsia is to use the Docker scripts that check out
25+
and run a Fuchsia build for you. If you've run Docker tests before, you can
26+
simply run this command from your Rust checkout to download and build Fuchsia
27+
using your local Rust toolchain.
28+
29+
```
30+
src/ci/docker/run.sh x86_64-gnu-integration
31+
```
32+
33+
See the [Testing with Docker](docker.md) chapter for more details on how to run
34+
and debug jobs with Docker.
35+
36+
Note that a Fuchsia checkout is *large* – as of this writing, a checkout and
37+
build takes 46G of space – and as you might imagine, it takes awhile to
38+
complete.
39+
40+
### Customizing the Fuchsia checkout and build
41+
42+
The main reason you would want to build Fuchsia locally is because you need to
43+
investigate a regression. After running a Docker build, you'll find the Fuchsia
44+
checkout inside the `obj/fuchsia` directory of your Rust checkout. If you
45+
modify the `KEEP_CHECKOUT` line in the [build-fuchsia.sh] script to
46+
`KEEP_CHECKOUT=1`, you can change the checkout as needed and rerun the build
47+
command above. This will reuse all the build results from before.
48+
49+
You can find more options to customize the Fuchsia checkout in the
50+
[build-fuchsia.sh] script, and more info about building Fuchsia in the
51+
[build_fuchsia_from_rust_ci.sh] script it invokes.
52+
53+
## Fuchsia target support
54+
55+
To learn more about Fuchsia target support, see the Fuchsia chapter in [the
56+
rustc book][platform-support].
57+
58+
[regressions]: https://gist.github.com/tmandry/7103eba4bd6a6fb0c439b5a90ae355fa
59+
[build-toolchain]: https://fuchsia.dev/fuchsia-src/development/build/rust_toolchain
60+
[build-fuchsia.sh]: https://github.com/rust-lang/rust/pull/126105/files?file-filters%5B%5D=.sh&show-viewed-files=true
61+
[build_fuchsia_from_rust_ci.sh]: https://cs.opensource.google/fuchsia/fuchsia/+/main:scripts/rust/build_fuchsia_from_rust_ci.sh?q=build_fuchsia_from_rust_ci&ss=fuchsia
62+
[platform-support]: https://doc.rust-lang.org/nightly/rustc/platform-support/fuchsia.html
63+
64+
[^loc]: As of June 2024, Fuchsia had about 2 million lines of first-party Rust code
65+
and a roughly equal amount of third-party code, as counted by tokei (excluding
66+
comments and blanks).

src/tests/integration.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Integration testing
2+
3+
Rust tests integration with real-world code to catch regressions and make
4+
informed decisions about the evolution of the language.
5+
6+
## Testing methods
7+
8+
### Crater
9+
10+
Crater is a tool which runs tests on many thousands of public projects. This
11+
tool has its own separate infrastructure for running, and is not run as part of
12+
CI. See the [Crater chapter](crater.md) for more details.
13+
14+
### Cargo test
15+
16+
`cargotest` is a small tool which runs `cargo test` on a few sample projects
17+
(such as `servo`, `ripgrep`, `tokei`, etc.).
18+
This runs as part of CI and ensures there aren't any significant regressions.
19+
20+
> Example: `./x test src/tools/cargotest`
21+
22+
### Integration builders
23+
24+
Integration jobs build large open-source Rust projects that are used as
25+
regression tests in CI.
26+
27+
Fuchsia is currently the only project used in this way. See the [Fuchsia
28+
chapter](fuchsia.md) for more details.
29+
30+
## A note about terminology
31+
32+
The term "integration testing" can be used to mean many things. Many of the
33+
compiletest tests within the Rust repo could be justifiably called integration
34+
tests, because they test the integration of many parts of the compiler, or test
35+
the integration of the compiler with other external tools. Calling all of them
36+
integration tests would not be very helpful, especially since those kinds of
37+
tests already have their own specialized names.
38+
39+
We use the term "integration" here to mean integrating the Rust compiler and
40+
toolchain with the ecosystem of Rust projects that depend on it. This is partly
41+
for lack of a better term, but it also reflects a difference in testing approach
42+
from other projects and the comparative advantage it implies.
43+
44+
The Rust compiler is part of the ecosystem, and the ecosystem is in many cases
45+
part of Rust, both in terms of libraries it uses and in terms of the efforts of many
46+
contributors who come to "scratch their own itch". Finally, because Rust has the
47+
ability to do integration testing at such a broad scale, it shortens development
48+
cycles by finding defects earlier.
49+

src/tests/intro.md

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -132,19 +132,12 @@ More information can be found in the [toolstate documentation].
132132
[toolstate documentation]: https://forge.rust-lang.org/infra/toolstate.html
133133
[toolstate website]: https://rust-lang-nursery.github.io/rust-toolstate/
134134

135-
### Cargo test
135+
### Integration testing
136136

137-
`cargotest` is a small tool which runs `cargo test` on a few sample projects
138-
(such as `servo`, `ripgrep`, `tokei`, etc.).
139-
This ensures there aren't any significant regressions.
140-
141-
> Example: `./x test src/tools/cargotest`
142-
143-
### Crater
144-
145-
Crater is a tool which runs tests on many thousands of public projects.
146-
This tool has its own separate infrastructure for running.
147-
See the [Crater chapter](crater.md) for more details.
137+
Rust tests integration with real-world code to catch regressions and make
138+
informed decisions about the evolution of the language. There are several kinds
139+
of integration tests, including Crater. See the [Integration testing
140+
chapter](integration.md) for more details.
148141

149142
### Performance testing
150143

0 commit comments

Comments
 (0)