Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running cargo test on windows fails when autocrlf is set in git #617

Closed
Marwes opened this issue Nov 16, 2015 · 5 comments · Fixed by #2029
Closed

Running cargo test on windows fails when autocrlf is set in git #617

Marwes opened this issue Nov 16, 2015 · 5 comments · Fixed by #2029
Labels
bug Panic, non-idempotency, invalid code, etc. os-windows
Milestone

Comments

@Marwes
Copy link
Contributor

Marwes commented Nov 16, 2015

Tried running cargo test in windows and more or less every test is failing which leads me to guess it is due to git replacing line endings. Couldn't find any information on how to deal with this so opening an issue.

running 14 tests
test comment::test::char_classes ... ok
test comment::test::comment_code_slices ... ok
test comment::test::comment_code_slices_two ... ok
test comment::test::comment_code_slices_three ... ok
test comment::test::test_contains_comment ... ok
test comment::test::test_find_uncommented ... ok
test comment::test::test_uncommented ... ok
test issues::find_issue ... ok
test issues::find_unnumbered_issue ... ok
test issues::issue_type ... ok
test utils::power_rounding ... ok
test utils::bin_search_test ... ok
test string::test::issue343 ... ok
test comment::test::format_comments ... ok

test result: ok. 14 passed; 0 failed; 0 ignored; 0 measured

     Running target\debug\rustfmt-7890f56441b13a3f.exe

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured

     Running target\debug\system-0cb9f497ada86c58.exe

running 4 tests
test coverage_tests ... FAILED

Mismatch at tests/source\comment.rs:17:
     // amet, consectetur adipiscing elit. Aenean ut gravida lorem. Ut turpis⏎
     // felis, pulvinar a semper sed, adipiscing id dolor.⏎
 ⏎
+⏎
     // Very looooooooooooooooooooooooooooooooooooooooooooooooooooooooong comment⏎
     // that should be split⏎
 ⏎
test system_tests ... FAILED
test idempotence_tests ... FAILED
test self_tests ... FAILED

failures:

---- coverage_tests stdout ----
        Testing 'tests/coverage-source\comments.rs'...
Ran 1 tests in coverage mode.
thread 'coverage_tests' panicked at '1 tests failed', tests\system.rs:62

---- system_tests stdout ----
        Testing 'tests/source\assignment.rs'...
Testing 'tests/source\attrib.rs'...
Testing 'tests/source\chains-block-indented-base.rs'...
Testing 'tests/source\chains-indent-inherit.rs'...
Testing 'tests/source\chains-indent-tabbed.rs'...
Testing 'tests/source\chains-indent-visual.rs'...
Testing 'tests/source\chains-no-overflow.rs'...
Testing 'tests/source\chains.rs'...
Testing 'tests/source\closure.rs'...
Testing 'tests/source\comment.rs'...
Testing 'tests/source\comment2.rs'...
Testing 'tests/source\comment3.rs'...
Testing 'tests/source\doc.rs'...
Testing 'tests/source\empty_file.rs'...
Testing 'tests/source\enum-no_trailing_comma.rs'...
Testing 'tests/source\enum.rs'...
Testing 'tests/source\expr-no-hints.rs'...
Testing 'tests/source\expr.rs'...
Testing 'tests/source\extern.rs'...
Testing 'tests/source\fn-custom-2.rs'...
Testing 'tests/source\fn-custom-3.rs'...
Testing 'tests/source\fn-custom-4.rs'...
Testing 'tests/source\fn-custom-5.rs'...
Testing 'tests/source\fn-custom-6.rs'...
Testing 'tests/source\fn-custom.rs'...
Testing 'tests/source\fn-simple.rs'...
Testing 'tests/source\hard-tabs.rs'...
Testing 'tests/source\hello.rs'...
Testing 'tests/source\hello2.rs'...
Testing 'tests/source\imports-reorder.rs'...
Testing 'tests/source\imports.rs'...
Testing 'tests/source\issue-510.rs'...
Testing 'tests/source\loop.rs'...
Testing 'tests/source\macros.rs'...
Testing 'tests/source\macro_not_expr.rs'...
Testing 'tests/source\match.rs'...
Testing 'tests/source\mod-1.rs'...
Testing 'tests/source\mod-2.rs'...
Testing 'tests/source\multiple.rs'...
Testing 'tests/source\no_new_line_beginning.rs'...
Testing 'tests/source\other.rs'...
Testing 'tests/source\paths.rs'...
Testing 'tests/source\pattern.rs'...
Testing 'tests/source\single-line-if-else.rs'...
Testing 'tests/source\static.rs'...
Testing 'tests/source\string-lit.rs'...
Testing 'tests/source\string_punctuation.rs'...
Testing 'tests/source\structs.rs'...
Testing 'tests/source\struct_lits.rs'...
Testing 'tests/source\struct_lits_multiline.rs'...
Testing 'tests/source\struct_lits_visual.rs'...
Testing 'tests/source\struct_lits_visual_multiline.rs'...
Testing 'tests/source\trait.rs'...
Testing 'tests/source\type.rs'...
Ran 54 system tests.
thread 'system_tests' panicked at '54 system tests failed', tests\system.rs:50

---- idempotence_tests stdout ----
        Testing 'tests/target\assignment.rs'...
