Commit Graph

85 Commits

Author SHA1 Message Date
clippered
d2f2f25463 add cli option for color 2017-11-13 20:18:03 +11:00
topecongiro
b17de6228f Cargo fmt 2017-11-02 21:45:00 +09:00
Shohei Wada
fe1619b548 Fix the test framework is failing in CRLF env 2017-10-07 01:53:55 +09:00
opilarium
72a9ad6199 Remove unused import 2017-09-21 22:54:29 +03:00
Nick Cameron
bdf791a174 Comment out stdin_disable_all_formatting_test 2017-09-21 20:06:44 +12:00
topecongiro
0779962a6e Add debug logging 2017-09-19 13:46:13 +09:00
topecongiro
007c673012 Remove noisy print from test 2017-09-19 11:02:21 +09:00
topecongiro
75a36f2886 Add a test for 'disable_all_formatting = true' with stdin 2017-09-18 14:19:50 +09:00
Seiichi Uchida
4b79055a15 Apply refactoring from cargo clippy 2017-08-31 12:49:12 +09:00
Seiichi Uchida
404e2db046 Remove unused extern crate 2017-08-28 23:43:49 +09:00
topecongiro
c28df858c7 Format source codes and update tests 2017-08-09 00:16:35 +09:00
Seiichi Uchida
a8b0a6e4c5 Format source codes and update tests 2017-07-20 00:42:00 +09:00
topecongiro
3bf66436e7 Update tests 2017-07-13 18:43:35 +09:00
Andy Russell
86d48981ee
assert no errors on formatting test source
Fixes #28.
2017-07-12 13:21:36 -04:00
topecongiro
cb48435ff3 Format source codes 2017-07-05 18:31:37 +09:00
topecongiro
208ff15954 Format source codes 2017-06-16 08:49:49 +09:00
Robin Stocker
a13db07b03 Add back cargo-fmt binary (#1670)
When there are no `[[bin]]` sections, all the binaries in `src/bin` are
automatically picked up. When a section is added, that is no longer the
case, so all the binaries need to be specified explicitly.
2017-06-14 14:16:51 +10:00
Nick Cameron
6f30d9e7c9 Reformat tests 2017-06-13 14:42:54 +12:00
topecongiro
62d200d9cf Update tests 2017-06-04 19:35:29 +09:00
topecongiro
86856491bc Format source codes 2017-05-25 16:08:08 +09:00
topecongiro
04bb5d8929 Format source codes 2017-05-24 00:07:02 +09:00
Michael Killough
c3c2e823cb Merge branch 'master' of https://github.com/rust-lang-nursery/rustfmt into config 2017-05-18 13:05:19 +07:00
Michael Killough
222bac1397 Provide config.set().item(value) API.
This API isn't fantastic, but it's the best I can come up with without
something like `concat_idents!()`. There are relatively few places where
config is set, to hopefully the ugliness isn't disastrous.

Change previous occurences of `config.item = value` to this new API,
rather than using `config.override_value()`. Undo the changes to
`override_value()`, as it's no longer important to propogate the error
to the caller. Add a test for the new interface.
2017-05-18 11:42:32 +07:00
topecongiro
d7b6f1199f Format source codes 2017-05-16 23:24:38 +09:00
Michael Killough
c0bdbfa531 Switch to accessing config items via method.
Preparation for #865, which proposes adding a flag which outputs which
config options are used during formatting.

This PR should not make any difference to functionality. A lot of this
was search-and-replace.

Some areas worthy of review/discussion:

 - The method for each config item returns a clone of the underlying
   value. We can't simply return an immutable reference, as lots of
   places in the code expect to be able to pass the returned value as
   `bool` (not `&bool). It would be nice if the `bool` items could
   return a copy, but the more complex types a borrowed reference... but
   unfortunately, I couldn't get the macro to do this.
 - A few places (mostly tests and `src/bin/rustfmt.rs`) were overriding
   config items by modifying the fields of the `Config` struct directly.
   They now use the existing `override_value()` method, which has been
   modified to return a `Result` for use by `src/bin/rustfmt.rs`. This
   benefits of this are that the complex `file_lines` and `write_mode`
   strings are now parsed in one place (`Config.override_value`) instead
   of multiple. The disadvantages are that it moves the compile-time
   checks for config names to become run-time checks.
2017-05-16 15:47:09 +07:00
Vincent Esche
4385b8063d Improve error message for missing source/target test file 2017-05-01 23:34:00 +02:00
topecongiro
02cf515be6 Format source codes 2017-04-24 16:50:11 +09:00
topecongiro
6af0968511 Change return type of 'from_toml' from 'Config' to 'Result<Config>'
Closes #1426.
2017-04-03 13:58:46 +09:00
Nick Cameron
5305bc8436 test fallout 2017-03-28 11:25:59 +13:00
Nick Cameron
91bbe0ff8b Test fallout 2017-03-28 11:01:44 +13:00
Nick Cameron
33b83ae7df Formatting fallout
Also fixes a minor bug when we break a line after `if` and used to leave a trailing space
2017-03-07 09:50:41 +13:00
Igor Gnatenko
3323056893 bump regex to 0.2
Signed-off-by: Igor Gnatenko <ignatenko@redhat.com>
2017-02-26 15:09:31 +01:00
Nick Cameron
db10a0b9b2 Merge pull request #1325 from C4K3/master
Add error_on_line_overflow option
2017-02-23 14:46:24 +13:00
Nick Cameron
a7612cc773 more fallout 2017-02-23 13:15:48 +13:00
Nick Cameron
ba1202f6b3 test fallout 2017-02-23 13:15:48 +13:00
Sebastian Blunt
235f33b230
Make tests fail if rustfmt encounters an error
Previously tests would not fail if they encountered an error such as
LineOverflow or TrailingWhitespace. Making the tests error out will fix
this mismatch between running rustfmt for real and running the tests.

This also modifies all tests that previously contained errors so that
they no longer contain errors (in almost all of the tests this is
accomplished by setting error_on_line_overflow = false).
2017-02-19 19:57:02 +01:00
Fraser Hutchison
aef665aa21 Fixes a few doc typos. 2016-11-03 04:22:16 +00:00
Nick Cameron
e1759ae295 Merge pull request #1123 from juicejitsu/807
Don't emit filename in diff mode, add filename to diff metadata
2016-08-10 21:52:46 +12:00
juicejitsu
a0de408198 Don't emit filename in diff mode, add filename to diff metadata 2016-08-09 18:21:04 -07:00
Stuart Dootson
5dda986a2c Add commentary 2016-08-09 22:11:27 +02:00
Stuart Dootson
4055e272da Reformat the source to actually pass the tests! 2016-08-09 22:10:48 +02:00
Stuart Dootson
cb0b7108ca Add test case for issue #1111, by adding another route by which a test file's config can be located 2016-08-08 23:13:45 +02:00
Kamal Marhubi
5361f61110 Include git commit and worktree status in version output (#1060)
This will help in debugging issues as rustfmt gets more users.

If the working tree is clean, output looks like

    $ target/debug/rustfmt -V
    0.5.0 (9f5ed3b)

If the working tree is dirty, output looks like

    $ target/debug/rustfmt -V
    0.5.0 (9f5ed3b worktree dirty)

If git is unavailable, output looks like

    $ target/debug/rustfmt -V
    0.5.0 (git commit unavailable)

To avoid rebuilds on changing tests, the build script will only rerun if
files under src/ are changed. This means the actual git status may show
changed files and this would not show up in the version. This should not
be an issue as files not in src/ should not affect the build output.
2016-06-12 10:38:03 +02:00
Nick Cameron
9b05461666 Write each file as it is formatted (#991)
The old behaviour stored everything in memory until we were finished. Now we write as soon as we can.

This gives better behaviour when formatting large programs, since there is some progress indication. It also opens the door to optimising memory use by not storing everything in memory unless it is required (which it still might be). That is left as future work though.
2016-05-15 11:41:05 +02:00
Nick Cameron
a9c3108c9c Change defaults and update tests and source
New defaults are `Tabbed` for `chain_indent` and `chain_base_indent`, and `5` for `closure_block_indent_threshold`.
2016-04-22 19:18:48 +12:00
Nick Cameron
9761cf71d8 Tests 2016-04-22 18:53:39 +12:00
Aleksey Kladov
77350e49b5 return non-zero exit code if there were errors 2016-04-15 02:51:50 +03:00
Aleksey Kladov
dc1fc4be0f unify format_string and format_file 2016-04-11 22:56:54 +03:00
Nick Cameron
19849fea15 Update the world 2016-04-08 15:51:06 +12:00
Aleksey Kladov
07cf62fc42 simplify tests
* change layout so that test group `foo` has source files in
`test/foo/source` and target files in `test/foo/target`.

* use significant comments to specify write mode instead of threading
  Option<WriteMode>
2016-04-05 02:45:39 +03:00