Commit graph

61 commits

Author SHA1 Message Date
Weihang Lo
64a1f204f3
refactor: only when -C debuginfo > 0 will spilt-debuginfo be passed
It was unnecessary to pass `spilt-debuginfo` if there is no debuginfo.
Tests are touched here only for matching rustflags invocation stderr
in the original test suite.
2023-05-31 20:43:57 +01:00
Weihang Lo
c51c6bb6ac
chore: reflect to clap updates 2023-01-14 09:23:39 +00:00
Dinu Blanovschi
0beb5fe93d Simple explanations for why cargo rebuilds crates 2022-12-28 16:27:50 +01:00
Ed Page
96948f7a24 refactor(cli): Upgrade to clap v4 2022-09-28 13:32:14 -05:00
Eric Huss
cde8f6f692
Merge branch 'master' into stabilize-crate-type 2022-07-17 13:14:44 -07:00
Weihang Lo
db3b5801d7
Update tests to reflect -Zmultitarget stabilization 2022-07-17 11:02:01 +01:00
Weihang Lo
f128cbd5da
Stabilize --crate-type flag for cargo rust 2022-07-16 23:25:55 +01:00
Scott Schafer
c239e407e7 add a reason to masquerade_as_nightly_cargo so it is searchable 2022-07-15 21:32:23 -05:00
Weihang Lo
497051a743
New test for cargo rustc --crate-type with dependency 2022-02-26 09:44:48 +08:00
Weihang Lo
229c48a0b9
Avoid assertion against default value in crate-type tests
`--crate-type` usually defaults to `lib`, so the original assertion is
somehow unuseful. Change to `cdylib` to make the test more robust.
2022-02-26 09:44:48 +08:00
Weihang Lo
11c50416c2
Assert optional args with square brackets [arg...] 2022-01-27 19:28:51 +08:00
Ed Page
f17ecafc24 Upgrade to Clap 3
- One parser change found by `cargo_config::includes` is that clap 2
  would ignore any values after a `=` for flags.
  `cargo config --show-origin` is a flag but the test passed `--show-origin=yes` which
  happens to give the desired result for that test but is the same as
  `--show-origin=no` or `--show-origin=alien-invasion`.
- The parser now panics when accessing an undefined attribute but clap
  takes advantage of that for sharing code across commands that have
  different subsets of arguments defined.  I've extended clap so we can
  "look before you leap" and put the checks at the argument calls to
  start off with so its very clear what is tenuously shared.  This
  allows us to go in either direction in the future, either addressing
  how we are sharing between commands or by moving this down into the
  extension methods and pretending this clap feature doesn't exist
- On that topic, a test found clap-rs/clap#3263.  For now, there is a
  hack in clap.  Depending on how we fix that in clap for clap 4.0, we
  might need to re-address things in cargo.
- `value_of_os` now requires setting `allow_invalid_utf8`, otherwise it
  asserts.  To help catch this, I updated the argument definitions
  associated with lookups reported by:
  - `rg 'values?_os' src/`
  - `rg 'values?_of_os' src/`
- clap now reports `2` for usage errors, so we had to bypass clap's
  `exit` call to keep the same exit code.

