Commit Graph

87 Commits

Author SHA1 Message Date
Eric Huss 4cb9ac35bf Add network container tests 2023-01-14 15:10:16 -08:00
Jon Gjengset 724a1977ce Make cargo forward pre-existing CARGO if set
Currently, Cargo will always set `$CARGO` to point to what it detects
its own path to be (using `std::env::current_exe`). Unfortunately, this
runs into trouble when Cargo is used as a library, or when `current_exe`
is not actually the binary itself (e.g., when invoked through Valgrind
or `ld.so`), since `$CARGO` will not point at something that can be used
as `cargo`. This, in turn, means that users can't currently rely on
`$CARGO` to do the right thing, and will sometimes have to invoke
`cargo` directly from `$PATH` instead, which may not reflect the `cargo`
that's currently in use.

This patch makes Cargo re-use the existing value of `$CARGO` if it's
already set in the environment. For Cargo subcommands, this will mean
that the initial invocation of `cargo` in `cargo foo` will set `$CARGO`,
and then Cargo-as-a-library inside of `cargo-foo` will inherit that
(correct) value instead of overwriting it with the incorrect value
`cargo-foo`. For other execution environments that do not have `cargo`
in their call stack, it gives them the opportunity to set a working
value for `$CARGO`.

One note about the implementation of this is that the test suite now
needs to override `$CARGO` explicitly so that the _user's_ `$CARGO` does
not interfere with the contents of the tests. It _could_ remove `$CARGO`
instead, but overriding it seemed less error-prone.

Fixes #10119.
Fixes #10113.
2022-10-25 13:51:27 -07:00
Arlo Siemsen dd5134c7a5 Implement RFC 3289: source replacement ambiguity 2022-10-07 22:30:59 -05:00
Wim Looman 61c4b11eae
Ensure rustc-echo-wrapper works with an overridden build.target-dir 2022-08-10 17:37:40 +02:00
Eric Huss 1c3640e05c Add requirements to cargo_test. 2022-07-30 19:36:58 -07:00
Scott Schafer c239e407e7 add a reason to `masquerade_as_nightly_cargo` so it is searchable 2022-07-15 21:32:23 -05:00
Ed Page cbd4edb266 refactor(test): Clarify asserts are for UI
In writing the contrib documentation for functional vs ui tests, I
realized that as we work to make snapbox work for the functional tests,
we'll need distinct `Assert` objects since we'll want to elide a lot
more content in functional tests.  I'm making room for this by
qualifying the existing asserts as being for "ui".
2022-06-21 14:59:54 -05:00
Arlo Siemsen 24dac452c5 Improve testing framework for http registries
Improve integration of the http server introduced by the http-registry feature.
Now the same HTTP server is used for serving downloads, the index, and
the API.

This makes it easier to write tests that deal with authentication and
http registries.
2022-06-10 16:51:35 -05:00
Ed Page dde4a1c381 test: Make curr_dir work in/out of workspace
When running tests in the `rust-lang/cargo` repo, `file!` is relative to
the crate root and tests are run relative to the crate root and
everything is fine.

When running tests in the `rust-lang/rust` repo, `file!` is relative to
the workspace root and tests are run relative to the crate root and
there is much sadness.

If we are compiling relative to the crate root, we could make the path
absolute and everything would be dandy but this needs to happen at
compile time.  Didn't see a way to do this.

We could stop using `curr_dir` but that makes the tests a bit noisier
with more overhead for creating a new tests from an existing case.

Since we can reasonly know what all roots will be used for `file!`, we
can just hard code-in support for those two roots.  Much happiness
ensues as everything works with this surgical hack.
2022-05-12 03:28:27 -05:00
Scott Schafer 92fbc4e344 move all `snapshot/cargo_add/` tests to `testsuite/cargo_add/` 2022-05-06 20:51:29 -05:00
Ed Page d6e912ca32 feat(test-support): Make multi-argument strings avaialble to snapbox
This is something the existing test infrastructure supports, so I
figured I'd make it mirror it for snapbox.  I'm mixed.
- It reads more like what a user would type, making it easier to run a
  test locally or take a manual test case and automate it
