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

First cut of test for the Airbrussh formatter #13

Merged
merged 2 commits into from
May 30, 2015

Conversation

robd
Copy link
Contributor

@robd robd commented May 22, 2015

This is a first cut of a test for the Airbrussh formatter in order to try to protect against breakages when I update it to work with the latest SSHKit.

I guess the first question is, is there something like this test already that I am missing? How do you know if things are working - is it manual at the moment?

A few other thoughts came up when I was working on this:

  • Would you be OK with setting up a travis build for this? [EDIT I AM AN IDIOT, ignore]
  • What ruby versions do you want to support?
  • Would you be supportive of merging this into SSHKit?

Some of the Rubocop rules are a PITA IMHO! I guess Rubocop rules in Airbrussh are quite new, but I wanted to mention I disabled the line length checks and the other rules which I disagreed strongly with in the test. We can talk about these if you want.

Let me know your thoughts - thanks!

@robd robd force-pushed the add-formatter-test branch 4 times, most recently from b0dfc94 to 80a32a5 Compare May 23, 2015 13:34
@robd
Copy link
Contributor Author

robd commented May 23, 2015

@mattbrictson I guess maybe you're not about at the moment, but this passes on all ruby / sshkit versions now. I rebased this on #14, so PR #14 should probably be merged before this one to make the history clear. I hope this is useful, let me know what you think.

I will now move on to try and rework Airbrussh to use the new SSHKit command logging API.

@robd robd force-pushed the add-formatter-test branch 8 times, most recently from fed33a7 to 7eba160 Compare May 24, 2015 10:38
@mattbrictson
Copy link
Owner

@robd Thanks for starting to fill in much-needed test coverage for Airbrussh. I hadn't realized that on_local could make tests fairly easy to write. Great idea!

What ruby versions do you want to support?

I see you have suggested 1.9+. I would really like to drop 1.9, but there is evidence that 1.9 is still being used. I've opened a separate issue to discuss that.

Some of the Rubocop rules are a PITA IMHO!

I agree that the line-, method-, and class-length checks in particular cause trouble for writing tests. For actual (i.e. non-test) code though, I would like to try to honor the Rubocop recommendations.

Would you be supportive of merging this into SSHKit?

Definitely! Give me a little more time to review these changes and I'll let you know.

def assert_log_file_lines(*command_lines)
preamble_lines = [
/#{blue('INFO')} ---------------------------------------------------------------------------\n/,
/#{blue('INFO')} START [\d\-]+ [\d\:]+ \+\d+ cap\n/,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@robd I think this regex needs to be tweaked to work in my time zone. The minus sign isn't getting matched:

FAIL["test_formats_execute_without_color", TestFormatter, 2015-05-24 13:45:46 -0700]
 test_formats_execute_without_color#TestFormatter (1432500346.55s)
        Expected /INFO START [\d\-]+ [\d\:]+ \+\d+ cap\n/ to === "  INFO START 2015-05-24 16:34:30 -0700 cap\n".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah OK, of course. With all of these tests, it's a bit hard to know how tightly to match the output. Also, much of this is testing the SSHKit pretty formatter, but since I don't really know what SSHKit did historically, I think it's worth testing here.

I will fix and rebase this PR on master, and also rebase #15. Will comment when this is done.

@robd robd force-pushed the add-formatter-test branch from 7eba160 to e04e460 Compare May 25, 2015 09:50
@robd
Copy link
Contributor Author

robd commented May 25, 2015

OK, rebased on master and hopefully fixed negative timezone offset.

@mattbrictson
Copy link
Owner

Tests pass on my machine and this looks good to merge. I am going to review #17 first, since I think it supersedes this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants