Commit graph

165 commits

Author SHA1 Message Date
Dale Wijnand 37df042ba8
Test cleanup: remove unnecessary with_status(0) 2019-02-04 18:52:33 +01:00
Jonathan Claudius 0c3851c017
HTTPS all the things 2019-01-30 15:34:37 -05:00
nasa db09895f3c $cargo fmt --all 2019-01-27 22:39:49 +09:00
Eric Huss b5144c7f83 Add test for publish with [patch] + cleanup. 2019-01-11 19:14:58 -08:00
bors c9fa7db4d4 Auto merge of #6453 - spacekookie:publish-featured, r=alexcrichton
Adding feature-flags to `cargo publish` and `cargo package`

This change adds the `--features` and `--all-features` flags to the
above mentioned commands. This is to allow publishing of crates that
have certain feature requirements for compilation, without having to
rely on `--no-verify` which isn't good practise.

This PR adds two new fields `features` and `all_features` to both the
`PackageOpts` and `PublishOpts` and also adds the argument options
to the CLI commands.

Merging this feature will allow people to publish crates on crates.io
that require some feature flag to compile (or all?) without needing
to rely on not checking the package before uploading, potentially
resulting in less packaging errors and broken packages.
2019-01-10 18:37:22 +00:00
Katharina Fey b29e37968a
Adding support for no-default-features to package and publish 2019-01-09 18:30:54 +01:00
Eric Huss 3d84d0ad77 Add dependency registry to cargo metadata.
This adds the `registry` field for dependencies for alternate registries in
`cargo metadata`.
2018-12-29 21:14:25 -08:00
Katharina Fey 40cca8058d
Undoing bad formatting changes and removing redundant struct fields 2018-12-29 18:18:50 +01:00
Katharina Fey 142bafb7e6
Adding feature tests to publish and package 2018-12-29 11:45:05 +01: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
Ximin Luo dd998a096b Fix package::include/exclude tests so they work even if running them not in cargo.git 2018-11-04 08:59:20 -08:00
Guillaume Gomez 2fc6b3e338 revert b1d6a7e changes 2018-09-14 23:19:00 +02:00
Zach Lute b020d3789a Resolve merge conflicts with test string changes. 2018-09-09 16:48:57 -07: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
bors 56ee6204de Auto merge of #5984 - alexcrichton:stabilize-edition, r=ehuss
Stabilize `edition` key and add `cargo new --edition`

This commit stabilizes the `edition` key in `Cargo.toml`, both in the
`[package]` section and inside subtargets. Additionally the `cargo new` and
`cargo init` subcommands have been enhanced with a `--edition` flag to allow
explicitly specifying the edition to be generated.

This commit does not yet change the default edition that's generated.

Closes #5980
2018-09-06 22:17:24 +00:00
Alex Crichton 3d0290398a Stabilize edition key and add cargo new --edition
This commit stabilizes the `edition` key in `Cargo.toml`, both in the
`[package]` section and inside subtargets. Additionally the `cargo new` and
`cargo init` subcommands have been enhanced with a `--edition` flag to allow
explicitly specifying the edition to be generated.

This commit does not yet change the default edition that's generated.

Closes #5980
2018-09-06 11:28:10 -07:00
Dale Wijnand 7bda434a57
support::git::Repository doesn't support .cargo (yet?) 2018-09-06 07:33:24 +01:00
Dale Wijnand 4415c72828
Remove/reworksome redundant .cwd(p.root()) in tests 2018-09-06 01:12:53 +01: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 570fe8927d
Remove hamcrest existing_file() 2018-08-29 10:26:12 +02:00
Dale Wijnand a5de2c0ce7
Remove hamcrest contains() 2018-08-29 07:42:03 +02:00
Dale Wijnand 85984a8700
Migrate from tests fom assert_that/execs to .run() 2018-08-28 15:08:12 +02:00
Dale Wijnand b5ee3635ef
Wrap ProcessBuilder in Execs & make .cargo return that 2018-08-28 09:24:37 +01:00
bors 0ec7281b9c Auto merge of #5886 - dekellum:record-package-git-head-3, r=alexcrichton
Generate .cargo_vcs_info.json and include in `cargo package` (take 2)

Implements #5629 and supersedes #5786, with the following improvements:

* With an upstream git2-rs fix (tracked #5823, validated and min version update in: #5858), no longer requires windows/unix split tests.

* Per review in #5786, drops file system output and locks for .cargo_vcs_info.json.

* Now uses serde `json!` macro for json production with appropriate escaping.

* Now includes a test of the output json format.

Possible followup:

* Per discussion in #5786, we could improve reliability of both the VCS dirty check and the git head sha1 recording by preferring (and/or warning otherwise) the local repository bytes of each source file, at the same head commit. This makes the process more appropriately like an atomic snapshot, with no sentry file or other locking required.  However given my lack of a window's license and dev setup, as exhibited by troubles of #5823, this feel intuitively like too much to attempt to change in one iteration here.  I accept the "best effort" concept of this feature as suggested in #5786, and think it acceptable progress if merged in this form.

@alexcrichton r?
@joshtriplett cc
2018-08-20 21:18:45 +00:00
bors cc88d01166 Auto merge of #5908 - orium:fix-package-cargo-toml, r=alexcrichton
Fix serialization bug in `edition` field of `TomlProject`.

Fixes #5906.
2018-08-19 17:40:22 +00:00
Diogo Sousa 8590a5fba4 Fix serialization bug in edition field of TomlProject.
Fixes #5906.
2018-08-18 23:24:47 +01:00
Dale Wijnand 0152f26405
Move .env/.masquerade_as_nightly_cargo to collapse some more p.cargo calls 2018-08-18 21:34:09 +01: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
David Kellum ab7877205f Add test package::vcs_file_collision 2018-08-13 10:00:30 -07:00
David Kellum 6b9961a382 Add generated .cargo_vcs_info.json (git hash) file to cargo package 2018-08-13 10:00:30 -07: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
bors 0e7a46e327 Auto merge of #5858 - dekellum:git-check-logging-and-test, r=alexcrichton
Improve verbose console and log for finding git repo in package check

Third attempt to resolve #5823 by improving logging and tests. This exposes the issue to testing,  via verbose console output and is dependent on alexcrichton/git2-rs#341 as just released in git2 0.7.5 crate. Thus tests *should* now pass on all platforms, incl. windows, but I also intend to bump the minimal git2 release dependency (in a subsequently added commit).

cc: @Eh2406 thanks for your fix and help!
2018-08-07 22:19:54 +00:00
Dale Wijnand b1d6a7e11d
Drop niche Execs::with_no_expected_status
.. by gating the nightly-only tests.
2018-08-03 07:54:07 +01:00
Dale Wijnand 60828dba83
Fix tests that have no stable expected exit code 2018-08-03 07:45:21 +01:00
Dale Wijnand 16aeb0cd4f
Default test support's Execs to exit code 0 2018-08-03 07:44:42 +01:00
David Kellum 5b2f734873 Merge branch 'master' into git-check-logging-and-test 2018-08-02 15:42:50 -07:00
David Kellum 972763a8ee Improve verbose console and logging for finding git repo in package check 2018-08-02 15:21:04 -07:00
bors 5badfb1acb Auto merge of #5854 - dwijnand:args-split_whitespace, r=alexcrichton
Cleanup tests by using single string commands, split on whitespaces

Refs #5742
2018-08-02 22:12:33 +00:00
Dale Wijnand 8940d30668
Make cargo_process take a string it splits on whitespace 2018-08-02 18:00:02 +01:00
Dale Wijnand 05400b8018
Drop the [/] test output macro 2018-08-02 10:18:48 +01:00
Dale Wijnand 6ca32be8a2
Declare one-line write_all contents on one line, too 2018-07-25 10:00:45 +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 252f6e8e9f
Opt-out all other failing tests
Looks like cargo traverses the filesystem & fails if it runs into a
Cargo.toml that doesn't declare a target.  I couldn't find a nice way to
re-engineer the test to avoid this issue.  So I'll leave that as someone
else's exercise.
2018-07-24 13:59:42 +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
Eric Huss f41ee8908a Fix flakey test on MacOS.
`do_not_package_if_src_was_modified` can fail if the test runs too quickly
due to mac's filesystem time resolution.
2018-07-21 17:27:34 -07:00
Dale Wijnand f8c9928cc1
Rework some test projects to use the "foo" default
Generally that means either switching "foo" and "bar" around (reversing
the arrow), or it means push "foo" to "bar" (and sometimes "bar" to
"baz", etc..) to free up "foo".

For trivia that leaves 80/1222 outliers, therefore 93.4% of test
project use the default. :)
2018-07-21 19:40:45 +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
Gabriel Féron 987ce8751f Fix test to work on Windows 2018-05-29 11:38:27 +02:00
Gabriel Féron 53480ac7c7 Add more instructions to error message 2018-05-29 11:05:34 +02:00
Gabriel Féron e31f3c3ca9 Use auto split argument in test 2018-05-28 14:43:51 +02:00
Gabriel Féron ba48ff4273 Add cargo --no-verify test when checking that src dir was not modified while publishing 2018-05-28 13:59:40 +02:00
Eric Huss 3dbae343ac Fix passing --edition to rustdoc during doctests.
Fixes #5538
2018-05-15 09:29:34 -07:00
Alex Crichton 8413008937 Rename the rust manifest key to edition
This'll hopefully jive better with the terminology of "edition" throughout the
rest of Rust!
2018-05-03 11:45:04 -07:00
Kurtis Nusbaum 0b2aaaffe9 switch to using the --edition flag 2018-04-22 12:14:21 -07:00
Dale Wijnand 6828380e56
Move edition earlier in TomlManifest::to_real_manifest
and fix a typo in the error message
2018-04-20 19:45:59 +01:00
Kurtis Nusbaum 3bbe93cef6 rename epoch to edition 2018-04-01 11:01:28 -07:00
Alex Crichton 1e6828485e cargo fmt 2018-03-14 17:48:23 -07:00
Alex Crichton 2a063798eb Drop outdated hamcrest dependency
This hasn't been updated in awhile and in general we've been barely using it.
This drops the outdated dependency and vendors a small amount of the
functionality that it provided. I think eventually we'll want to transition away
from this method of assertions but I wanted to get this piece in to avoid too
much churn in one commit.
2018-03-01 11:03:54 -08:00
Alex Crichton a4a3302d46 Package lock files in published crates
Previously we had logic to explicitly skip lock files but there's actually a
good case to read these from crates.io (#2263) so let's do so!

Closes #2263
2018-02-28 13:57:16 -08:00
André Rocha c2ff988c9f Reorganize integration tests as one crate with many modules. Issue #4867. 2018-02-21 13:33:51 -05:00
Renamed from tests/package.rs (Browse further)