42 Commits

Author SHA1 Message Date
Rustin-Liu
9ede5267ce fix: refine test 2020-07-11 10:36:49 +08:00
Rustin-Liu
773ab74b87 fix: add space to comments 2020-07-11 00:16:21 +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
Matthias Krüger
1d912002e9 fix most remaining clippy findings (mostly redundant imports) 2020-02-21 12:15:16 +01:00
Kinrany
bc4c65c5d3 Do not run formats_source if rustfmt is not available
Generalized `clippy_is_available` and renamed as `command_is_available`.

No checks in `ignores_failure_to_format_source`, it's not supposed to
use `rustfmt` even if it's available
2020-02-05 10:09:43 +03:00
Kinrany
ea4f53cbd4 Fix tests on Linux/MacOS
The tests were failing with error:
"could not determine the current user, please set $USER"
2020-01-28 00:46:56 +03:00
Kinrany
6baf6bca01 Add tests
Test 1: init a library crate with a `rustfmt.toml` config file in it.
Expect the generated source files to be formatted according to the
config file.

Test 2: same as test 1, but with missing `rustfmt`. Expect `cargo init`
to ignore the absence of `rustfmt` and generate source files
with default formatting.
2020-01-27 19:42:20 +03: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
Odin Dutton
c42f2eeb0e Improve gitignore comment wording 2019-11-08 10:00:57 +11:00
Odin Dutton
a6db5b0797 Fix comment 2019-11-08 10:00:29 +11:00
Odin Dutton
3e8cdd7ce0 Only include "already existing ..." comment in gitignore on conflict
This comment was previously confusing when there were no existing items
that conflict.
2019-11-08 09:59:33 +11: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
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
Eric Huss
0b2b10b73c Cleanup: Misc. 2019-03-26 19:06:08 -07:00
Eric Huss
6d13bcce44 Make hg optional for tests. 2019-03-12 20:52:38 -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
Dale Wijnand
f3bd19fb94
Fix init::no_filename 2018-09-21 09:15:51 +01:00
Zach Lute
3492a3905c Replace 'project' with 'package' in many strings and comments. 2018-09-20 23:47:09 -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
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
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
Dale Wijnand
16aeb0cd4f
Default test support's Execs to exit code 0 2018-08-03 07:44:42 +01:00
Dale Wijnand
8940d30668
Make cargo_process take a string it splits on whitespace 2018-08-02 18:00:02 +01:00
Eh2406
7fc0dffed2 remove all of the (now) unnecessary temp file usage in tests 2018-07-26 15:10:48 -04:00
Dale Wijnand
6ca32be8a2
Declare one-line write_all contents on one line, too 2018-07-25 10:00:45 +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
Orestis Floros
dbb1abd814
cargo_new: remove redundant leading new lines from ignore files
Only add a leading new line in .gitignore/.hgignore/.ignore files when
the file existed before 'cargo new'.

Fixes #5265.
2018-03-31 17:40:44 +03:00
Bastien Orivel
8daf81e193 Replace tempdir by tempfile
The former has been deprecated in favor of the latter
2018-03-26 13:29:02 +02:00
Aleksey Kladov
b0c181d91c Prettify rustfmted single-line strings 2018-03-14 17:48:44 -07:00
Alex Crichton
1e6828485e cargo fmt 2018-03-14 17:48:23 -07:00
Aleksey Kladov
a64df78ea6 Relax tests for windows
On windows, clap prints `cargo.exe` rather than just `cargo`.
2018-03-10 18:46:32 +03:00
Aleksey Kladov
31ea0d93f7 Fix some trivially fixable tests 2018-03-08 23:31:56 +03:00
Aleksey Kladov
4131bdbe72 Move init to clap 2018-03-08 23:30:46 +03:00
André Rocha
c2ff988c9f Reorganize integration tests as one crate with many modules. Issue #4867. 2018-02-21 13:33:51 -05:00