mirror of
https://github.com/TheLocehiliosan/yadm
synced 2026-03-02 03:49:29 +00:00
Merge pull request #304 from erijo/multiple-classes
This commit is contained in:
@@ -99,7 +99,9 @@ def test_alt_conditions(
|
||||
|
||||
# set the class
|
||||
tst_class = 'testclass'
|
||||
utils.set_local(paths, 'class', tst_class)
|
||||
utils.set_local(paths, 'class', tst_class + ".before")
|
||||
utils.set_local(paths, 'class', tst_class, add=True)
|
||||
utils.set_local(paths, 'class', tst_class + ".after", add=True)
|
||||
|
||||
suffix = string.Template(suffix).substitute(
|
||||
tst_arch=tst_arch,
|
||||
|
||||
@@ -205,6 +205,7 @@ def test_score_values(
|
||||
YADM_TEST=1 source {yadm}
|
||||
score=0
|
||||
local_class={local_class}
|
||||
local_classes=({local_class})
|
||||
local_arch={local_arch}
|
||||
local_system={local_system}
|
||||
local_distro={local_distro}
|
||||
|
||||
@@ -37,7 +37,10 @@ def test_set_local_alt_values(
|
||||
echo "user='$local_user'"
|
||||
"""
|
||||
|
||||
if override:
|
||||
if override == 'class':
|
||||
utils.set_local(paths, override, 'first')
|
||||
utils.set_local(paths, override, 'override', add=True)
|
||||
elif override:
|
||||
utils.set_local(paths, override, 'override')
|
||||
|
||||
run = runner(command=['bash'], inp=script)
|
||||
|
||||
@@ -5,6 +5,7 @@ FILE_MODE = 0o754
|
||||
|
||||
# these values are also testing the handling of bizarre characters
|
||||
LOCAL_CLASS = "default_Test+@-!^Class"
|
||||
LOCAL_CLASS2 = "default_Test+@-|^2nd_Class withSpace"
|
||||
LOCAL_ARCH = "default_Test+@-!^Arch"
|
||||
LOCAL_SYSTEM = "default_Test+@-!^System"
|
||||
LOCAL_HOST = "default_Test+@-!^Host"
|
||||
@@ -34,6 +35,9 @@ Multiple lines
|
||||
{{% else %}}
|
||||
Should not be included...
|
||||
{{% endif %}}
|
||||
{{% if yadm.class == "{LOCAL_CLASS2}" %}}
|
||||
Included section for second class
|
||||
{{% endif %}}
|
||||
{{% if yadm.class == "wrongclass2" %}}
|
||||
wrong class 2
|
||||
{{% endif %}}
|
||||
@@ -106,6 +110,7 @@ default distro_family = >{LOCAL_DISTRO_FAMILY}<
|
||||
Included section from else
|
||||
Included section for class = {LOCAL_CLASS} ({LOCAL_CLASS} repeated)
|
||||
Multiple lines
|
||||
Included section for second class
|
||||
Included section for arch = {LOCAL_ARCH} ({LOCAL_ARCH} repeated)
|
||||
Included section for os = {LOCAL_SYSTEM} ({LOCAL_SYSTEM} repeated)
|
||||
Included section for host = {LOCAL_HOST} ({LOCAL_HOST} again)
|
||||
@@ -165,6 +170,7 @@ def test_template_default(runner, yadm, tmpdir):
|
||||
YADM_TEST=1 source {yadm}
|
||||
set_awk
|
||||
local_class="{LOCAL_CLASS}"
|
||||
local_classes=("{LOCAL_CLASS2}" "{LOCAL_CLASS}")
|
||||
local_arch="{LOCAL_ARCH}"
|
||||
local_system="{LOCAL_SYSTEM}"
|
||||
local_host="{LOCAL_HOST}"
|
||||
|
||||
@@ -4,6 +4,7 @@ import os
|
||||
FILE_MODE = 0o754
|
||||
|
||||
LOCAL_CLASS = "esh_Test+@-!^Class"
|
||||
LOCAL_CLASS2 = "esh_Test+@-|^2nd_Class withSpace"
|
||||
LOCAL_ARCH = "esh_Test+@-!^Arch"
|
||||
LOCAL_SYSTEM = "esh_Test+@-!^System"
|
||||
LOCAL_HOST = "esh_Test+@-!^Host"
|
||||
@@ -28,6 +29,10 @@ Included esh section for class = <%=$YADM_CLASS%> (<%=$YADM_CLASS%> repeated)
|
||||
<% if [ "$YADM_CLASS" = "wrongclass2" ]; then -%>
|
||||
wrong class 2
|
||||
<% fi -%>
|
||||
<% echo "$YADM_CLASSES" | while IFS='' read cls; do
|
||||
if [ "$cls" = "{LOCAL_CLASS2}" ]; then -%>
|
||||
Included esh section for second class
|
||||
<% fi; done -%>
|
||||
<% if [ "$YADM_ARCH" = "wrongarch1" ]; then -%>
|
||||
wrong arch 1
|
||||
<% fi -%>
|
||||
@@ -95,6 +100,7 @@ esh user = >{LOCAL_USER}<
|
||||
esh distro = >{LOCAL_DISTRO}<
|
||||
esh distro_family = >{LOCAL_DISTRO_FAMILY}<
|
||||
Included esh section for class = {LOCAL_CLASS} ({LOCAL_CLASS} repeated)
|
||||
Included esh section for second class
|
||||
Included esh section for arch = {LOCAL_ARCH} ({LOCAL_ARCH} repeated)
|
||||
Included esh section for os = {LOCAL_SYSTEM} ({LOCAL_SYSTEM} repeated)
|
||||
Included esh section for host = {LOCAL_HOST} ({LOCAL_HOST} again)
|
||||
@@ -123,6 +129,7 @@ def test_template_esh(runner, yadm, tmpdir):
|
||||
script = f"""
|
||||
YADM_TEST=1 source {yadm}
|
||||
local_class="{LOCAL_CLASS}"
|
||||
local_classes=("{LOCAL_CLASS2}" "{LOCAL_CLASS}")
|
||||
local_arch="{LOCAL_ARCH}"
|
||||
local_system="{LOCAL_SYSTEM}"
|
||||
local_host="{LOCAL_HOST}"
|
||||
|
||||
@@ -5,6 +5,7 @@ import pytest
|
||||
FILE_MODE = 0o754
|
||||
|
||||
LOCAL_CLASS = "j2_Test+@-!^Class"
|
||||
LOCAL_CLASS2 = "j2_Test+@-|^2nd_Class withSpace"
|
||||
LOCAL_ARCH = "j2_Test+@-!^Arch"
|
||||
LOCAL_SYSTEM = "j2_Test+@-!^System"
|
||||
LOCAL_HOST = "j2_Test+@-!^Host"
|
||||
@@ -30,6 +31,9 @@ Included j2 section for class = \
|
||||
{{%- if YADM_CLASS == "wrongclass2" %}}
|
||||
wrong class 2
|
||||
{{%- endif %}}
|
||||
{{%- if "{LOCAL_CLASS2}" in YADM_CLASSES.split("\\n") %}}
|
||||
Included j2 section for second class
|
||||
{{%- endif %}}
|
||||
{{%- if YADM_ARCH == "wrongarch1" %}}
|
||||
wrong arch 1
|
||||
{{%- endif %}}
|
||||
@@ -99,6 +103,7 @@ j2 user = >{LOCAL_USER}<
|
||||
j2 distro = >{LOCAL_DISTRO}<
|
||||
j2 distro_family = >{LOCAL_DISTRO_FAMILY}<
|
||||
Included j2 section for class = {LOCAL_CLASS} ({LOCAL_CLASS} repeated)
|
||||
Included j2 section for second class
|
||||
Included j2 section for arch = {LOCAL_ARCH} ({LOCAL_ARCH} repeated)
|
||||
Included j2 section for os = {LOCAL_SYSTEM} ({LOCAL_SYSTEM} repeated)
|
||||
Included j2 section for host = {LOCAL_HOST} ({LOCAL_HOST} again)
|
||||
@@ -128,6 +133,7 @@ def test_template_j2(runner, yadm, tmpdir, processor):
|
||||
script = f"""
|
||||
YADM_TEST=1 source {yadm}
|
||||
local_class="{LOCAL_CLASS}"
|
||||
local_classes=("{LOCAL_CLASS2}" "{LOCAL_CLASS}")
|
||||
local_arch="{LOCAL_ARCH}"
|
||||
local_system="{LOCAL_SYSTEM}"
|
||||
local_host="{LOCAL_HOST}"
|
||||
|
||||
@@ -21,11 +21,12 @@ INCLUDE_DIRS = ['', 'test alt']
|
||||
INCLUDE_CONTENT = '8780846c02e34c930d0afd127906668f'
|
||||
|
||||
|
||||
def set_local(paths, variable, value):
|
||||
def set_local(paths, variable, value, add=False):
|
||||
"""Set local override"""
|
||||
add = "--add" if add else ""
|
||||
os.system(
|
||||
f'GIT_DIR={str(paths.repo)} '
|
||||
f'git config --local "local.{variable}" "{value}"'
|
||||
f'git config --local {add} "local.{variable}" "{value}"'
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user