Skip to content

Commit 70fe1fd

Browse files
committed
test: v8 and v9 support [#209]
1 parent 5a301ff commit 70fe1fd

File tree

3 files changed

+76
-10
lines changed

3 files changed

+76
-10
lines changed

snakefmt/parser/grammar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class SnakeGlobal(Vocabulary):
109109
outputflags=Context(None, NoKeyParamList),
110110
module=Context(SnakeModule, KeywordSyntax),
111111
use=Context(SnakeUseRule, KeywordSyntax),
112-
resource_scopes=Context(None, KeywordSyntax),
112+
resource_scopes=Context(None, ParamList),
113113
conda=Context(None, InlineSingleParam),
114114
storage=Context(None, ParamList),
115115
pathvars=Context(None, ParamList),

tests/test_v8_v9_features.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
from snakefmt.formatter import TAB
2+
from tests import setup_formatter
3+
4+
5+
class TestSnakemakeV8V9Features:
6+
def test_global_conda_directive(self):
7+
"""Test for issue #209: Global conda directive"""
8+
setup_formatter('conda: "envs/global.yaml"')
9+
setup_formatter('conda:\n "envs/global.yaml"')
10+
11+
def test_module_directive(self):
12+
snake = (
13+
"module other:\n"
14+
f'{TAB}snakefile: "other.smk"\n'
15+
f"{TAB}config: config\n"
16+
f'{TAB}meta_wrapper: "meta"\n'
17+
)
18+
setup_formatter(snake)
19+
20+
def test_use_rule_with_block(self):
21+
snake = (
22+
"use rule * from other as other_* with:\n"
23+
f'{TAB}conda: "envs/other.yaml"\n'
24+
f"{TAB}threads: 4\n"
25+
f"{TAB}resources:\n"
26+
f"{TAB}{TAB}mem_mb=1000\n"
27+
)
28+
setup_formatter(snake)
29+
30+
def test_storage_directive(self):
31+
snake = "storage:\n" f'{TAB}provider="s3",\n' f"{TAB}retries=3\n"
32+
setup_formatter(snake)
33+
34+
def test_resource_scopes_directive(self):
35+
snake = "resource_scopes:\n" f'{TAB}mem_mb="global"\n'
36+
setup_formatter(snake)
37+
38+
def test_new_rule_properties(self):
39+
snake = (
40+
"rule a:\n"
41+
f'{TAB}output: "a"\n'
42+
f"{TAB}retries: 3\n"
43+
f"{TAB}handover: True\n"
44+
f"{TAB}default_target: True\n"
45+
f"{TAB}localrule: True\n"
46+
f"{TAB}cache: True\n"
47+
)
48+
setup_formatter(snake)
49+
50+
def test_input_output_flags(self):
51+
# inputflags and outputflags take no key parameters (NoKeyParamList)
52+
snake = "inputflags:\n" f'{TAB}"flag1", "flag2"\n'
53+
setup_formatter(snake)
54+
55+
def test_pathvars_directive(self):
56+
# pathvars is in SnakeGlobal
57+
snake = "pathvars:\n" f'{TAB}var1="path/to/1"\n'
58+
setup_formatter(snake)

uv.lock

Lines changed: 17 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)