Improve testability of the Real
interpreter
#300
Merged
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.
There is an issue in how we test actions. Fundamentally, we rely on the fact that the
Real
runner is generatinggit
calls correctly. This could be neglected in theory, but there is another issue, which forces us to generate "textual" representation of what our command is doing, in multiple places, which leads to code repetition.As a solution to this, I've created 1 data type for every type of the command we can execute, and implemeted the way to render it to the "textual" representation.
This could be used by
Real
runner directly, but this still suffers from a different issue. We giveReal
runner to much access, by addingMonadIO
to the context.There is a solution however. We can create a custom
Monad
which can provide all needed functions forReal
to proceed. Going this way, we can hide how we "render" and "execute" git calls from theReal
runner, which implies that it has no way to run arbitrary commands at all.Values to
git config
should be quoted to work properly, otherwise they(specifically aliases) would be set as multi-value configs.
However, if we just blindly change this to be quoted values, we would
split them into separate arguments for a proc, which would lead to the
same issue.
To improve this, we just need to use
[]
instead ofText
for commandargs.
Note: I've switched to "raw strings" (
[s|quoted "string"|]
) inAcquireRepositorySpec.hs
to remove escaping of double quotes.#299
The contribution:
CONTRIBUTING.md > Committing the changes
rulesREADME.md > Hands-on development notes
@bees-hive/elegant-git-maintainers, please review.