BREAKING CHANGE: API now uses clap3
2022-01-05 19:54:54 -06:00
hi-rustin
660ce6bba4 Add tests
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2021-11-23 22:58:18 +08:00
Chris Field
2a5355f9b3 Fix usage of assert methods
The `with_stdout_contains` was mis-used. Since some lines may or may not
appear for some compiler targets and environments (nightly, beta,
stable, etc.) the tests would fail because the output was not identical.
Instead of a using raw strings, each line with the arch, endian, env,
family, vendor, pointer_width, etc. that are known to always be
present (at least of the CI builds) are included. This should work for
the CI environments and my local environment.
2021-02-21 22:58:31 -05:00
Chris Field
9b02dd41e4 Fix tests for CI environment
The `panic="unwind"` appears in the output for the CI tests, but not in
my local tests. I need to investigate the origin of this configuration
but it causes the CI builds to fail.
2021-02-21 21:45:55 -05:00
Chris Field
70a423ebf8 Fix formatting 2021-02-21 20:00:28 -05:00
Chris Field
1f057303b8 Add test with cargo configuration file
A `.cargo/config.toml` file is used to add the "crt-static" target
feature and test printing the compiler target configuration contains the
`target_feature="crt-static"` line.
2021-02-21 19:58:19 -05:00
Chris Field
c7038b22ca Add test using RUSTFLAGS env var
The `RUSTFLAGS` environment variable is used to add the "crt-static"
target feature and test printing the target compiler configuration
contains the `target_feature="crt-static"` line.
2021-02-21 19:54:08 -05:00
Chris Field
8b80e52ca8 Add multitarget test
Using the multitarget feature to print the configuration of multiple
compiler target configurations, a test is created.
2021-02-21 19:50:21 -05:00
Chris Field
de340a2ef6 Add first test
Not sure how to handle running the test on different hosts, so the first
test is explicit about the compile target to print the configuration.
2021-02-21 19:35:33 -05:00
Weihang Lo
8f0664f02a
test: normalize raw string indentation. 2020-10-10 07:44:57 +08:00
Weihang Lo
db313e54a2
test(rustc): glob support for package selection 2020-10-05 01:24:41 +08:00
Eric Huss
6f8c7d5a87 Normalize raw string indentation. 2020-09-26 17:59:58 -07:00
Alex Crichton
bac300bda0 Add support for -Cembed-bitcode=no
This commit is the Cargo half of support necessary for
rust-lang/rust#70458. Today the compiler emits embedded bytecode in
rlibs by default, but compresses it. This is both extraneous disk space
and wasted build time for almost all builds, so the PR in question there
is changing rustc to have a `-Cembed-bitcode` flag which, when enabled,
places the bitcode in the object file rather than an auxiliary file (no
extra compression), but also enables `-Cembed-bitcode=no` to disable
bitcode emission entirely.

This Cargo support changes Cargo to pass `-Cembed-bitcode=no` for almost
all compilations. Cargo will keep `lto = true` and such working by not
passing this flag (and thus allowing bitcode to get embedded), but by
default `cargo build` and `cargo build --release` will no longer have
any bitcode in rlibs which should result in speedier builds!

Most of the changes here were around the test suite and various
assertions about the `rustc` command lines we spit out. One test was
hard-disabled until we can get `-Cembed-bitcode=no` into nightly, and
then we can make it a nightly-only test. The test will then be stable
again once `-Cembed-bitcode=no` hits stable.

Note that this is intended to land before the upstream `-Cembed-bitcode`
change. The thinking is that we'll land everything in rust-lang/rust all
at once so there's no build time regressions for anyone. If we were to
land the `-Cembed-bitcode` PR first then there would be a build time
regression until we land Cargo changes because rustc would be emitting
uncompressed bitcode by default and Cargo wouldn't be turning it off.
2020-04-01 14:31:06 -07:00
Eric Huss
83571aee56 Minor testsuite organization. 2019-11-24 18:42:45 -08:00
Eric Huss
bd73e8dab5 Stabilize cache-messages 2019-09-30 14:04:10 -07:00
Alex Crichton
9115b2c326 Extract support directory to its own crate
Extract out all our test support code to its own standalone crate so it
can be shared between multiple test suites if necessary.
2019-09-16 11:47:09 -07:00
Eric Huss
a4e9611453 Fix some formatting for some strings. 2019-07-13 16:00:47 -07:00
Jethro Beekman
0e0d968825 Update #[test] attribute on all tests in the testsuite
sed -i 's/^#\[test\]/#[cargo_test]/' $(rg -l '^#\[test\]')

Manual fixes:
* proc_macro::proc_macro_doctest
2019-06-07 12:41:26 -07:00
Eric Huss
6b07c8da63 cargo fmt 2019-05-20 12:40:20 -07:00
Alex Crichton
127fdfeb89 Implement the Cargo half of pipelined compilation
This commit starts to lay the groundwork for #6660 where Cargo will
invoke rustc in a "pipelined" fashion. The goal here is to execute one
command to produce both an `*.rmeta` file as well as an `*.rlib` file
for candidate compilations. In that case if another rlib depends on that
compilation, then it can start as soon as the `*.rmeta` is ready and not
have to wait for the `*.rlib` compilation.

Initially attempted in #6864 with a pretty invasive refactoring this
iteration is much more lightweight and fits much more cleanly into
Cargo's backend. The approach taken here is to update the
`DependencyQueue` structure to carry a piece of data on each dependency
edge. This edge information represents the artifact that one node
requires from another, and then we a node has no outgoing edges it's
ready to build.

