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
Add Travis CI check for whitespace at the ends of lines. #1477
Conversation
@godbyk: And right with pull request, it's the first time I'm seeing a Travis CI failure. How's that? |
@godbyk: wonderful, thanks! |
@jensmaurer I just pushed a fix. Waiting to see if Travis CI likes it. (During my later testing, I was canceling the non-test-whitespace builds as I wasn't testing the PDF builds.) |
.travis.yml
Outdated
# Fail if there is whitespace at the ends of any lines | ||
- export TEST_STATUS=0; | ||
if [ "$BUILD_TYPE" = "check-whitespace" ]; then | ||
grep '\s$' source/*.tex && export TEST_STATUS=1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I don't know Travis, but if this is just shell code, couldn't you just say grep '\s$' source/*.tex
here and let grep
's return status do the job? It seems that just false
has the desired effect of failing the test, so grep
should be able to d the same?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tkoeppe I need to invert grep's exit status.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, OK, what about ! grep ...
then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tkoeppe When I tried that previously it didn't work, but it appears to be working now. (I guess it was a combination of bugs previously—testing the .travis-ci.yml
file is a bit of trial-and-error.) Thanks for prompting me to give it another shot; it greatly simplifies the code!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Less is more :-)
6752175
to
e054ed0
Compare
Thanks a lot! I've always wanted this to be cleaned up, and now we can prevent people from ever breaking it again! |
@tkoeppe No problem! |
Per @tkoeppe's suggestion.
This adds a new build type to the Travis CI build which only checks for whitespace at the ends of lines. If it finds any, it will fail the build.
Having this test as a separate 'build type' makes it easy to determine whether the whitespace test failed or whether the PDF compilation failed.
Note: If we plan on adding more tests in the future (e.g., checks for other nonconformant usage)—which I'm in favor of—then I'd recommend we migrate the code from
.travis-ci.yml
to a separate shell script where we can write more succinct code. (Travis CI wraps the.travis-ci.yml
code in its own function and hijacks the exit code$?
variable, so we have to capture it to test it later. Within our own shell script, this isn't a problem.)