58 Commits

Author SHA1 Message Date
bjorn3
f5a3d55983 Fix warnings of the new non_fmt_panic lint 2021-02-06 19:10:42 +01:00
Eric Huss
fdb8ea1e03 Add some extra help to cargo new and invalid package names. 2021-01-24 13:21:25 -08:00
bors
78beb3784f Auto merge of #8912 - aniljava:master, r=alexcrichton
Fixes #8783 , cargo new fails without a author name or email

If user can not be obtained from git or env variables $USER, new command defaults to empty author in generated Cargo.toml

Could not edit old PR(#8910 8783) as the original clone was deleted.
2020-12-03 15:14:39 +00:00
Anil P
a006347b2d Removed debug println! 2020-12-02 23:04:00 -06:00
Anil P
4787dd3acf rustfmt 2020-12-02 23:02:55 -06:00
Anil P
4eeadfb38c Explicitly removed USER env variables. 2020-12-02 22:59:40 -06:00
Anil P
fad16813a3 Removed debug println from earlier commit. 2020-12-02 12:39:29 -06:00
asdf
c3e01b8fe3 Fix test escaping __CARGO_TEST_ROOT 2020-12-01 21:58:32 -08:00
Anil P
917fc99fd5 Test cargo new with missing authors
- test case for missing name and email (author_without_user_or_email)
- test case for handling email only (finds_author_email_only)
2020-12-01 23:46:16 -06:00
Franz-Xaver Geiger
35b029c2ce Start searching git config at path of the new project
This lets `cargo new` follow `includeIf` blocks inside .gitignore.

Fixes #8882
2020-11-23 20:43:57 +01:00
Eric Huss
0be75d2edc Update git2. 2020-10-13 18:13:25 -07:00
Weihang Lo
c6fcb0e2ef
Fix unintenional newline in stderr assertion 2020-09-11 01:02:59 +08:00
Weihang Lo
2fbce89dd6
Rephrase message of restricted crate name 2020-09-11 00:39:51 +08:00
Weihang Lo
c00ad7922d
Fix test for windows reserved filename error message 2020-09-04 09:18:47 +08:00
Weihang Lo
9cda385ab3
Test for --name hint 2020-09-04 08:39:13 +08:00
Eric Huss
4ae79d2ffd Use fs helpers instead of File functions. 2020-04-17 07:56:16 -07:00
Eric Huss
95008f91e5 Try to better handle restricted crate names. 2020-03-02 16:04:24 -08:00
bors
abba15f95a Auto merge of #7667 - giraffate:add_test_for_name_when_cargo_new, r=alexcrichton
Add test for `NAME` environment variable when `cargo new`

Looks like there was no test for `NAME` environment variable when `cargo new`.
2019-12-06 01:14:07 +00:00
Takayuki Nakata
2fb90adc73 Add test for NAME environment variable when cargo new 2019-12-06 09:30:13 +09:00
Takayuki Nakata
058937f018 Add test for GIT_COMMITTER_EMAIL when cargo new
There was no test for `GIT_COMMITER_EMAIL`, so I add the test for
this. In addition, I update the name of some tests.
2019-12-05 12:39:10 +09:00
Josh Triplett
997a6d5ab9 Stop ignoring .rs.bk files; rustfmt hasn't generated them in years
cargo currently generates a .gitignore file that ignores .rs.bk files,
historically because rustfmt would sometimes generate such files.
However, rustfmt and cargo fmt don't generate backup files by default
(only when requested), and even when requested, they generate .bk files,
not .rs.bk files (as of rustfmt commit
fad903fd14ad0df045dc574cac0717312860c380 in 2017). And nobody seems to
have noticed or complained since then, likely because rustfmt doesn't
generate backup files by default.

rustfmt also plans to deprecate the --backup option entirely, in rustfmt
2.0, and instead always rely on version control to track changes.

In addition, these types of ignores, just like ignores of editor backup
files, don't belong in .gitignore; they belong in people's personal
ignore files, such as ~/.config/git/ignore.  See
https://julien.danjou.info/properly-managing-your-gitignore/ for further
explanation of that.

Given all three of those factors, drop the code to add **/*.rs.bk to
.gitignore, and update tests accordingly.
2019-12-02 12:40:38 -08:00
Eric Huss
83571aee56 Minor testsuite organization. 2019-11-24 18:42:45 -08:00
Alex Crichton
c37a46ced4 Handle a case where cargo new oscillates 2019-11-18 07:27:18 -08:00
Alex Crichton
7606f79661 Improve test output with --quiet
We had a few locations where the shell was written to raw instead of
through the test harness or through other captured mechanisms. This
updates the test suite so testing Cargo with `--quiet` provides a nice
and clean report of tests executed.
2019-09-26 11:32:29 -07: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
a4e9611453 Fix some formatting for some strings. 2019-07-13 16:00:47 -07:00
Jethro Beekman
0e0d968825 Update #[test] attribute on all tests in the testsuite
sed -i 's/^#\[test\]/#[cargo_test]/' $(rg -l '^#\[test\]')

Manual fixes:
* proc_macro::proc_macro_doctest
2019-06-07 12:41:26 -07:00
k-nasa
f781d2df86 test: Add reference link test 2019-05-02 06:29:56 +09:00
Eric Huss
4282274e64 new/init: Don't include email if it is empty. 2019-03-31 14:05:49 -07:00
Andrew Kvalheim
5a5d924c3e End VCS ignore files with a newline 2019-03-10 14:40:32 -07:00
nasa
db09895f3c $cargo fmt --all 2019-01-27 22:39:49 +09:00
Johannes Weissmann
99a23c0883 avoid duplicates in ignore files
existing ignore files are now checked for duplicates. If the file
already contains an entry it is commented out in the section added by
cargo.

fixes #6377
2019-01-04 23:47:16 +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
Brennan Ashton
7d579483c6 Strip angle brackets from author email before passing to template.
Some people already have angle brackets around their email in
git settings or other author sources. Right now if you create
a new project the Cargo.toml would render something like:

authors = ["bar <<foo@baz>>"]

instead of

authors = ["bar <foo@baz>"]

This detects the emails that start and end with <> and removes them.
2018-11-01 15:05:19 -07:00
Zach Lute
3492a3905c Replace 'project' with 'package' in many strings and comments. 2018-09-20 23:47:09 -07: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
Alex Crichton
cf8d6a41b5 Change the default edition for cargo new to 2018
As it says on the tin! Some tests were updated to explicitly pass 2015 so they
can continue to work on stable, and otherwise `cargo new` should now by default
generate a 2018 project.
2018-09-06 17:01:20 -07: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
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
6fd1b54c65
Remove hamcrest existing_dir() 2018-08-29 07:53:01 +02:00
Dale Wijnand
85984a8700
Migrate from tests fom assert_that/execs to .run() 2018-08-28 15:08:12 +02:00
Dale Wijnand
16aeb0cd4f
Default test support's Execs to exit code 0 2018-08-03 07:44:42 +01:00
Dale Wijnand
dda661ddf2
Introduce git_process too 2018-08-02 18:00:02 +01:00
Dale Wijnand
8940d30668
Make cargo_process take a string it splits on whitespace 2018-08-02 18:00:02 +01:00
Eh2406
acf89e946c update test for #5733 2018-07-26 14:39:10 -04:00
Without Boats
064a1461d7
Respect .gitignore during cargo new
When running `cargo new`, we check to see if you are inside a git
repository. If you are, we do not initialize a new git repo for
your project unless you specifically asked for it using --vcs.
(See #1210 for more background).

This commit changes that behavior to *also* create a new repo if
the project would be an ignored path in the parent repository.
This way, if your home directory is a git repository, as long as
you have ignored the directory you are creating a new project in,
we will instantiate a git repository without you having to
specifically request it.
2018-07-26 15:39:42 +02: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