0

I have downloaded a copy of the 1.1.0-RELEASE tagged source code for Spring RESTdocs, but "gradlew build" is failing during the test phase. 273 of 502 tests are failing with variations on this error: org.springframework.restdocs.request.RequestPartsSnippetTests > requestPartsWithOptionalColumn[Markdown] FAILED java.lang.AssertionError: Expected: is adoc snippetPart | Optional | Description ---- | -------- | ----------- a | true | one b | false | two but: was:Part | Optional | Description ---- | -------- | ----------- a | true | one b | false | two

The problem looks to be that the string "adoc snippet" is prefixed to the start of the expected output. I don't think that's right, although I can see in the AbstractContentSnippetMatcher.describeTo() why it's happening and it doesn't look very conditional so maybe it's the test's actual result that's wrong?

I have made no changes to the source code* but I don't see other people reporting this problem, so I'm mystified. I'm entirely new to gradle. Is there some kind of config I need to set up to make the tests pass? Should I be using a different target?

(OK... 1 teensy change: I removed the new-line-at-end-of-file check from the checkStyle - I'm downloading from Github onto a Windows PC.)

Julie C
  • 1
  • 1
  • There's a [Windows-specific CI job](https://build.spring.io/browse/SRD-WIN) where all the tests pass (in addition to one that runs on Linux) so I don't think there's a general problem. There most be something different about your environment. I wonder if it's related to line endings. How have you got Git set up (`core.autocrlf`, for example)? – Andy Wilkinson Jul 11 '16 at 21:41
  • @JulieC You seem to have used 2 different accounts to edit your question (and so got your edit into the review queues). Can you please stick to the one account? – Peter Brittain Jul 12 '16 at 22:26
  • @AndyWilkinson I agree, must be environmental, I just don't know what. I've tried running the build in both Windows & cygwin command line, but same result. I downloaded using the .zip file (of v1.1.0.RELEASE), so I don't have github settings. Would you be able to comment on which of my two pieces of output is correct in your environment? i.e. The expected result or the actual result? Maybe if I knew which ghost in the machine I should be chasing... – Julie C Jul 13 '16 at 20:27
  • @PeterBrittain Thanks for pointing that out, it explains a lot! Using two browsers, I guess one has some mystery credentials cached. I'll go try to clear that up. – Julie C Jul 13 '16 at 20:29
  • I am not sure if this is related, But I had a problem running single tests from a Netbeans IDE. It seems Window/Netbeans/NewLines are a horrible combination. Had no problems running the suite from the terminal. You can see what I had to do [here](https://github.com/RESTDocsEXT/restdocsext-jersey/blob/master/src/test/java/io/github/restdocsext/jersey/test/SnippetMatchers.java#L121) in the `SnippetMatchers`. That seems to be the location of the problem you are facing. – Paul Samsotha Jul 14 '16 at 04:15
  • My problem wasn't exactly the same though. What I was facing was that the content looked _exactly_ the same, but you couldn't tell the difference because new lines are invisible. But in your case there seems to be prefixed line missing. – Paul Samsotha Jul 14 '16 at 04:17

1 Answers1

0

The problem is that the files in the zip have Unix-style line endings but, when run on Windows, Checkstyle and the tests expect Windows-style line endings.

Typically a Windows Git client will take care of this for you by converting the line endings when you check out the code. For example, the default configuration of Git for Windows is to check code out with Windows-style line endings but commit changes with Windows-style line endings.

You may be able to find a Windows utility that will batch-convert the line endings from LF to CRLF. Failing that, it's probably easiest to install a Git client (such as Git for Windows that I linked to above), ensure it's configure to perform line ending conversion, and then:

> git clone https://github.com/spring-projects/spring-restdocs
> cd spring-restdocs
> gradlew build
Andy Wilkinson
  • 108,729
  • 24
  • 257
  • 242