Testing 'tests/target\attrib-extern-crate.rs'...
Testing 'tests/target\attrib.rs'...
Testing 'tests/target\chains-block-indented-base.rs'...
Testing 'tests/target\chains-indent-inherit.rs'...
Testing 'tests/target\chains-indent-tabbed.rs'...
Testing 'tests/target\chains-indent-visual.rs'...
Testing 'tests/target\chains-no-overflow.rs'...
Testing 'tests/target\chains-no-overlow-2.rs'...
Testing 'tests/target\chains.rs'...
Testing 'tests/target\closure.rs'...
Testing 'tests/target\comment.rs'...
Testing 'tests/target\comment2.rs'...
Testing 'tests/target\comment3.rs'...
Testing 'tests/target\comments-fn.rs'...
Testing 'tests/target\doc.rs'...
Testing 'tests/target\empty_file.rs'...
Testing 'tests/target\enum-no_trailing_comma.rs'...
Testing 'tests/target\enum.rs'...
Testing 'tests/target\expr-no-hints.rs'...
Testing 'tests/target\expr.rs'...
Testing 'tests/target\extern.rs'...
Testing 'tests/target\fn-custom-2.rs'...
Testing 'tests/target\fn-custom-3.rs'...
Testing 'tests/target\fn-custom-4.rs'...
Testing 'tests/target\fn-custom-5.rs'...
Testing 'tests/target\fn-custom-6.rs'...
Testing 'tests/target\fn-custom.rs'...
Testing 'tests/target\fn-simple.rs'...
Testing 'tests/target\fn.rs'...
Testing 'tests/target\fn_once.rs'...
Testing 'tests/target\hard-tabs.rs'...
Testing 'tests/target\hello.rs'...
Testing 'tests/target\impl.rs'...
Testing 'tests/target\imports-reorder.rs'...
Testing 'tests/target\imports.rs'...
Testing 'tests/target\issue-510.rs'...
Testing 'tests/target\issue-64.rs'...
Testing 'tests/target\long-fn-1.rs'...
Testing 'tests/target\loop.rs'...
Testing 'tests/target\macros.rs'...
Testing 'tests/target\macro_not_expr.rs'...
Testing 'tests/target\match.rs'...
Testing 'tests/target\mod-1.rs'...
Testing 'tests/target\mod-2.rs'...
Testing 'tests/target\multiple.rs'...
Testing 'tests/target\no_new_line_beginning.rs'...
Testing 'tests/target\other.rs'...
Testing 'tests/target\paths.rs'...
Testing 'tests/target\pattern.rs'...
Testing 'tests/target\single-line-if-else.rs'...
Testing 'tests/target\skip.rs'...
Testing 'tests/target\static.rs'...
Testing 'tests/target\string-lit-custom.rs'...
Testing 'tests/target\string-lit.rs'...
Testing 'tests/target\string_punctuation.rs'...
Testing 'tests/target\structs.rs'...
Testing 'tests/target\struct_lits.rs'...
Testing 'tests/target\struct_lits_multiline.rs'...
Testing 'tests/target\struct_lits_visual.rs'...
Testing 'tests/target\struct_lits_visual_multiline.rs'...
Testing 'tests/target\trait.rs'...
Testing 'tests/target\tuple.rs'...
Testing 'tests/target\type.rs'...
Ran 64 idempotent tests.
thread 'idempotence_tests' panicked at '64 idempotent tests failed', tests\system.rs:78

---- self_tests stdout ----
        Testing 'src/bin\rustfmt.rs'...
Testing 'tests\system.rs'...
Testing 'src/lib.rs'...
Ran 3 self tests.
thread 'self_tests' panicked at '3 self tests failed', tests\system.rs:98


failures:
    coverage_tests
    idempotence_tests
    self_tests
    system_tests

test result: FAILED. 0 passed; 4 failed; 0 ignored; 0 measured
@Marwes
Copy link
Contributor Author

Marwes commented Nov 20, 2015

Anyone developing rustfmt on windows successfully or have any comment on how to resolve this?

EDIT: Setting core.autocrlf = false in .gitconfig and cloning a new repository seems to do the trick, it would be better if it "just worked however".

@Marwes Marwes changed the title Running cargo test on windows fails (possibly git replacing lineendings?) Running cargo test on windows fails when autocrlf is set in git Nov 21, 2015
@Marwes
Copy link
Contributor Author

Marwes commented Nov 21, 2015

With 7809e3b merged + using the Native newline configuration option cargo test passes all tests with the autocrlf option set in git. Unfortunately that will likely break cargo test for anyone not having core.autocrlf = true.

One solution might be to override the global settings using a .gitattributes file to make sure that tests that are sensitive to line endings are run consistently.

@marcusklaas marcusklaas mentioned this issue Jan 2, 2016
@cyplo
Copy link

cyplo commented Aug 1, 2016

Hi ! Is this still an issue ?

@nrc nrc added bug Panic, non-idempotency, invalid code, etc. os-windows and removed bug Panic, non-idempotency, invalid code, etc. labels Sep 18, 2017
@nrc nrc added this to the impl period milestone Sep 18, 2017
@wada314
Copy link
Contributor

wada314 commented Oct 4, 2017

Today some tests are still failing with CRLF newline. Mostly because many rustfmt codes are assuming the newline is a single LF character. We should decide which layer to convert CRLFs into LF.

I think we should not depend on git checkout-time settings. rustfmt can be used in the both LF env and CRLF env in real world. We must accept CRLF input file, then make sure to convert it to LF at some layer, then pass it to rustfmt submodules.

@SingingTree
Copy link
Contributor

Still looks like a problem. The symptom one sees at the moment is described in #1318

@nrc nrc closed this as completed in #2029 Oct 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Panic, non-idempotency, invalid code, etc. os-windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants