Make the bash_program()
helper in gix-testtools
more robust
#1864
+47
−12
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.
On Windows, since #1712,
gix-testtools
looks for abash
shell associated with Git for Windows, to run fixture scripts. This logic is broadly similar togix_path::env::shell()
(#1758), which it influenced (#1752 (comment)). But there are some differences, even beyondshell()
ingix-path
being forsh
andbash_program()
ingix-testtools
being forbash
. Some differences are stylistic, while others are behavioral.It seems to me that they should be more similar than they are, and that there are also some improvements that should be applied to both in the same way. The changes proposed for
shell()
in #1862 include some that make it more similar tobash_program()
, such as checking if the shell exists, as well as others such as preferring/
, which neithershell()
norbash_program()
yet do but which makes sense in both.This PR is the
gix-testtools
counterpart to thegix-path
changes in #1862. The topical similarity could justify including both in the same PR, but having separate feature branches is more flexible, and I think the effects are also independent. In addition, neither is ready, it is possible that one will be ready before the other, and I do not know which. Currently the changes in this PR are:gix_path::env::shell()
./
over\
in building the path tobash.exe
.bash.exe
in(git root)/usr/bin
instead of the shim in(git root)/bin
.All but the last of those changes are done together, while the last is in its own commit. See commit messages for more details and rationale. Some code is analogous to code proposed for
gix-path
in #1862 but less commented. More comments could be added, especially if this PR ends up being merged without #1862 being merged or looking like it would be merged soon after.All but the last of these changes also appear to be working fine on all tested systems. In contrast, using the non-shim
bash.exe
breaks at least one fixture and many tests when run locally on my Windows 10 development machine from PowerShell. The failing tests are not the ones introduced here, but preexisting tests that passed before, including when run in that environment. The failures appear to be due to errors in test fixture scripts. This situation is similar to the local failures currently blocking #1862 and I suspect the cause is the same. This is what I was referring to in #1758 (comment), and I'll try to give details of the failures (as an edit or comment here) soon.I suspect that, for the
sh.exe
andbash.exe
provided by Git for Windows, the shim behavior of addingbin
directories associated with Git for Windows to the front ofPATH
is necessary to prevent scripts run in those shells from invoking the wrong implementations of commands, where multiple implementations are available. But I have not determined for sure that this is the case, so this PR is not ready yet.If that is the case, then a possible solution could be to prefer the shims (both here and in #1862), though if the additional subprocess invocations inherent in doing so cause a performance problem, then the existing customization of the environment in both
gix-command
andgix-testtools
could potentially be extended. If that performance degradation is not excessive, then the ideal solution may be to prefer the shims but fall back to the non-shim versions, which would preserve compatibility with the Git for Windows SDK in scenarios where it currently works (the SDK does not have the shims, noted in #1761 (comment), as observed in #1758 (comment) and rechecked in #1758 (comment)).