- It can make it harder to parse the arguments when scanning tests
- Without using a crate like `shlex`, the syntax support is unclear
2022-04-27 20:57:19 -05:00
Ed Page 83d444040c feat(test-support): Make it easy to launch cargo 2022-04-27 20:57:17 -05:00
Ed Page 9a3d99b6c5 fix(test-support): Default the current_dir for snapbox 2022-04-27 20:57:03 -05:00
Ed Page c9e82ec197 feat(test-support): Expose test-env setup 2022-04-27 20:57:03 -05:00
Ed Page 79ef00c60b feat(test-support): Expose `masquerade_as_nightly_cargo` to snapbox users 2022-04-27 20:56:20 -05:00
Ed Page 0d135a0b43 feat(test-support): Share `Project::from_template` with all cargo tests
This was written for `cargo_add.rs`, based on `snapbox`.  This allows
creating a test from a known reproduction case or easily debugging on an
existing test case.
2022-04-27 20:53:25 -05:00
Ed Page 5eaec4fa2f refactor(test-support): Use snapbox to look up binaries 2022-04-27 20:45:36 -05:00
Lucas Kent fab44ff971 Remove warn(clippy::*) 2022-03-09 10:33:39 +11:00
Sean Stangl 4c66d18361 fix panic if an alias is defined to "" 2021-12-12 13:30:31 -07:00
Russ Weas effc72042b Implement glob escaping for clean -p
Implement glob escaping for clean -p

Add pattern escape for glob matching cargo clean files

Implement correct solution for #10068

Removed superfluous formatting changes

Update rm_rf_glob()'s error handling

Remove dir_glob reference for non-glob function

Added test

Satisfy clippy

Add MSVC support for test
2021-11-16 16:55:23 -06:00
Alex Crichton cab1e3566b Fix CI testing 2021-10-22 13:30:46 -07:00
Nipunn Koorapati dde290e6ff Refactor fake_file() away from cargo_command tests
There are already similar preexisting test helpers which
also work on windows. Port over the executable-creation
helper into the file() helper and things appear to pass.
2021-08-05 19:09:58 -07:00
Eric Huss b67454c660 Make it easier to run testsuite with a custom toolchain. 2021-07-11 14:02:47 -07:00
Eric Huss 28c3bef71a Include the linker in the fingerprint. 2021-07-01 20:33:48 -07:00
Eric Huss 16b5402fd7 testsuite: Switch to colored diffs with Myers diff. 2021-06-16 15:43:29 -07:00
Eric Huss 6dff99781d Remove with_either_contains.
It isn't needed anymore, and I would prefer to not keep around unused code.
It can always be added back if ever needed again.
2021-06-16 09:44:29 -07:00
Eric Huss e132bb53ab Move comparison and diffing code to a new module.
This includes various minor refactorings to try to clean things up
and provide better error messages.
2021-06-16 09:44:29 -07:00
Eric Huss 0f5deb64f9 testsuite: Support anyhow error chains in error messages.
This is intended to help with adding more usage of anyhow in the
testsuite, which can help show context for errors.

This also includes some small improvements to the error messages to
provide more information.
2021-06-16 09:44:28 -07:00
Eric Huss 2021865d88 Remove some unused code. 2021-06-15 15:38:02 -07:00
Eric Huss 393077f968 Add `run_json` to `Execs`.
This is a helper to run the process and return a JSON object.
2021-06-11 16:07:20 -07:00
Eric Huss 3be34cb834 Remove "Expected: execs" from testsuite error.
That message was not helpful.
2021-06-11 15:25:50 -07:00
Eric Huss 0f304ca450 Fix verify_checks_output.
This was accidentally broken in
cc5e9df64a
causing it to not check in the error case (which is the only case that mattered).
2021-06-11 13:12:30 -07:00
Eric Huss 5d1b0f9c43 Switch cargo-test-support to anyhow. 2021-06-11 12:37:27 -07:00
Eric Huss 7b229bbe39 Move the rustc-echo-wrapper to be shared across tests.
This helps avoid rebuilding the same project several times.
2021-06-09 17:13:33 -07:00
Eric Huss 10eb56f2c4 Update clippy lint allow set. 2021-04-13 09:02:07 -07:00
bors 7204d3989d Auto merge of #9302 - ehuss:cargo-config, r=alexcrichton
Add `cargo config` subcommand.

