Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustbuild: Add support for crate tests + doctests #33282

Merged
merged 2 commits into from
May 13, 2016

Conversation

alexcrichton
Copy link
Member

This commit adds support to rustbuild to run crate unit tests (those defined by
#[test]) as well as documentation tests. All tests are powered by cargo test
under the hood.

Each step requires the libtest library is built for that corresponding stage.
Ideally the test crate would be a dev-dependency, but for now it's just easier
to ensure that we sequence everything in the right order.

Currently no filtering is implemented, so there's not actually a method of
testing only libstd or only libcore, but rather entire swaths of crates are
tested all at once.

A few points of note here are:

  • The coretest and collectionstest crates are just listed as [[test]]
    entires for cargo test to naturally pick up. This mean that cargo test -p core actually runs all the tests for libcore.
  • Libraries that aren't tested all mention test = false in their Cargo.toml
  • Crates aren't currently allowed to have dev-dependencies due to
    Dev-dependencies are not linked when testing subpackages cargo#860, but we can likely alleviate this restriction once
    workspaces are implemented.

cc #31590

@alexcrichton
Copy link
Member Author

r? @brson

@rust-highfive rust-highfive assigned aturon and brson and unassigned aturon Apr 29, 2016
@rust-highfive
Copy link
Collaborator

r? @aturon

(rust_highfive has picked a reviewer for you, use r? to override)

cargo.args(&build.flags.args);

build.run(&mut cargo);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fairly ugly function. Why search the dag like this and run cargo with a bunch of -p flags instead of calling cargo test on every individual crate?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running cargo test with a bunch of -p flags gives us the ability to compile all the crate tests in parallel (but run them sequentially). Ideally this'd just be cargo test --all, but unfortunately that's not implemented yet :(

Running cargo test on each individual crate would work, but we'd still have to discover the list of crates somewhere and we unfortunately wouldn't get the same parallelism :(

@brson
Copy link
Contributor

brson commented Apr 29, 2016

@bors r+

@bors
Copy link
Contributor

bors commented Apr 29, 2016

📌 Commit 58902f5 has been approved by brson

@bors
Copy link
Contributor

bors commented Apr 29, 2016

⌛ Testing commit 58902f5 with merge b0e3f7a...

@bors
Copy link
Contributor

bors commented Apr 29, 2016

💔 Test failed - auto-win-msvc-64-cargotest

@alexcrichton
Copy link
Member Author

@bors: r=brson 4c42905

@bors
Copy link
Contributor

bors commented Apr 30, 2016

⌛ Testing commit 4c42905 with merge 4f41647...

@bors
Copy link
Contributor

bors commented Apr 30, 2016

💔 Test failed - auto-win-gnu-32-opt-rustbuild

@alexcrichton
Copy link
Member Author

@bors: r=brson 7606bfd

@bors
Copy link
Contributor

bors commented Apr 30, 2016

⌛ Testing commit 7606bfd with merge 58a22a2...

@bors
Copy link
Contributor

bors commented Apr 30, 2016

💔 Test failed - auto-win-gnu-32-opt-rustbuild

@alexcrichton
Copy link
Member Author

@bors: r=brson f5a73cb

Chalking up another segfault to opt-level=3 ...

@bors
Copy link
Contributor

bors commented May 3, 2016

⌛ Testing commit f5a73cb with merge de696cd...

@bors
Copy link
Contributor

bors commented May 3, 2016

💔 Test failed - auto-win-gnu-32-opt-rustbuild

Ensure that `rerun-if-changed` is printed for all build scripts to ensure that
they've all got the right list of dependencies.
@alexcrichton
Copy link
Member Author

@bors: r=brson d11e3c1

@bors
Copy link
Contributor

bors commented May 12, 2016

⌛ Testing commit d11e3c1 with merge 4d9c301...

@bors
Copy link
Contributor

bors commented May 12, 2016

💔 Test failed - auto-win-msvc-64-opt-rustbuild

This commit adds support to rustbuild to run crate unit tests (those defined by
`#[test]`) as well as documentation tests. All tests are powered by `cargo test`
under the hood.

Each step requires the `libtest` library is built for that corresponding stage.
Ideally the `test` crate would be a dev-dependency, but for now it's just easier
to ensure that we sequence everything in the right order.

Currently no filtering is implemented, so there's not actually a method of
testing *only* libstd or *only* libcore, but rather entire swaths of crates are
tested all at once.

A few points of note here are:

* The `coretest` and `collectionstest` crates are just listed as `[[test]]`
  entires for `cargo test` to naturally pick up. This mean that `cargo test -p
  core` actually runs all the tests for libcore.
* Libraries that aren't tested all mention `test = false` in their `Cargo.toml`
* Crates aren't currently allowed to have dev-dependencies due to
  rust-lang/cargo#860, but we can likely alleviate this restriction once
  workspaces are implemented.

cc rust-lang#31590
@alexcrichton
Copy link
Member Author

@bors: r=brson bb9062a

@bors
Copy link
Contributor

bors commented May 12, 2016

⌛ Testing commit bb9062a with merge 584f1b5...

@bors
Copy link
Contributor

bors commented May 12, 2016

⛄ The build was interrupted to prioritize another pull request.

@bors
Copy link
Contributor

bors commented May 12, 2016

⌛ Testing commit bb9062a with merge 7c8476a...

eddyb added a commit to eddyb/rust that referenced this pull request May 12, 2016
… r=brson

rustbuild: Add support for crate tests + doctests

This commit adds support to rustbuild to run crate unit tests (those defined by
`#[test]`) as well as documentation tests. All tests are powered by `cargo test`
under the hood.

Each step requires the `libtest` library is built for that corresponding stage.
Ideally the `test` crate would be a dev-dependency, but for now it's just easier
to ensure that we sequence everything in the right order.

Currently no filtering is implemented, so there's not actually a method of
testing *only* libstd or *only* libcore, but rather entire swaths of crates are
tested all at once.

A few points of note here are:

* The `coretest` and `collectionstest` crates are just listed as `[[test]]`
  entires for `cargo test` to naturally pick up. This mean that `cargo test -p
  core` actually runs all the tests for libcore.
* Libraries that aren't tested all mention `test = false` in their `Cargo.toml`
* Crates aren't currently allowed to have dev-dependencies due to
  rust-lang/cargo#860, but we can likely alleviate this restriction once
  workspaces are implemented.

cc rust-lang#31590
@bors
Copy link
Contributor

bors commented May 12, 2016

⛄ The build was interrupted to prioritize another pull request.

eddyb added a commit to eddyb/rust that referenced this pull request May 12, 2016
… r=brson

rustbuild: Add support for crate tests + doctests

This commit adds support to rustbuild to run crate unit tests (those defined by
`#[test]`) as well as documentation tests. All tests are powered by `cargo test`
under the hood.

Each step requires the `libtest` library is built for that corresponding stage.
Ideally the `test` crate would be a dev-dependency, but for now it's just easier
to ensure that we sequence everything in the right order.

Currently no filtering is implemented, so there's not actually a method of
testing *only* libstd or *only* libcore, but rather entire swaths of crates are
tested all at once.

A few points of note here are:

* The `coretest` and `collectionstest` crates are just listed as `[[test]]`
  entires for `cargo test` to naturally pick up. This mean that `cargo test -p
  core` actually runs all the tests for libcore.
* Libraries that aren't tested all mention `test = false` in their `Cargo.toml`
* Crates aren't currently allowed to have dev-dependencies due to
  rust-lang/cargo#860, but we can likely alleviate this restriction once
  workspaces are implemented.

cc rust-lang#31590
bors added a commit that referenced this pull request May 12, 2016
bors added a commit that referenced this pull request May 12, 2016
rustbuild: Add support for crate tests + doctests

This commit adds support to rustbuild to run crate unit tests (those defined by
`#[test]`) as well as documentation tests. All tests are powered by `cargo test`
under the hood.

Each step requires the `libtest` library is built for that corresponding stage.
Ideally the `test` crate would be a dev-dependency, but for now it's just easier
to ensure that we sequence everything in the right order.

Currently no filtering is implemented, so there's not actually a method of
testing *only* libstd or *only* libcore, but rather entire swaths of crates are
tested all at once.

A few points of note here are:

* The `coretest` and `collectionstest` crates are just listed as `[[test]]`
  entires for `cargo test` to naturally pick up. This mean that `cargo test -p
  core` actually runs all the tests for libcore.
* Libraries that aren't tested all mention `test = false` in their `Cargo.toml`
* Crates aren't currently allowed to have dev-dependencies due to
  rust-lang/cargo#860, but we can likely alleviate this restriction once
  workspaces are implemented.

cc #31590
@bors
Copy link
Contributor

bors commented May 12, 2016

⌛ Testing commit bb9062a with merge 4ec5ce5...

@bors bors merged commit bb9062a into rust-lang:master May 13, 2016
@alexcrichton alexcrichton deleted the rustbuild-crate-tests branch May 25, 2016 00:22
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 3, 2023
Enable tests on rustc_codegen_ssa

This enables unittests in rustc_codegen_ssa. There are some tests, primarily in [`back/rpath/tests.rs`](https://github.com/rust-lang/rust/blob/HEAD/compiler/rustc_codegen_ssa/src/back/rpath/tests.rs) that haven't ever been running since the unittests are disabled. From what I can tell, this was just a consequence of how things evolved. When testing was initially added in rust-lang#33282, `librustc_trans` had test=false because it didn't have any tests. `rustc_codegen_ssa` eventually split off from that (rust-lang#55627), and the rpath module eventually got merged in too (from `librustc_back` where it used to live). That migration didn't enable the tests.

This also includes some fluent diagnostic tests, though I'm not sure what exactly they are testing.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 4, 2023
Enable tests on rustc_codegen_ssa

This enables unittests in rustc_codegen_ssa. There are some tests, primarily in [`back/rpath/tests.rs`](https://github.com/rust-lang/rust/blob/HEAD/compiler/rustc_codegen_ssa/src/back/rpath/tests.rs) that haven't ever been running since the unittests are disabled. From what I can tell, this was just a consequence of how things evolved. When testing was initially added in rust-lang#33282, `librustc_trans` had test=false because it didn't have any tests. `rustc_codegen_ssa` eventually split off from that (rust-lang#55627), and the rpath module eventually got merged in too (from `librustc_back` where it used to live). That migration didn't enable the tests.

This also includes some fluent diagnostic tests, though I'm not sure what exactly they are testing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants