198 Commits

Author SHA1 Message Date
Ed Page
3a615ca9c8 feat(test): Add CargoPathExt to prelude 2024-07-18 15:22:29 -05:00
Ed Page
5b9799c6f4 refactor: Migrate from extern crate to test-support prelude
We now include the prelude in so many places, this simplifies how we can
present how `cargo-test-support` works.

Yes, this included some `use` clean ups but its already painful enough
walking through every test file, I didn't want to do it twice.
2024-07-12 15:57:00 -05:00
eth3lbert
5efed1bfdf
test: migrate package to snapbox 2024-06-27 12:55:34 +08:00
Tor Hovland
e7bfed103c Skip serializing the dirty flag if false. 2024-06-24 13:02:25 +02:00
Tor Hovland
1b636855a9 Add a dirty flag to the vcs_info file. 2024-06-24 13:02:25 +02:00
Tor Hovland
2a1299a878 fix: Include vcs_info even if workspace is dirty. 2024-06-24 13:02:25 +02:00
Tor Hovland
a6ad3a3ed5 test: Verify that the vcs_info file is not included in package when allowing dirty. 2024-06-24 13:02:25 +02:00
Joe Neeman
c0287bec8d Change verification order during packaging.
Once we support packaging workspaces with dependencies, dependency
packages need to be built before anything is verified. In addition to a
little refactoring, this commit reorders the console messages so that
package metadata (archive size, etc.) is reported before verification
results.

Co-Authored-By: Tor Hovland <55164+torhovland@users.noreply.github.com>
2024-06-14 15:15:03 -05:00
Ed Page
dc5ac62cab fix(test): Deprecate non-snapbox assertions
While this is noisy and hides other deprecations, I figured deprecations would
make it easier for people to discover what tasks remain and allow us to
divide and conquer this work rather than doing a heroic PR.
In theory, this will be short lived and we'll go back to seeing
deprecations in our tests.
2024-06-10 10:20:52 -05:00
bors
ab85225804 Auto merge of #13921 - heisen-li:licence_readme_warning, r=weihanglo
fix(toml): Convert warnings that `licence` and `readme` files do not exist into errors

### What does this PR try to resolve?

In this PR:
- Changed the warning to a hard error and modified the associated test function;
- Removed what should have been a redundant test function:`publish::publish_with_missing_readme`;
- Since `cargo publish` is preceded by the execution of `cargo package`, the error message in the test `function bad_license_file` needs to be modified.

issue: https://github.com/rust-lang/cargo/issues/13629#license-file-and-readme-pointing-to-a-non-existent-file.

### Additional information

It seems that this is not enough, the current situation is that `cargo package` warns if `package.readme` is an empty string or the wrong file location, but if I cancel `package.readme`, no warning is generated.

I'm wondering if I should judge `package.readme&licence` when executing `cargo package` and return an error if it doesn't exist?

As this has not been done before, your advice is sought.
2024-06-09 13:02:50 +00:00
heisen-li
193319c66c fix(toml): Convert warnings that license and readme files do not exist into errors 2024-06-04 12:32:18 +08:00
Ed Page
150461cdec fix(vendor): Ensure sort happens for vendor 2024-06-03 10:34:41 -05:00
Ed Page
81b1bb1580 test(package): Ensure order is consistent 2024-06-03 09:10:05 -05:00
Ed Page
06a57142f1 fix(toml): Warn, rather than fail publish, if targets are excluded
This could offer performance gains when parsing a published
manifest since the targets don't need to be discovered.
To see this, we'd first need to stop discovering potential targets even when it isn't
needed.
2024-04-29 12:25:56 -05:00
Ed Page
1e6047763d fix(toml): Warn, rather than fail publish, if build.rs is excluded
This could offer a minor performance gain when reading this manifest
since the target doesn't need to be discovered.
2024-04-29 12:25:19 -05:00
Ed Page
39f1a210b8 perf(toml): Avoid looking up readme on published packages
Not much of a performance gain;
this is mostly done to be consistent with the target work.
2024-04-29 12:25:19 -05:00
Ed Page
0cf29c5713 test(package): Show different crate discovery cases
I left off the explicit `path` cases because I hope that will become
moot
2024-04-29 12:25:19 -05:00
Ed Page
340050e0cb test(package): Show current case behavior 2024-04-29 12:25:19 -05:00
bors
7ac5d58f36 Auto merge of #13735 - linyihai:package-no-match, r=epage
`cargo package -p no-exist` emitt  error when the -p `package` not found

### What does this PR try to resolve?

Fixes #13719

If `-p` is used, and the spec doesn't match any member, we emit an error  like `cargo publish -p` does.

### How should we test and review this PR?

The first commit add a test to show the issue, the next commit add the check logic to fix it.