This adds an initial version of the `cargo config` command as discussed in #2362.

Closes #2362
2021-03-30 19:07:19 +00:00
Alex Crichton a4f0988ef8 Default macOS targets to `unpacked` debuginfo
This commit continues the work from #9112 to enable `unpacked` split
debuginfo on macOS targets by default. This has been discussed on [internals]
for awhile now and no breakage has emerged while significant speedups
have. This is expected to be a compile-time and `target`-directory size
win for almost all macOS Rust projects.

While breakage is possible it's possible to mitigate this with
project-local or global cargo configuration of the `dev` and `test` profiles.

[internals]: https://internals.rust-lang.org/t/help-test-faster-incremental-debug-macos-builds-on-nightly/14016/9
2021-03-26 07:38:17 -07:00
Eric Huss 96a5642217 Add `cargo config` subcommand. 2021-03-25 13:52:31 -07:00
Eric Huss 0ad3fb1b57 Remove CargoResult from cargo-test-support. 2021-03-20 17:42:41 -07:00
Eric Huss 10224938bf Remove use of Rustc from cargo-test-support.
cargo-test-support wasn't using any of the caching or other logic from
Rustc, so this just swaps with a very basic implementation in order to
remove the dependency on `cargo`.
2021-03-20 17:42:41 -07:00
Eric Huss dbfdd49559 Move is_ci to cargo-util. 2021-03-20 17:42:32 -07:00
Eric Huss 888100352a Move ProcessBuilder to cargo-util. 2021-03-20 15:19:03 -07:00
Kornel 3f7f0942cd track_caller on custom assert functions 2021-03-03 17:17:07 +00:00
bors 6780fbd22a Auto merge of #9207 - ehuss:testsuite-splitdebug, r=Eh2406
testsuite: Use split debuginfo on macos.

This switches the testsuite to use "unpacked" debuginfo on macos, which is a substantial performance boost. On my system, the testsuite runs 1.55 times faster with this change.  Along with #9206, total testsuite time is 3.1 times faster.
2021-02-25 19:06:49 +00:00
Eric Huss c73765f9c3 testsuite: Improve performance when using rustup. 2021-02-25 09:07:48 -08:00
Eric Huss 0f78dbd38e testsuite: Use split debuginfo on macos. 2021-02-25 09:06:11 -08:00
Eric Huss 3f2f7e30ff Add a migrating message for `cargo fix --edition`.
This helps indicate which edition you are moving from and to.
2021-02-17 21:36:28 -08:00
Eric Huss 820537c706 Change Fixing to Fixed, and add a verbose "Fixing".
What was previously "Fixing" was a message for after the fixes had
been applied. I think it would be clearer if it said "Fixed",
to indicate that the fixes had actually finished.

The new "Fixing" is posted just before it starts. This is verbose-only
since it is a little noisy.
2021-02-17 20:41:38 -08:00
Alex Crichton cc5e9df64a Cache failures in the rustc info cache
This commit updates the rustc info cache to cache failures to execute
rustc as well as successes. This fixes a weird issue where if you're
probing for flags the `rustc_info_cache` test fails on channels which
don't have the flag since previously a failure to execute rustc resulted
in never caching the result.
2021-02-01 11:29:25 -08:00
Alex Crichton ed4568e108 Add split-debuginfo profile option
This commit adds a new `split-debuginfo` option to Cargo compilation
profiles which gets forwarded to the `-Csplit-debuginfo` codegen option
in rustc. This commit also sets the default, only on macOS, to be
`-Csplit-debuginfo=unpacked`. The purpose of this change is to leverage
rust-lang/rust#79570 to avoid running `dsymutil` on incremental builds
while also preserving a pleasant debugging experience by default. This
should lead to much faster incremental build times on macOS since
`dsymutil` isn't exactly the speediest tool in the world.

This is technically a breaking change in Cargo because we're no longer
by-default producing the `*.dSYM` folders on macOS. If those are still
desired, however, authors can always run `dsymutil` themselves or
otherwise configure `split-debuginfo = 'packed'` in their
manifest/profile configuration.
2021-02-01 09:21:36 -08:00