82 Commits

Author SHA1 Message Date
Eric Huss
24b8936c20 Remove normalized_lines_match, it is not needed. 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
r00ster91
b381fdb71e Improve two error messages 2021-05-10 17:28:19 +02:00
Kornel
3f7f0942cd track_caller on custom assert functions 2021-03-03 17:17:07 +00:00
bors
b219f0eb7a Auto merge of #9181 - jyn514:computer-says-no, r=ehuss
Forbid setting `RUSTC_BOOTSTRAP` from a build script on stable

Instead, recommend `RUSTC_BOOTSTRAP=crate_name`. If cargo is using a nightly toolchain, or if RUSTC_BOOTSTRAP was set in *cargo*'s build environment, the error is downgraded to a warning, since the variable won't affect the build.

This is mostly the same as suggested in https://github.com/rust-lang/cargo/issues/7088#issuecomment-713867773, except that `RUSTC_BOOTSTRAP=` values other than 1 are treated the same as `RUSTC_BOOTSTRAP=1`. My reasoning was that https://github.com/rust-lang/rust/pull/77802 is now on 1.50 stable, so some crates may have started using it, and I would still prefer not to give hard errors when there's no workaround.

Closes https://github.com/rust-lang/cargo/issues/7088.

r? `@joshtriplett`
2021-03-03 03:19:33 +00:00
bors
f3e63d6ab4 Auto merge of #8939 - Andy-Python-Programmer:master, r=alexcrichton
Throw error if CARGO_TARGET_DIR is an empty string

This pull request makes the target dir to be target/ if `CARGO_TARGET_DIR` is `` with spaces trimmed and not delete the current project.

Fixes: #8866
2021-02-25 19:40:08 +00:00
unknown
b5b2e489d6 Fix tests 2021-02-25 18:48:05 +11:00
unknown
019b4e111e Fixes error message 2021-02-25 18:10:59 +11:00
Joshua Nelson
ecfdced0d8 Fix test that assumed tests always were run on the stable channel
Note that this has to be set in the builder, before
`config.configure()` gets run.
2021-02-24 15:11:34 -05:00
Joshua Nelson
a5720117fe Make nightly_features_allowed a field instead of a function
`nightly_features_allowed()` is no longer doing any work, so it can be
accessed directly. This also renames the `enable_nightly_features` field
to `nightly_features_allowed`.
2021-02-24 15:11:31 -05:00
Joshua Nelson
4b096beaed Fix masquerade_as_nightly_cargo in work threads
Previously, since `ENABLE_NIGHTLY_FEATURES` and
`NIGHTLY_FEATURES_ENABLED` were thread locals, reading them in any other
thread would always say nightly features were disabled. Now, they are
tied to the `Context` itself, so it is both more clear how the variables
are being set and fixes the behavior within work threads.

Note that `Context` is not thread-safe, so this passes a boolean through
to `BuildOutput::parse`.
2021-02-24 14:43:00 -05:00
unknown
97707a880e Add tests 2021-02-24 17:56:20 +11:00
Eric Huss
9cb8f41ec9 Prevent testsuite from loading config out of sandbox. 2021-02-10 17:39:38 -08:00
bors
0608fcd99d Allow true and false as options for strip option
This follows the convention of `lto` and `debug` that allow `true` for
the highest level, and `false` for disabled.

Signed-off-by: David Calavera <david.calavera@gmail.com>
2021-02-10 00:19:10 +00:00
unknown
7a69aafbf3 Add tests for target_dir; throw error if [build] target = '' and update messages 2021-01-23 18:18:28 +11:00
Eric Huss
ad34852f39 Update toml dependency 2020-10-12 11:22:45 -07:00
Eric Huss
6f8c7d5a87 Normalize raw string indentation. 2020-09-26 17:59:58 -07:00
Alex Berghage
d035daae4e Fix tests for handling env key overlaps / errors 2020-07-09 13:12:34 -06:00
Alex Berghage
e49b3aed79 Add tests verifying overlapping prefixes and defaults
These tests demonstrate the current failure mode around
overlapping env keys and inner structs. To some extent this
is a limitation of mapping on to environment variables with
an underscore as both the namespace separator and the
substitute for dashes in flag names in that the mapping is
not strictly one-to-one.
2020-07-09 12:53:42 -06:00
Alex Berghage
724273ed25 Minor test fix (error text comparison)
Serde's errors for missing fields are a lil' different than
the ones from our Deserializer.
2020-07-08 21:22:44 -06:00
Alex Berghage
08f1020f48 Drop broken test asserting invalid configs error on nightly
The current behavior, with the default-false workaround in place,
is not able to identify extra members of the `unstable` table, so
it can't error on unexpected members.