A dependency on a metadata file is modeled as just that, a dependency on
just the metadata and not the full build itself. Most of cargo's backend
doesn't really need to know about this edge information so it's
basically just calculated as we insert nodes into the `DependencyQueue`.
Once that's all in place it's just a few pieces here and there to
identify compilations that *can* be pipelined and then they're wired up
to depend on the rmeta file instead of the rlib file.
2019-05-08 08:10:26 -07:00
Alexander Regueiro
f7c91ba622
Various cosmetic improvements. 2019-02-20 10:58:27 +00:00
Alex Crichton
fecb724643 Format with cargo fmt 2018-12-08 03:19:47 -08:00
Dale Wijnand
04ddd4d0fc
Upgrade to Rust 2018 2018-12-06 20:18:35 +01:00
Eric Huss
739c272f05 Use "test" profile for cargo build benchmarks. 2018-11-12 13:10:54 -08:00
kennytm
4779dbfe85
Update the testsuite to include the explicit '--color' flags. 2018-09-12 11:59:08 +08:00
Zach Lute
89f43938fe Print file paths instead of file:// URLs.
This change ensures cargo will output file paths in the expected format
(C:\foo\... on Windows, /foo/... elsewhere). Previously it would output
file:// URLs instead.

To support this change, additional changes were made to the test suite
string processing such that [ROOT] is now replaced with the appropriate
file path root for the platform.

The CWD template was also updated to use [CWD] like other replacement
templates and to do the replacement on the expected value rather than
the actual value to avoid replacing things we don't expect with CWD.
2018-09-07 19:42:59 -07:00
Matthias Krüger
2cd9cce6e3 clippy: resolve all warnings about useless format!() 2018-09-03 11:38:29 +02:00
Dale Wijnand
d5fc8dc3a7
Introduce the CWD macro in test output asserting
Avoids dealing with things like CWD changing.
2018-08-30 11:05:29 +02:00
Dale Wijnand
85984a8700
Migrate from tests fom assert_that/execs to .run() 2018-08-28 15:08:12 +02:00
Dale Wijnand
511d4bc503
Collapse multiline ProcessBuilder::arg calls in tests
.. by calling this a bunch of times:

    fastmod --multiline '\.cargo\("([^"]+)"\).[ ]+\.arg\("([^"]+)"\)' '.cargo("${1} ${2}")' tests/testsuite/
2018-08-18 15:12:54 +01:00
Dale Wijnand
af4f1392f7
Collapse ProcessBuilder::arg calls in tests
.. with mutliple calls of:

    fastmod --accept-all '\.cargo\("([^"]+)"\)\.arg\("([^"]+)"\)' '.cargo("${1} ${2}")' tests/testsuite/

until no changes are left.
2018-08-18 15:05:45 +01:00
Matthias Krüger
8798bf0d28 fix a bunch of clippy warnings (invocation: cargo clippy --all-targets --all-features -- --cap-lints warn )
Special thanks to dwijnand for helping me with this! :)
2018-08-12 10:00:12 +02:00
Dale Wijnand
16aeb0cd4f
Default test support's Execs to exit code 0 2018-08-03 07:44:42 +01:00
Dale Wijnand
05400b8018
Drop the [/] test output macro 2018-08-02 10:18:48 +01:00
Dale Wijnand
ca7d9ee292
Declare one-line files on one line, in test projects 2018-07-25 09:58:50 +01:00
Dale Wijnand
ab19c48358
Dedup a bunch more manifest 2018-07-25 00:43:30 +01:00
Dale Wijnand
081e7930d2
Drop now unnecessary basic manifests 2018-07-24 16:33:55 +01:00
Dale Wijnand
43b42d6f4c
Reorganise the testsuite crate module hierarchy
* Collapse the nested cargotest::support module into the cargotest
  module (merge the mod.rs's)
* Rename the cargotest module to support
* Nest the top-level hamcrest module into support
2018-07-22 08:46:44 +01:00
Dale Wijnand
7fe2fbc8a3
Remove the argument from the project test support function
By rewriting the tests, with rerast (https://github.com/google/rerast),
to use the newly introduced "at" method.

First I added the following temporary function to cargotest::support:

    pub fn project_foo() -> ProjectBuilder {
        project("foo")
    }

Then I defined the following rewrite.rs:

    use cargotest::support::{ project, project_foo };

    fn rule1(a: &'static str) {
        replace!(project("foo") => project_foo());
        replace!(project(a) => project_foo().at(a));
    }

Then I ran rerast:

    cargo +nightly rerast --rules_file=rewrite.rs --force --targets tests --file tests/testsuite/main.rs

Finally I searched and replaced the references to project_foo with
argument-less project (a little awkardly on macOS with a git clean).

    find tests -type f -exec sed -i -e 's/project_foo/project/g' {} +
    git clean -d tests
2018-07-20 13:31:50 +01:00