Properly handle missing "." in alternate conditions
This commit is contained in:
parent
4ea3ed9e2a
commit
6d5467951a
3 changed files with 6 additions and 2 deletions
|
@ -100,7 +100,8 @@ def test_alt_conditions(
|
|||
|
||||
|
||||
@pytest.mark.usefixtures('ds1_copy')
|
||||
@pytest.mark.parametrize('kind', ['builtin', '', 'envtpl', 'j2cli', 'j2'])
|
||||
@pytest.mark.parametrize(
|
||||
'kind', ['builtin', '', None, 'envtpl', 'j2cli', 'j2'])
|
||||
@pytest.mark.parametrize('label', ['t', 'template', 'yadm', ])
|
||||
def test_alt_templates(
|
||||
runner, paths, kind, label):
|
||||
|
@ -108,6 +109,8 @@ def test_alt_templates(
|
|||
yadm_dir = setup_standard_yadm_dir(paths)
|
||||
|
||||
suffix = f'##{label}.{kind}'
|
||||
if kind is None:
|
||||
suffix = f'##{label}'
|
||||
utils.create_alt_files(paths, suffix)
|
||||
run = runner([paths.pgm, '-Y', yadm_dir, 'alt'])
|
||||
assert run.success
|
||||
|
|
|
@ -59,7 +59,7 @@ def create_alt_files(paths, suffix,
|
|||
# Do not test directory support for jinja alternates
|
||||
test_paths = [new_file1, new_file2]
|
||||
test_names = [ALT_FILE1, ALT_FILE2]
|
||||
if not re.match(r'##(t|template|yadm)\.', suffix):
|
||||
if not re.match(r'##(t$|t\.|template|yadm)', suffix):
|
||||
test_paths += [new_dir]
|
||||
test_names += [ALT_DIR]
|
||||
|
||||
|
|
1
yadm
1
yadm
|
@ -148,6 +148,7 @@ function score_file() {
|
|||
for field in "${fields[@]}"; do
|
||||
label=${field%%.*}
|
||||
value=${field#*.}
|
||||
[ "$field" = "$label" ] && value="" # when .value is omitted
|
||||
score=$((score + 1000))
|
||||
# default condition
|
||||
if [[ "$label" =~ ^(default)$ ]]; then
|
||||
|
|
Loading…
Reference in a new issue