Skip to content

Commit bfcc6d6

Browse files
committed
Update contributing documentation for running tests and building docs.
1 parent e70a376 commit bfcc6d6

File tree

3 files changed

+94
-46
lines changed

3 files changed

+94
-46
lines changed

CONTRIBUTING.md

Lines changed: 53 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,59 @@ in `test/` provide templates on how to test Cargo's behavior in a
8888
sandbox-environment. The internal module `crates/cargo-test-support` provides a vast amount
8989
of helpers to minimize boilerplate. See [`crates/cargo-test-support/src/lib.rs`] for an
9090
introduction to writing tests.
91-
* Make sure `cargo test` passes. If you do not have the cross-compilers
92-
installed locally, install them using the instructions returned by
93-
`cargo test cross_compile::cross_tests` (twice, with `--toolchain nightly`
94-
added to get the nightly cross target too); alternatively just
95-
ignore the cross-compile test failures or disable them by
96-
using `CFG_DISABLE_CROSS_TESTS=1 cargo test`. Note that some tests are enabled
97-
only on `nightly` toolchain. If you can, test both toolchains.
91+
* Make sure `cargo test` passes. See [Running tests](#running-tests) below
92+
for details on running tests.
9893
* All code changes are expected to comply with the formatting suggested by `rustfmt`.
99-
You can use `rustup component add --toolchain nightly rustfmt` to install `rustfmt` and use
100-
`rustfmt +nightly --unstable-features --skip-children` on the changed files to automatically format your code.
94+
You can use `rustup component add rustfmt` to install `rustfmt` and use
95+
`cargo fmt` to automatically format your code.
10196
* Push your commits to GitHub and create a pull request against Cargo's
10297
`master` branch.
10398

99+
## Running tests
100+
101+
Most of the tests are found in the `testsuite` integration test. This can be
102+
run with a simple `cargo test`.
103+
104+
Some tests only run on the nightly toolchain, and will be ignored on other
105+
channels. It is recommended that you run tests with both nightly and stable to
106+
ensure everything is working as expected.
107+
108+
Some tests exercise cross compiling to a different target. This will require
109+
you to install the appropriate target. This typically is the 32-bit target of
110+
your host platform. For example, if your host is a 64-bit
111+
`x86_64-unknown-linux-gnu`, then you should install the 32-bit target with
112+
`rustup target add i686-unknown-linux-gnu`. If you don't have the alternate
113+
target installed, there should be an error message telling you what to do. You
114+
may also need to install additional tools for the target. For example, on Ubuntu
115+
you should install the `gcc-multilib` package.
116+
117+
If you can't install an alternate target, you can set the
118+
`CFG_DISABLE_CROSS_TESTS=1` environment variable to disable these tests.
119+
Unfortunately 32-bit support on macOS is going away, so you may not be able to
120+
run these tests on macOS. The Windows cross tests only support the MSVC
121+
toolchain.
122+
123+
Some of the nightly tests require the `rustc-dev` component installed. This
124+
component includes the compiler as a library. This may already be installed
125+
with your nightly toolchain, but it if isn't, run `rustup component add
126+
rustc-dev --toolchain=nightly`.
127+
128+
There are several other packages in the repo for running specialized tests,
129+
and you will need to run these tests separately by changing into its directory
130+
and running `cargo test`:
131+
132+
* [`crates/resolver-tests`] – This package runs tests on the dependency resolver.
133+
* [`crates/cargo-platform`] – This is a standalone `cfg()` expression parser.
134+
135+
The `build-std` tests are disabled by default, but you can run them by setting
136+
the `CARGO_RUN_BUILD_STD_TESTS=1` environment variable and running `cargo test
137+
--test build-std`. This requires the nightly channel, and also requires the
138+
`rust-src` component installed with `rustup component add rust-src
139+
--toolchain=nightly`.
140+
141+
[`crates/resolver-tests`]: crates/resolver-tests
142+
[`crates/cargo-platform`]: crates/cargo-platform
143+
104144
## Pull requests
105145

106146
After the pull request is made, a friendly bot will automatically assign a
@@ -124,18 +164,8 @@ and [merges][mergequeue] it into Cargo's `master` branch.
124164

125165
## Contributing to the documentation
126166

127-
To contribute to the documentation, all you need to do is change the markdown
128-
files in the `src/doc` directory. To view the rendered version of changes you
129-
have made locally, make sure you have `mdbook` installed and run:
130-
131-
```sh
132-
cd src/doc
133-
mdbook build
134-
open book/index.html
135-
```
136-
137-
To install `mdbook` run `cargo install mdbook`.
138-
167+
See the [documentation README](src/doc/README.md) for details on building the
168+
documentation.
139169

140170
## Issue Triage
141171

@@ -184,6 +214,7 @@ adding labels to triage issues:
184214
* The light orange **relnotes** label marks issues that should be documented in
185215
the release notes of the next release.
186216

217+
* Dark blue, **Z**-prefixed labels are for unstable, nightly features.
187218

188219
[githelp]: https://dont-be-afraid-to-commit.readthedocs.io/en/latest/git/commandlinegit.html
189220
[development-models]: https://help.github.com/articles/about-collaborative-development-models/
@@ -197,6 +228,6 @@ adding labels to triage issues:
197228
[I-nominated]: https://github.com/rust-lang/cargo/labels/I-nominated
198229
[Code of Conduct]: https://www.rust-lang.org/conduct.html
199230
[Discord]: https://discordapp.com/invite/rust-lang
200-
[`crates/cargo-test-support/src/lib.rs`]: https://github.com/rust-lang/cargo/blob/master/crates/cargo-test-support/src/lib.rs
231+
[`crates/cargo-test-support/src/lib.rs`]: crates/cargo-test-support/src/lib.rs
201232
[irlo]: https://internals.rust-lang.org/
202233
[subcommands]: https://doc.rust-lang.org/cargo/reference/external-tools.html#custom-subcommands

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ locally you probably also have `cargo` installed locally.
2020
Cargo requires the following tools and packages to build:
2121

2222
* `git`
23-
* `python`
2423
* `curl` (on Unix)
2524
* `pkg-config` (on Unix, used to figure out the `libssl` headers/libraries)
2625
* OpenSSL headers (only for Unix, this is the `libssl-dev` package on ubuntu)

src/doc/README.md

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,65 @@
1-
# The Cargo Book
1+
# Cargo documentation
22

3+
This directory contains Cargo's documentation. There are two parts, [The Cargo Book]
4+
which is built with [mdbook] and the man pages, which are built with [Asciidoctor].
5+
The man pages are also included in The Cargo Book as HTML.
36

4-
### Requirements
7+
[The Cargo Book]: https://doc.rust-lang.org/cargo/
8+
9+
### Building the book
510

611
Building the book requires [mdBook]. To get it:
712

8-
[mdBook]: https://github.com/rust-lang-nursery/mdBook
13+
[mdBook]: https://github.com/rust-lang/mdBook
914

1015
```console
1116
$ cargo install mdbook
1217
```
1318

14-
### Building
15-
1619
To build the book:
1720

1821
```console
1922
$ mdbook build
2023
```
2124

22-
The output will be in the `book` subdirectory. To check it out, open it in
23-
your web browser.
25+
`mdbook` provides a variety of different commands and options to help you work
26+
on the book:
2427

25-
_Firefox:_
26-
```console
27-
$ firefox book/index.html # Linux
28-
$ open -a "Firefox" book/index.html # OS X
29-
$ Start-Process "firefox.exe" .\book\index.html # Windows (PowerShell)
30-
$ start firefox.exe .\book\index.html # Windows (Cmd)
31-
```
28+
* `mdbook build --open`: Build the book and open it in a web browser.
29+
* `mdbook serve`: Launches a web server on localhost. It also automatically
30+
rebuilds the book whenever any file changes and automatically reloads your
31+
web browser.
32+
33+
The book contents are driven by the [`SUMMARY.md`](src/SUMMARY.md) file, and
34+
every file must be linked there.
35+
36+
### Building the man pages
37+
38+
Building the man pages requires [Asciidoctor]. See the linked page for
39+
installation instructions. It also requires the `make` build tool and `ruby`.
40+
41+
[Asciidoctor]: https://asciidoctor.org/
42+
43+
The source files are located in the [`src/doc/man`](man) directory. The
44+
[`Makefile`](Makefile) is used to rebuild the man pages. It outputs the man
45+
pages into [`src/etc/man`](../etc/man) and the HTML versions into
46+
[`src/doc/man/generated`](man/generated). The Cargo Book has some markdown
47+
stub files in [`src/doc/src/commands`](src/commands) which load the generated
48+
HTML files.
49+
50+
To build the man pages, run `make` in the `src/doc` directory:
3251

33-
_Chrome:_
3452
```console
35-
$ google-chrome book/index.html # Linux
36-
$ open -a "Google Chrome" book/index.html # OS X
37-
$ Start-Process "chrome.exe" .\book\index.html # Windows (PowerShell)
38-
$ start chrome.exe .\book\index.html # Windows (Cmd)
53+
$ make
3954
```
4055

56+
The build script uses a few Asciidoctor extensions. See
57+
[`asciidoc-extension.rb`](asciidoc-extension.rb) for details.
4158

4259
## Contributing
4360

44-
Given that the book is still in a draft state, we'd love your help! Please feel free to open
45-
issues about anything, and send in PRs for things you'd like to fix or change. If your change is
46-
large, please open an issue first, so we can make sure that it's something we'd accept before you
47-
go through the work of getting a PR together.
61+
We'd love your help with improving the documentation! Please feel free to
62+
[open issues](https://github.com/rust-lang/cargo/issues) about anything, and
63+
send in PRs for things you'd like to fix or change. If your change is large,
64+
please open an issue first, so we can make sure that it's something we'd
65+
accept before you go through the work of getting a PR together.

0 commit comments

Comments
 (0)