Tests for the executables used as pre-commit hooks via entrypoint
in
.pre-commit-config.yaml
.
run_test(hook_name, file_name = hook_name, suffix = ".R",
error_msg = NULL, cmd_args = NULL, copy = NULL)
The name of the hook in bin/
.
The file to test in tests/in
(without extension).
The fuffix of file_name
.
An expected error message. If no error is expected, this
can be NULL
. In that case, the comparator
is applied.
More arguments passed to the file. Pre-commit handles it as described here.
A function thtat takes two paths as arguments: One to
a file after the hooks has been applied and one to a reference file. Only
used if error_msg
is not NULL
.
Two potential outcomes of a hooks are pass or fail. This is reflected on the level of the executable: Fail means the executable fails or the file is changed. Pass means the executable succeeds and the file is unchanged. We check if the executable passes as follows:
If we expect success (by setting error_msg
to NULL
), we make sure
nothing was written to sterr and the file content does not change.
If we expect failure, it can be due to changed file or due to failed
executable. To check for failed executalble, we set error_msg
to
the message we expect. To check changed file content, we set error_msg
to
NA
.