Commit graph

134 commits

Author SHA1 Message Date
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
Jeremy Banks 42424065f6 Add test to confirm that Cargo.toml.orig files are reserved. 2022-04-09 14:03:09 -04:00
Jon Gjengset 79cc65fa5a Add tests for ignoring symlinks 2022-03-22 16:21:39 -07:00
Ed Page 320c279f43 Port cargo from toml-rs to toml_edit
Benefits:
- A TOML 1.0 compliant parser
- Unblock future work
  - Have `cargo init` add the current crate to the workspace, rather
    than error
  - #5586: Upstream `cargo-add`
2022-01-13 09:27:27 -06:00
Weihang Lo d92dceaeba
Test IO error resilience while walking directories
Remove `build_script::build_script_scan_eacces`  test case because cargo
ignores it and returns its path during a `cargo build`. The caller still
has a chance to hit the IO error if they does access it.
2022-01-05 14:29:59 +08:00
Weihang Lo 6fa0f01d87
Test filesystem loop during traversal
Use unordered since order of warning differs on each platform.
2021-12-15 09:42:14 +08:00
Nipunn Koorapati b8b127a870 Support path_in_vcs as part of cargo_vcs_metadata 2021-09-26 13:37:56 -04:00
tcmal 8f1f0e40fd feat(package+publish): package arguments
adds -p, --workspace, and --exclude to package command,
and -p to publish command, as well as tests for both.

closes #7345
2021-07-26 16:31:58 +01:00
Eric Huss 97a135049a Handle git deleted files with dirty worktree. 2021-07-01 18:10:35 -07:00
Bryysen 4e1910d9d3 Error when packaging with git dependencies without version
If `cargo package` is run on a package that specifies a git dependency
without a version, cargo will error. This should help with clarifying
that git dependencies will be stripped when packaging, and that the
dependency has to be fetched from a registry.
2021-06-23 02:01:29 +02:00
Alex Crichton a02b6e5bfc Update tar dependency to 0.4.34
Pulls in a fix which should avoid 0 mtime files from showing up.

Closes #9512
2021-05-27 14:16:59 -07:00
Eric Huss a200640dbd Improve performance of git status check in cargo package. 2021-05-10 18:15:05 -07:00
Alex Crichton 6bc74556f9 Fix publication of packages with metadata and resolver
This commit fixes an issue where packages which specify `resolver = '2'`
cannot be packaged if they also have a `package.metadata` table. The
issue is that the `toml` serialization implementation serializes fields
in order which requires that tables be emitted last.
2021-03-25 09:13:40 -07:00
Eric Huss 340656e29d Add RegistryBuilder to help initializing test registries.
The intent here is to make it more flexible to create different registry
setups, and to reuse code a little more easily.
2021-02-02 15:48:48 -08:00
Mara Bos de839dabe3 Add support for Rust edition 2021. 2020-11-30 21:32:08 +01:00
brian m. carlson 449ead05db
package: canonicalize tar headers for crate packages
Currently, when reading a file from disk, we include several pieces of
data from the on-disk file, including the user and group names and IDs,
the device major and minor, the mode, and the timestamp.  This means
that our archives differ between systems, sometimes in unhelpful ways.

In addition, most users probably did not intend to share information
about their user and group settings, operating system and disk type, and
umask.  While these aren't huge privacy leaks, cargo doesn't use them
when extracting archives, so there's no value to including them.

Since using consistent data means that our archives are reproducible and
don't leak user data, both of which are desirable features, let's
canonicalize the header to strip out identifying information.

Omit the inclusion of the timestamp for generated files and tell the tar
crate to copy deterministic data.  That will omit all of the data we
don't care about and also canonicalize the mode properly.

Our tests don't check the specifics of certain fields because they
differ between the generated files and the files that are archived from
the disk format.  They are still canonicalized correctly for each type,
however.
2020-11-18 00:07:50 +00:00
brian m. carlson e46ca84b6c
package: canonicalize tar headers for crate packages
Currently, when reading a file from disk, we include several pieces of
data from the on-disk file, including the user and group names and IDs,
the device major and minor, the mode, and the timestamp.  This means
that our archives differ between systems, sometimes in unhelpful ways.

In addition, most users probably did not intend to share information
about their user and group settings, operating system and disk type, and
umask.  While these aren't huge privacy leaks, cargo doesn't use them
when extracting archives, so there's no value to including them.

Since using consistent data means that our archives are reproducible and
don't leak user data, both of which are desirable features, let's
canonicalize the header to strip out identifying information.

We set the user and group information to 0 and root, since that's the
only user that's typically consistent among Unix systems.  Setting
these values doesn't create a security risk since tar can't change the
ownership of files when it's running as a normal unprivileged user.

Similarly, we set the device major and minor to 0.  There is no useful
value here that's portable across systems, and it does not affect
extraction in any way.

We also set the timestamp to the same one that we use for generated
files.  This is probably the biggest loss of relevant data, but
considering that cargo doesn't otherwise use it and honoring it makes
the archives unreproducible, we canonicalize it as well.

Finally, we canonicalize the mode of an item we're storing by looking at
the executable bit and using mode 755 if it's set and mode 644 if it's
not.  We already use 644 as the default for generated files, and this is
the same algorithm that Git uses to determine whether a file should be
considered executable.  The tests don't test this case because there's
no portable way to create executable files on Windows.
2020-11-16 01:46:10 +00:00
Eric Huss 6f8c7d5a87 Normalize raw string indentation. 2020-09-26 17:59:58 -07:00
Matthias Krüger f23b91190c use sort_by_key() instead of comparing by keys manually
replace format!() macro by String::from()
use eprintln() instead of manually writing to std::io::stderr
2020-08-03 22:52:01 +02:00
Eric Huss 35758d2c92 Disable long_file_names test if not supported on Windows. 2020-07-08 16:57:40 -07:00
Martin Pool 0dfd4a88fd Add test for packaging long file names 2020-07-04 17:52:02 -07:00
Alex Crichton 6514c289d2 Improve git error messages a bit
This commit is targeted at further improving the error messages
generated from git errors. For authentication errors the actual URL
fetched is now printed out as well if it's different from the original
URL. This should help handle `insteadOf` logic where SSH urls are used
instead of HTTPS urls and users can know to track that down.

Otherwise the logic about recommending `net.git-fetch-with-cli` was
tweaked a bit and moved to the same location as the rest of our error
reporting.

Note that a change piggy-backed here as well is that `Caused by:` errors
are now automatically all tabbed over a bit instead of only having the
first line tabbed over. This required a good number of tests to be
updated, but it's just an updated in renderings.
2020-06-25 08:47:15 -07:00
Eric Huss 156c65123f Allow cargo package --list even for things that don't package. 2020-04-28 10:49:21 -07:00
Hanif Bin Ariffin 2c67111552 Added warning when using restricted names in Windows. 2020-04-26 06:13:08 -07:00
Eric Huss 1232ad3cde Don't require Cargo.toml to be in root of a git repo for path source walking. 2020-04-22 11:29:59 -07:00
Eric Huss 787e75b797 Add resolver opt-in for new feature resolver. 2020-04-19 08:45:18 -07:00
bors b04345c21b Auto merge of #8122 - kornelski:future-edition, r=Eh2406
Hint upgrading for future edition keys

A more specific error message for potentially-future edition values.

This error is likely to be seen by people who are not regular Rust users and are just trying to build someone's crate. It may be helpful to stronger hint at upgrading Cargo, rather than display a more general message about an unknown value.

I know Cargo plans to fix it better with explicit MSRV eventually, but that's not ready yet, so it's better to land something sooner.
2020-04-17 15:20:04 +00:00
Eric Huss 4ae79d2ffd Use fs helpers instead of File functions. 2020-04-17 07:56:16 -07:00
Kornel f57c4c9ba3 Hint upgrading for future edition keys 2020-04-17 15:23:59 +01:00
Eric Huss 2a874aa522 Warn when packaging files with Windows special names. 2020-03-02 16:14:36 -08:00
Matthias Krüger 1d912002e9 fix most remaining clippy findings (mostly redundant imports) 2020-02-21 12:15:16 +01:00
Eric Huss 90887707ed Copy license-file into package if outside of root. 2020-02-20 13:27:25 -08:00
Eric Huss ab33bc0c36 Add a warning if license-file points to a file that does not exist. 2020-02-20 13:27:00 -08:00
bors c8595e8897 Auto merge of #7680 - stefanhoelzl:issue-7183, r=ehuss
include dotfiles in packages

This PR solves #7183

It changes the behavior of `cargo package` to also include dotfiles by default.

It should be discussed if this is intended or if the implementation should be changed to only include dotfiles which are specified in the `include` section.

From the [existing comment](40885dfab4/src/cargo/sources/path.rs (L358)) it is a little bit unclear to me, but I supposed it was intended only to exclude directories starting with a dot?
2019-12-12 18:19:57 +00:00
Matthias Krüger 34f2d4710b fix a couple of typos 2019-12-11 15:31:26 +01:00
Stefan Hoelzl 5c5d1718e3 test variant to exclude dot-files/dirs by default 2019-12-08 16:03:17 +01:00
Stefan Hoelzl 7662c2d8bb added dotfile to include test
got rid of extra test for dotfiles
2019-12-08 12:10:13 +01:00
Stefan Hoelzl 60db94c056 fix format issues 2019-12-07 20:19:17 +01:00
Stefan Hoelzl 525e250be5 added testcase 2019-12-06 22:21:14 +01:00
Eric Huss 83571aee56 Minor testsuite organization. 2019-11-24 18:42:45 -08: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 3c20a24335 Clean up some git test support functions. 2019-08-12 22:25:36 -07:00
Thom Wiggers d0f7c0ee31
Cargo fmt 2019-07-30 10:02:05 +02:00
Thom Wiggers 55e5623368
Don't run symlink tests based on symlink_supported 2019-07-30 09:31:35 +02:00
Thom Wiggers 673bb69cf5
Ignore tests that need Administrator privileges on Windows.
This patch allows you to run them when wanted with ``--ignored`` on Windows.
2019-07-30 09:31:35 +02:00
Thom Wiggers 32130f8e58
enable the broken_symlink test on Windows 2019-07-30 09:31:35 +02:00
Thom Wiggers 50a24ff29b
Check if symlinks are directories
Fixes #2748.

Uses @ehuss's suggested fix.
See https://github.com/rust-lang/cargo/pull/6817#issuecomment-480538976
2019-07-30 09:31:35 +02:00
Thom Wiggers 77cfceea7d
Add tests for symlinks to git submodules or directories. 2019-07-30 09:31:32 +02:00
Eric Huss 24d2850247 Remove include/exclude glob warning. 2019-07-23 13:49:17 -07:00
Sekhat Temporus 69226ed887 improve uncommitted changes cargo-package message
fixes #7003

Explicitly state what the suggested flag `--allow-dirty`
actually does when packaging/publishing the crate. Primarily,
that the uncommited changes are included within the resulting
package.
2019-07-01 18:48:59 +01:00