I'll add this test back in with a Deserializer refactor to clean up
the extra logic added to CliUnstable.
2020-07-07 23:38:26 -06:00
Alexander Berghage
bd938f077d Switch unstable config parsing to serde
Tests are currently failing, looks like there's something in the
Deserializer impl that's forcing field-missing errors even when
the serde `default` annotation is applied.
2020-07-07 23:38:26 -06:00
Alex Berghage
4aede8c784 Allow setting unstable options in .cargo/config
Obviously this only works with nightlies and all
that, but if you're e.g. testing resolver v2, want
to always have Ztiming on in your workspace, or
something like that, this makes it easier to do.
2020-07-07 23:38:26 -06:00
Gabriel Majeri
65fc4cec8d Implement enum config options deserialization 2020-07-06 22:12:15 +03:00
Gabriel Majeri
4c7be8d4fb Add a test reproducing the issue 2020-07-05 10:04:24 +03:00
est31
7f73a6c782 Move string interning to util
Code that handles string interning is rather an util functionality than
a core functionality.
2020-06-26 19:55:29 +02:00
Jan-Erik Rediger
09084a365f Expand error message to explain that a string was found
With `opt-level = "3"` this previously said:

    must be an integer, `z`, or `s`, but found: 3 for ...

The error message doesn't make that super clear.
This should now be a bit more clear.

Fixes #8234
2020-05-12 21:41:03 +02:00
Eric Huss
fd258634c9 Improvements to StringList config handling. 2020-02-16 15:29:59 -08:00
Eric Huss
0279e8e63a Fix using global options before an alias. 2020-01-31 13:56:06 -08:00
Eric Huss
77ee608de3 Add named config profiles. 2020-01-13 13:27:33 -08:00
Alex Crichton
d7b45f9992 Use context to create a chain of errors
There's an existing bug (#7782) in Cargo which exacerbates the issue
here but in general having a stack of errors is a bit easier to read and
work with than having a big long error message.
2020-01-09 10:29:22 -08:00
Alex Crichton
3a18c89a55 Migrate from the failure crate to anyhow
The `anyhow` crate interoperates with the `std::error::Error` trait
rather than a custom `Fail` trait, and this is the general trend of
error handling in Rust as well.

Note that this is mostly mechanical (sed) and intended to get the test
suite passing. As usual there's still more idiomatic cleanup that can
happen, but that's left to later commits.
2020-01-07 16:50:09 -08:00
Eric Huss
829ddf0dc8 Fix config env vars that are prefix of another with underscore. 2019-12-23 18:13:50 -08:00
Eric Huss
e7eda2f91f Implement config-include. 2019-12-19 09:44:02 -08:00
Eric Huss
91015d52ce Add --config CLI option. 2019-12-19 09:44:02 -08:00
Eric Huss
2e5796d4e8 Store Definition in ConfigValue. 2019-12-19 09:44:02 -08:00
Eric Huss
6d95721ec5 Add a ConfigBuilder for tests. 2019-12-19 09:44:01 -08:00
Eric Huss
381251aa1f Config refactoring. 2019-12-19 09:44:01 -08:00
Eric Huss
83571aee56 Minor testsuite organization. 2019-11-24 18:42:45 -08:00
Eric Huss
fcfe0b8988 Rename overrides to package in profiles. 2019-10-10 14:39:30 -07:00
Alex Crichton
d7d8ca1e12 Consolidate build key configuration
Add a typed structure which lists all `build` key configuration
throughout Cargo.
2019-10-07 17:12:03 -07:00
Alex Crichton
37ace8886a Finish implementing Value, use it in helpers
Rewrite helpers like `get_bool` to use `get::<Option<Value<bool>>>`
instead of duplicating the logic that's already with the typed access of
configuration. This is more along the effort to centralize all
deserialization of configuration into typed values instead of using
ad-hoc accessors in a number of locations.
2019-10-07 17:12:03 -07:00
Alex Crichton
c0baf844e3 Refactor ConfigKey to its own file
Also make it a little less allocation-heavy by tweaking the API to
encourage incremental building of the key and incremental destruction as
we walk throughout the configuration tree.
2019-10-07 17:12:03 -07:00
bors
8b0561d68f Auto merge of #6989 - da-x:custom-profile-pr-rfc, r=ehuss
Support for named profiles (RFC 2678)

Tracking issue: https://github.com/rust-lang/cargo/issues/6988

Implementation according to the [RFC](https://github.com/rust-lang/rfcs/blob/master/text/2678-named-custom-cargo-profiles.md).
2019-09-30 19:51:19 +00:00
Guanqun Lu
852cf05365 add a bit more docs 2019-10-01 00:06:34 +08:00
Guanqun Lu
a4e3b81a55 run cargo fmt to pass the CI build 2019-09-30 23:48:08 +08:00
Guanqun Lu
ba1f16a7a4 fixes 2019-09-30 00:32:57 +08:00
Guanqun Lu
0e5d378e04 modify to enum/struct and add test for SslVersionConfig 2019-09-30 00:29:15 +08:00
Dan Aloni
375a46f18b Merge remote-tracking branch 'origin/master' into custom-profile-pr-rfc 2019-09-18 08:56:13 +03:00
Alex Crichton
ebd10526f3 Run rustfmt 2019-09-16 12:00:12 -07:00