-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Added tests for utils/svn #2950
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
Conversation
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.
You shouldn't use instance variables to describe a test, since this doesn't really explain what it is supposed to do.
|
Some test failures: |
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.
Is this test performing network access?
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.
Yes, it is performing network access. Do you think I should add a local repo instead?
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.
As we discussed on Slack - preferably, it'd be good to use a local repo here. If something has to use the network and we don't have another option, it'll need the :needs_network tag so that it only gets run with brew tests --online.
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.
The tests are behaving weirdly on my system. In the first run, only 1 test case fails, in the second 3 tests cases fail. I can kind of see this pattern here. Could you please try running the tests on your system and let me know what happens, @mistydemeo ?
|
@apjanke Why was this PR closed? |
|
I have no idea! I think I accidentally hit the wrong button on GitHub. Please ignore. |
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.
Shouldn't need mktmpdir here; this is already in a temporary directory.
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.
This won't be run if the expectation fails.
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.
I've added a begin ... ensure block to take care of this now.
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.
This will not reset the variable after the test, can you find a way to test the functionality that actually sets this to true? Otherwise, the only thing this is testing is whether svn_available? uses this variable.
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.
Or alternatively: call a method that calls this so it's covered but not by a unit test.
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.
This variable will be set only if svn_available? has been called successfully atleast once. So, there is no method which can ensure @svn will already exist if svn is not available on the system.
I'm removing @svn before each test now. I don't think svn_version already set can work without setting @svn because on a system without svn, this test won't work the way it should.
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.
I think it may be worth allowing the svn shim to be called. What fails if it is?
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.
I think it may be worth allowing the svn shim to be called. What fails if it is?
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.
On some systems it might be successful and on some it might not be. So, I can just check that quiet_system will return either true, nil or false if svn shim is called.
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.
On any macOS system there will always be a working svn and git so let's assume that during the tests, too, thanks.
5fb5025 to
f659a03
Compare
mistydemeo
left a comment
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.
Left one comment, but otherwise looks good to me.
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.
Isn't this test just doing the same thing as the previous one?
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.
True. I guess I should remove it. I've removed such similar tests in git tests as well. Thanks :)
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.
Need to try and figure out a way to not set/get instance variables here. If need be: delete the relevant tests that need them set given we're almost at the end of GSoC. Ideally: just call other methods that end up calling these ones.
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.
Here, I'm trying to remove the instance variable if already set because once svn_available? is called, it will set the @svn instance variable. To make these tests independent of each other, I need to ensure that the instance variable is not set beforehand. What do you suggest in this case?
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.
Perhaps adding a new method clear_svn_location_cache or similar and call that in the before.
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.
Thanks for the suggestion! :)
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.
Why does this need to use mktmpdir and not write to an already existing location that's deleted after tests: for example:
brew/Library/Homebrew/test/spec_helper.rb
Lines 110 to 129 in 2c43e06
| FileUtils.rm_rf [ | |
| TEST_DIRECTORIES.map(&:children), | |
| HOMEBREW_LINKED_KEGS, | |
| HOMEBREW_PINNED_KEGS, | |
| HOMEBREW_PREFIX/".git", | |
| HOMEBREW_PREFIX/"bin", | |
| HOMEBREW_PREFIX/"share", | |
| HOMEBREW_PREFIX/"opt", | |
| HOMEBREW_PREFIX/"Caskroom", | |
| HOMEBREW_LIBRARY/"Taps/caskroom", | |
| HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-bar", | |
| HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-bundle", | |
| HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-foo", | |
| HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-services", | |
| HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-shallow", | |
| HOMEBREW_REPOSITORY/".git", | |
| CoreTap.instance.path/".git", | |
| CoreTap.instance.alias_dir, | |
| CoreTap.instance.path/"formula_renames.json", | |
| ] |
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.
It's also really confusing to have a directory named url. Instead just use HOMEBREW_CACHE and no let.
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.
Got it. It's better to use a location that is already deleted after tests. Thanks!
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.
Consider using https://github.com/Homebrew/install as it's really small and we control it (you can clone GitHub repositories as Subversion repositories).
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.
Using the above url, I'm getting the following:
Error validating server certificate for 'https://github.com:443':
- The certificate is not issued by a trusted authority. Use the
fingerprint to validate the certificate manually!
Certificate information:
- Hostname: github.com
- Valid: from Mar 10 00:00:00 2016 GMT until May 17 12:00:00 2018 GMT
- Issuer: DigiCert SHA2 Extended Validation Server CA, www.digicert.com, DigiCert Inc, US
- Fingerprint: D7:9F:07:61:10:B3:92:93:E3:49:AC:89:84:5B:03:80:C1:9E:2F:8B
(R)eject, accept (t)emporarily or accept (p)ermanently?
In the tests, how do I ensure that I don't need to manually answer the above posed question of accepting the host?
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.
HOMEBREW_CACHE.cd { system ... }
Library/Homebrew/utils/svn.rb
Outdated
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.
This is never needed, except in tests, so this shouldn‘t exist in the actual 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.
@reitermarkus I'm not sure how this gets resolved without adding a method here. What would you propose?
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.
How about adding a method in one of the support modules for tests to clear any instance variable? As in a method whose argument is the instance variable to be cleared. @MikeMcQuaid @reitermarkus @mistydemeo
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.
@mansimarkaur If by support modules you mean in the spec_helper or something then: yeh, that could work. @reitermarkus?
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.
Also, there's probably some times this method should be called anyway such as e.g. after a new installation of svn (and same thing for git)
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.
@MikeMcQuaid Yes, I meant adding a method in the spec_helper but if we want to call this cache clear method after a new installation, then we don't need to add it in the spec_helper. Which is a better alternative? Also, utils/git.rb already has a Utils.clear_git_available_cache to remove @git, @git_path and @git_version: https://github.com/Homebrew/brew/blob/master/Library/Homebrew/utils/git.rb#L66
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.
@mansimarkaur I think this is fine as-is, then, thanks.
|
There is something wrong with codecov. The base coverage is missing. Could you please help? |
mistydemeo
left a comment
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.
This looks good to me. Could you get the commit history ready for merging?
97565f3 to
dfe7338
Compare
Requested changes have been made
MikeMcQuaid
left a comment
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.
One tweak required otherwise 👍
Library/Homebrew/dev-cmd/audit.rb
Outdated
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.
Actually: this shouldn't be a problem because it's not an issue with the formula that's being audited. Instead I'd just do next unless Utils.svn_available?
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.
Got it! Made the change. Thanks :)
|
Thanks! |
|
Thanks for this @mansimarkaur, nice work! |
brew testswith your changes locally?