fix r local hooks

`language: r` acts more like `language: script` so we have to *not* append
the prefix when run with `repo: local`
This commit is contained in:
Anthony Sottile 2023-01-29 17:27:42 -05:00
parent 6eacdd440e
commit 420902f67c
12 changed files with 51 additions and 6 deletions

View file

@ -14,7 +14,12 @@ from testing.language_helpers import run_language
def test_r_parsing_file_no_opts_no_args(tmp_path):
cmd = r._cmd_from_hook(Prefix(str(tmp_path)), 'Rscript some-script.R', ())
cmd = r._cmd_from_hook(
Prefix(str(tmp_path)),
'Rscript some-script.R',
(),
is_local=False,
)
assert cmd == (
'Rscript',
'--no-save', '--no-restore', '--no-site-file', '--no-environ',
@ -38,6 +43,7 @@ def test_r_parsing_file_no_opts_args(tmp_path):
Prefix(str(tmp_path)),
'Rscript some-script.R',
('--no-cache',),
is_local=False,
)
assert cmd == (
'Rscript',
@ -48,7 +54,12 @@ def test_r_parsing_file_no_opts_args(tmp_path):
def test_r_parsing_expr_no_opts_no_args1(tmp_path):
cmd = r._cmd_from_hook(Prefix(str(tmp_path)), "Rscript -e '1+1'", ())
cmd = r._cmd_from_hook(
Prefix(str(tmp_path)),
"Rscript -e '1+1'",
(),
is_local=False,
)
assert cmd == (
'Rscript',
'--no-save', '--no-restore', '--no-site-file', '--no-environ',
@ -56,6 +67,20 @@ def test_r_parsing_expr_no_opts_no_args1(tmp_path):
)
def test_r_parsing_local_hook_path_is_not_expanded(tmp_path):
cmd = r._cmd_from_hook(
Prefix(str(tmp_path)),
'Rscript path/to/thing.R',
(),
is_local=True,
)
assert cmd == (
'Rscript',
'--no-save', '--no-restore', '--no-site-file', '--no-environ',
'path/to/thing.R',
)
def test_r_parsing_expr_no_opts_no_args2():
with pytest.raises(ValueError) as excinfo:
r._entry_validate(['Rscript', '-e', '1+1', '-e', 'letters'])