@@ -14,18 +14,21 @@ def _test_r_parsing(
1414 hook_id ,
1515 expected_hook_expr = {},
1616 expected_args = {},
17+ config = {},
18+ expect_path_prefix = True ,
1719):
1820 repo_path = 'r_hooks_repo'
1921 path = make_repo (tempdir_factory , repo_path )
20- config = make_config_from_repo (path )
22+ config = config or make_config_from_repo (path )
2123 hook = _get_hook_no_install (config , store , hook_id )
2224 ret = r ._cmd_from_hook (hook )
2325 expected_cmd = 'Rscript'
2426 expected_opts = (
2527 '--no-save' , '--no-restore' , '--no-site-file' , '--no-environ' ,
2628 )
2729 expected_path = os .path .join (
28- hook .prefix .prefix_dir , '.' .join ([hook_id , 'R' ]),
30+ hook .prefix .prefix_dir if expect_path_prefix else '' ,
31+ f'{ hook_id } .R' ,
2932 )
3033 expected = (
3134 expected_cmd ,
@@ -102,3 +105,25 @@ def test_r_parsing_expr_non_Rscirpt(tempdir_factory, store):
102105
103106 msg = execinfo .value .args
104107 assert msg == ('entry must start with `Rscript`.' ,)
108+
109+
110+ def test_r_parsing_file_local (tempdir_factory , store ):
111+ path = 'path/to/script.R'
112+ hook_id = 'local-r'
113+ config = {
114+ 'repo' : 'local' ,
115+ 'hooks' : [{
116+ 'id' : hook_id ,
117+ 'name' : 'local-r' ,
118+ 'entry' : f'Rscript { path } ' ,
119+ 'language' : 'r' ,
120+ }],
121+ }
122+ _test_r_parsing (
123+ tempdir_factory ,
124+ store ,
125+ hook_id = hook_id ,
126+ expected_hook_expr = (path ,),
127+ config = config ,
128+ expect_path_prefix = False ,
129+ )
0 commit comments