### Additional information
2024-04-12 16:27:02 +00:00
Lin Yihai
decbadb36f fix: cargo package -p includes all packages if no match is found 2024-04-12 10:57:58 +08:00
Lin Yihai
ac7bf6eb19 test(package): cargo package -p doesnt-exist will package all packages in workspace 2024-04-12 10:57:35 +08:00
Ed Page
8b593e5ba7 fix(package): Normalize path separators
A windows user could use `\` and no Linux or Mac user could use the
package.
This normalizes the separator to what works on all platforms.
2024-04-09 21:29:08 -05:00
Ed Page
5539293cf6 fix(package): Normalize paths in published Cargo.toml
For now, this is more for visual consistency.
However, this blocks #13713 as we need to be able to make these paths
comparable to what is included in the package.
2024-04-09 20:57:25 -05:00
Ed Page
4eea907733 test(package): Show behavior with backslashes 2024-04-09 13:44:25 -05:00
Ed Page
71e362fb17 test(package): Clean up a build.rs test 2024-04-05 13:12:41 -05:00
Arlo Siemsen
312e2aab7f Use strip_path_canonical for getting the relative path
This resolve an issue where the package path contains a symlink that's resolved by git
2024-04-03 12:59:49 -05:00
Arlo Siemsen
45c390a2a5 Switch to using gitoxide by default for listing files 2024-04-03 12:05:26 -05:00
Ed Page
cad9673785 refactor(package): Move preamble to Manifest 2024-03-28 13:29:24 -05:00
Sebastian Thiel
a710d459af
assure repositories are always walked into to avoid .git folders.
With a traditional walk, `.git` will be picked up, and so will be
ignored directories. This commit also doesn't give submodules special
treatment - instead it just tries to open directories as repositories,
or walks them if that fails.
2024-03-18 10:07:04 +01:00
Sebastian Thiel
9115545053
implement list_files_gix to be used when gitoxide is enabled. 2024-03-18 10:06:13 +01:00
Lin Yihai
cf45a5c186 test: Add test for packaging a public dependency 2024-03-01 20:19:41 +08:00
Ed Page
14646e6af6 test: Make edition explicit on packages 2024-02-22 11:37:03 -06:00
Ed Page
e7e8d8748a fix(compiler): Clarify we're showing a profile name 2024-02-08 14:01:39 -06:00
Lin Yihai
75aaa40c78 Remove the unnecessary backticks 2023-11-22 11:09:55 +08:00
Lin Yihai
edfbcf0a6c Return a hard error when custom build outside package 2023-11-21 11:10:46 +08:00
Lin Yihai
92ce5a2b27 Change the logging level and other improvement. 2023-11-20 12:57:26 +08:00
Lin Yihai
ac1e66d947 Add testcase for custom build file warning 2023-11-17 17:11:57 +08:00
Eric Huss
0afd943dad Fix some test output validation. 2023-11-15 15:10:18 -08:00
Lin Yihai
b2b026bfbb Improve testcase include_files_called_target_git 2023-11-14 11:25:11 +08:00
Lin Yihai
722d8f1c1d Add target folder but not committed 2023-11-10 15:49:57 +08:00
Lin Yihai
4577c0ec61 Correct the situation with git repository test cases 2023-11-10 14:22:03 +08:00
Karel Peeters
2c503f89c4 Add unit test for files called target.
https://github.com/rust-lang/cargo/issues/12790
2023-11-10 10:38:26 +08:00
Ed Page
bfb5d1db0e fix(toml): Default package.publish based on presence of package.version
Before the default was hardcoded to `true`.  The problem was that means
that to remove the `package.version` boilerplate, you had to add
`package.publish = false` boilerplate.

To make the errors easier to understand in this situation, I err on the
side of encouraging people to put `publish = true` in their manifests.

By making this change, we also unblock "cargo script" /
`Cargo.toml` unifying the handling of `package.publish`.
2023-10-11 13:17:03 -05:00
Ed Page
1923b5b862 feat(toml): Allow versionless packages
This defaults the version to `0.0.0` for most of cargo.

It is an error to lack a version and have a package publishable.
That means you have to add `publish = false`.
2023-10-11 13:13:44 -05:00
Ed Page
5c9a126911 test(toml): Verify existing version-less behavior 2023-10-06 12:21:07 -05:00
Scott Schafer
b2b3cfa524
feat: Add Edition2024 2023-10-04 13:11:52 -06:00
Ed Page
cc6b6c9584 fix(package): Avoid multiple package list entries
To keep things simple, especially in getting a `Hash` implementation
correct, I'm leveraging `unicase` for case-insensitive
comparisons which is an existing dependency and I've been using for
years on other projects.

This also opens the door for us to add cross-platform compatibility
hazard warnings about multiple paths that would write to the same
location on a case insensitive file system.  I held off on that because
I assume we would want #12235 first.

This does mean we can't test the "no manifest" case anymore because the
one case (no pun intended) I knew of for hitting it is now gone.
2023-07-26 11:02:47 -05:00
Ed Page
9b14e39cd7 test(package): Verify mixed-case Cargo.toml 2023-07-26 10:10:21 -05:00
Ed Page
3166e5f614 fix(package): Warn when manifest is not more generally found
Being a bit cautious about not turning this into an error since this is
most likely because of case insensitive filesystems.
2023-07-24 16:49:38 -05:00
Ed Page
f4c97b24a8 test(package): Verify the no-manifest case 2023-07-24 16:41:15 -05:00