66 'labels' : ['default' ],
77 'modifier' : 0 ,
88 },
9+ 'arch' : {
10+ 'labels' : ['a' , 'arch' ],
11+ 'modifier' : 1 ,
12+ },
913 'system' : {
1014 'labels' : ['o' , 'os' ],
11- 'modifier' : 1 ,
15+ 'modifier' : 2 ,
1216 },
1317 'distro' : {
1418 'labels' : ['d' , 'distro' ],
15- 'modifier' : 2 ,
19+ 'modifier' : 4 ,
20+ },
21+ 'distro_family' : {
22+ 'labels' : ['f' , 'distro_family' ],
23+ 'modifier' : 8 ,
1624 },
1725 'class' : {
1826 'labels' : ['c' , 'class' ],
19- 'modifier' : 4 ,
27+ 'modifier' : 16 ,
2028 },
2129 'hostname' : {
2230 'labels' : ['h' , 'hostname' ],
23- 'modifier' : 8 ,
31+ 'modifier' : 32 ,
2432 },
2533 'user' : {
2634 'labels' : ['u' , 'user' ],
27- 'modifier' : 16 ,
35+ 'modifier' : 64 ,
2836 },
2937 }
3038TEMPLATE_LABELS = ['t' , 'template' , 'yadm' ]
@@ -44,6 +52,12 @@ def calculate_score(filename):
4452 label , value = condition .split ('.' , 1 )
4553 if label in CONDITION ['default' ]['labels' ]:
4654 score += 1000
55+ elif label in CONDITION ['arch' ]['labels' ]:
56+ if value == 'testarch' :
57+ score += 1000 + CONDITION ['arch' ]['modifier' ]
58+ else :
59+ score = 0
60+ break
4761 elif label in CONDITION ['system' ]['labels' ]:
4862 if value == 'testsystem' :
4963 score += 1000 + CONDITION ['system' ]['modifier' ]
@@ -82,6 +96,8 @@ def calculate_score(filename):
8296
8397@pytest .mark .parametrize (
8498 'default' , ['default' , None ], ids = ['default' , 'no-default' ])
99+ @pytest .mark .parametrize (
100+ 'arch' , ['arch' , None ], ids = ['arch' , 'no-arch' ])
85101@pytest .mark .parametrize (
86102 'system' , ['system' , None ], ids = ['system' , 'no-system' ])
87103@pytest .mark .parametrize (
@@ -93,10 +109,11 @@ def calculate_score(filename):
93109@pytest .mark .parametrize (
94110 'user' , ['user' , None ], ids = ['user' , 'no-user' ])
95111def test_score_values (
96- runner , yadm , default , system , distro , cla , host , user ):
112+ runner , yadm , default , arch , system , distro , cla , host , user ):
97113 """Test score results"""
98114 # pylint: disable=too-many-branches
99115 local_class = 'testclass'
116+ local_arch = 'testarch'
100117 local_system = 'testsystem'
101118 local_distro = 'testdistro'
102119 local_host = 'testhost'
@@ -111,6 +128,18 @@ def test_score_values(
111128 newfile += ','
112129 newfile += label
113130 filenames [newfile ] = calculate_score (newfile )
131+ if arch :
132+ for filename in list (filenames ):
133+ for match in [True , False ]:
134+ for label in CONDITION [arch ]['labels' ]:
135+ newfile = filename
136+ if not newfile .endswith ('##' ):
137+ newfile += ','
138+ newfile += '.' .join ([
139+ label ,
140+ local_arch if match else 'badarch'
141+ ])
142+ filenames [newfile ] = calculate_score (newfile )
114143 if system :
115144 for filename in list (filenames ):
116145 for match in [True , False ]:
@@ -176,6 +205,8 @@ def test_score_values(
176205 YADM_TEST=1 source { yadm }
177206 score=0
178207 local_class={ local_class }
208+ local_classes=({ local_class } )
209+ local_arch={ local_arch }
179210 local_system={ local_system }
180211 local_distro={ local_distro }
181212 local_host={ local_host }
@@ -221,6 +252,7 @@ def test_extensions(runner, yadm, ext):
221252def test_score_values_templates (runner , yadm ):
222253 """Test score results"""
223254 local_class = 'testclass'
255+ local_arch = 'arch'
224256 local_system = 'testsystem'
225257 local_distro = 'testdistro'
226258 local_host = 'testhost'
@@ -239,6 +271,7 @@ def test_score_values_templates(runner, yadm):
239271 YADM_TEST=1 source { yadm }
240272 score=0
241273 local_class={ local_class }
274+ local_arch={ local_arch }
242275 local_system={ local_system }
243276 local_distro={ local_distro }
244277 local_host={ local_host }
0 commit comments