Refactor tests for Git::Lib methods #read_tree, #write_tree, and #commit_tree #679
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Checklist
🚨Please review the guidelines for contributing to this repository.
Description
Refactor tests in test/units/test_tree_ops.rb for Git::Lib#read_tree, write_tree, and commit_tree.
This is to fix these tests from failing on JRuby on Windows for PR #673 after some changes were made to remove calls to
Dir.chdir
. I believe the tests were failing due to how temporary directories were created and doing that in JRuby on Windows caused git to error out.The refactor consists of limiting the tests to make sure that when the previously mentioned Git::Lib methods are called, that git is called with the right arguments without actually running git. In other words, the tests test this lib and not git itself or edge cases of the platform it is running on.
I have left the original tests in the code, commented out as an example of how these methods might be used.
Also, in writing these tests, I found that when Git::Lib#commit_tree is called with an array of commit SHAs for the
parents
argument, the command line was constructed incorrectly. This PR fixes that behavior.After this PR is merged to master, PR #673 should be rebased with master and its tests should pass which should make it ready for review and merge.