-
Notifications
You must be signed in to change notification settings - Fork 35
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
Changes to allow rake test
to work on Windows; set up Windows-based CI
#55
Conversation
Hey @mattbrictson Sorry for the delay in getting back to you on this. This is very interesting to see what is required to get this to work on windows. I guess my overwhelming feeling is that it reinforces the need for acceptance tests against NetSSH on to Linux (which I imagine is more common) rather than against local windows backend. Re removing the default command map, I think this is probably reasonable. There was already some hackery to account for the difference between linux and osx. Since the prefix (if present) is formatted the same as the command, I think we don't lose much coverage by removing it across all tests. If the SSHKit readme is right, we may just be able to assign the new map without stubbing: SSHKit.config.command_map = Hash.new do |hash, command|
hash[command] = command.to_s
end Re the I may have misunderstood something here, but one thought I had here is, rather than changing the output to force colors, whether we could change the assertion not to expect colors on windows? The assertion changes to allow > 1 second commands are improvements. I am a bit confused about this: Etc.stubs(:getpwuid => stub(:name => "user")) because the name is hard coded to "user", but that is never asserted on in the tests (where the user name is 'test_user'). I guess the result of Etc.stubs(:getpwuid) Re changing the It's finely balanced, but I think if we can remove forcing colors in the log output ( Hope this is of some help - let me know your thoughts. |
@robd Thanks for the review.
You're probably right, but since
Good idea. I will make that change. It seems like it should be straightforward since there is already conditional logic for color.
This is because SSHKit's host.rb sets its |
OK, I just lost a massive comment that I wrote here (thanks Github), so apologies if this is a bit brief!
I think this is already achieved by the call to
The thing I think is confusing here is that the name stubbed is 'user' but the name asserted on in all of the tests is 'test_user'. Obviously the stubbed name isn't actually used because of this line, but I think this makes the intent of the stub confusing. Any stub would work here eg: In fact I think the correct thing to do here is to alter the test to only stub Expected / ✔ 01 test_user@localhost \d.\d+s\n/ to === " ✔ 01 user@localhost 0.003s\n". So the Like this: robd@2599b1c |
... and for Windows compatibility.
A command like `[ -f ~ ]` doesn't work on Windows, so use a more basic `echo`.
@robd Thanks again for the detailed feedback. I've rebuilt this PR from scratch with cleaned-up commits, and incorporated the changes you suggested. Specifically:
I think this is now ready to merge, if you agree! |
@mattbrictson Sorry for the delay here. I just looked through the latest changes and this looks good to me. |
Changes to allow `rake test` to work on Windows; set up Windows-based CI
This PR makes the airbrussh tests work on Windows and sets up a Windows-based CI. The build status can be found here: https://ci.appveyor.com/project/mattbrictson/airbrussh
Getting airbrussh's tests to execute on Windows was a bit of a challenge, mainly due to the acceptance tests assuming a UNIX-like environment. I had to make the following fixes:
$stdout.tty?
returns false in that environment. This had the effect of disabling color in thePretty
log file output. I worked around this by settingSSHKIT_COLOR=1
during the tests to force color output./usr/bin/env
on Windows, which by default SSHKit prepends to every command. To fix this, I faked the SSHKit command map to never prefix commands.Env.getpwuid
(used bySSHKit::Host
) doesn't work on Windows. I stubbed it.[ -f ~ ]
is not understood shell syntax on Windows. I replaced it withecho
.All tests now pass on both Travis and AppVeyor.
@robd In your opinion have a mangled the acceptance tests with these changes? I am particularly worried that by using the
SSHKIT_COLOR=1
and command map faking that the tests have diverged slightly from the typical SSHKit configuration, and therefore the tests are now of lower quality.Windows compatibility is not a high priority, so if the acceptance tests have been compromised as a result of my changes, perhaps it is not worth merging this. Let me know what you think.