summaryrefslogtreecommitdiff
path: root/tests/format
diff options
context:
space:
mode:
authorChandan Singh <csingh43@bloomberg.net>2019-11-11 17:07:09 +0000
committerChandan Singh <chandan@chandansingh.net>2019-11-14 21:21:06 +0000
commit122177153b14664a0e4fed85aa4f22b87cfabf56 (patch)
tree032c2e46825af91f6fe27f22b5b567eea2b7935d /tests/format
parenta3ee349558f36a220f79665873b36c1b0f990c8e (diff)
downloadbuildstream-122177153b14664a0e4fed85aa4f22b87cfabf56.tar.gz
Reformat code using Black
As discussed over the mailing list, reformat code using Black. This is a one-off change to reformat all our codebase. Moving forward, we shouldn't expect such blanket reformats. Rather, we expect each change to already comply with the Black formatting style.
Diffstat (limited to 'tests/format')
-rw-r--r--tests/format/assertion.py49
-rw-r--r--tests/format/dependencies.py164
-rw-r--r--tests/format/include.py265
-rw-r--r--tests/format/include_composition.py101
-rw-r--r--tests/format/invalid_keys.py20
-rw-r--r--tests/format/junctions.py301
-rw-r--r--tests/format/listdirectiveerrors.py32
-rw-r--r--tests/format/optionarch.py88
-rw-r--r--tests/format/optionbool.py121
-rw-r--r--tests/format/optioneltmask.py82
-rw-r--r--tests/format/optionenum.py128
-rw-r--r--tests/format/optionexports.py41
-rw-r--r--tests/format/optionflags.py148
-rw-r--r--tests/format/optionos.py53
-rw-r--r--tests/format/optionoverrides.py17
-rw-r--r--tests/format/options.py281
-rw-r--r--tests/format/project.py161
-rw-r--r--tests/format/project/plugin-no-load-ref/plugins/noloadref.py1
-rw-r--r--tests/format/project/plugin-preflight-error/errorplugin/preflighterror.py4
-rw-r--r--tests/format/projectoverrides.py17
-rw-r--r--tests/format/userconfig.py6
-rw-r--r--tests/format/variables.py189
22 files changed, 993 insertions, 1276 deletions
diff --git a/tests/format/assertion.py b/tests/format/assertion.py
index 7e87977cb..67436250a 100644
--- a/tests/format/assertion.py
+++ b/tests/format/assertion.py
@@ -7,30 +7,41 @@ from buildstream._exceptions import ErrorDomain, LoadErrorReason
from buildstream.testing.runcli import cli # pylint: disable=unused-import
# Project directory
-DATA_DIR = os.path.join(
- os.path.dirname(os.path.realpath(__file__)),
- 'assertion'
-)
+DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "assertion")
@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize("target,opt_pony,opt_horsy,assertion", [
- # Test an unconditional (!) directly in the element
- ('raw-assertion.bst', 'False', 'False', 'Raw assertion boogey'),
- # Test an assertion in a conditional
- ('conditional-assertion.bst', 'True', 'False', "It's not pony time yet"),
- # Test that we get the first composited assertion
- ('ordered-assertion.bst', 'True', 'True', "It's not horsy time yet"),
-])
+@pytest.mark.parametrize(
+ "target,opt_pony,opt_horsy,assertion",
+ [
+ # Test an unconditional (!) directly in the element
+ ("raw-assertion.bst", "False", "False", "Raw assertion boogey"),
+ # Test an assertion in a conditional
+ ("conditional-assertion.bst", "True", "False", "It's not pony time yet"),
+ # Test that we get the first composited assertion
+ ("ordered-assertion.bst", "True", "True", "It's not horsy time yet"),
+ ],
+)
def test_assertion_cli(cli, datafiles, target, opt_pony, opt_horsy, assertion):
project = str(datafiles)
- result = cli.run(project=project, silent=True, args=[
- '--option', 'pony', opt_pony,
- '--option', 'horsy', opt_horsy,
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- target])
+ result = cli.run(
+ project=project,
+ silent=True,
+ args=[
+ "--option",
+ "pony",
+ opt_pony,
+ "--option",
+ "horsy",
+ opt_horsy,
+ "show",
+ "--deps",
+ "none",
+ "--format",
+ "%{vars}",
+ target,
+ ],
+ )
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.USER_ASSERTION)
# Assert that the assertion text provided by the user
diff --git a/tests/format/dependencies.py b/tests/format/dependencies.py
index f92b89afa..e54b9b2d5 100644
--- a/tests/format/dependencies.py
+++ b/tests/format/dependencies.py
@@ -15,125 +15,125 @@ DATA_DIR = os.path.dirname(os.path.realpath(__file__))
#
@pytest.mark.datafiles(DATA_DIR)
def test_two_files(cli, datafiles):
- project = os.path.join(str(datafiles), 'dependencies1')
+ project = os.path.join(str(datafiles), "dependencies1")
- elements = cli.get_pipeline(project, ['target.bst'])
- assert elements == ['firstdep.bst', 'target.bst']
+ elements = cli.get_pipeline(project, ["target.bst"])
+ assert elements == ["firstdep.bst", "target.bst"]
@pytest.mark.datafiles(DATA_DIR)
def test_shared_dependency(cli, datafiles):
- project = os.path.join(str(datafiles), 'dependencies1')
+ project = os.path.join(str(datafiles), "dependencies1")
- elements = cli.get_pipeline(project, ['shareddeptarget.bst'])
- assert elements == ['firstdep.bst', 'shareddep.bst', 'shareddeptarget.bst']
+ elements = cli.get_pipeline(project, ["shareddeptarget.bst"])
+ assert elements == ["firstdep.bst", "shareddep.bst", "shareddeptarget.bst"]
@pytest.mark.datafiles(DATA_DIR)
def test_dependency_dict(cli, datafiles):
- project = os.path.join(str(datafiles), 'dependencies1')
- elements = cli.get_pipeline(project, ['target-depdict.bst'])
- assert elements == ['firstdep.bst', 'target-depdict.bst']
+ project = os.path.join(str(datafiles), "dependencies1")
+ elements = cli.get_pipeline(project, ["target-depdict.bst"])
+ assert elements == ["firstdep.bst", "target-depdict.bst"]
@pytest.mark.datafiles(DATA_DIR)
def test_invalid_dependency_declaration(cli, datafiles):
- project = os.path.join(str(datafiles), 'dependencies1')
- result = cli.run(project=project, args=['show', 'invaliddep.bst'])
+ project = os.path.join(str(datafiles), "dependencies1")
+ result = cli.run(project=project, args=["show", "invaliddep.bst"])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
@pytest.mark.datafiles(DATA_DIR)
def test_invalid_dependency_type(cli, datafiles):
- project = os.path.join(str(datafiles), 'dependencies1')
- result = cli.run(project=project, args=['show', 'invaliddeptype.bst'])
+ project = os.path.join(str(datafiles), "dependencies1")
+ result = cli.run(project=project, args=["show", "invaliddeptype.bst"])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
@pytest.mark.datafiles(DATA_DIR)
def test_invalid_strict_dependency(cli, datafiles):
- project = os.path.join(str(datafiles), 'dependencies1')
- result = cli.run(project=project, args=['show', 'invalidstrict.bst'])
+ project = os.path.join(str(datafiles), "dependencies1")
+ result = cli.run(project=project, args=["show", "invalidstrict.bst"])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
@pytest.mark.datafiles(DATA_DIR)
def test_invalid_non_strict_dependency(cli, datafiles):
- project = os.path.join(str(datafiles), 'dependencies1')
- result = cli.run(project=project, args=['show', 'invalidnonstrict.bst'])
+ project = os.path.join(str(datafiles), "dependencies1")
+ result = cli.run(project=project, args=["show", "invalidnonstrict.bst"])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
@pytest.mark.datafiles(DATA_DIR)
def test_circular_dependency(cli, datafiles):
- project = os.path.join(str(datafiles), 'dependencies1')
- result = cli.run(project=project, args=['show', 'circulartarget.bst'])
+ project = os.path.join(str(datafiles), "dependencies1")
+ result = cli.run(project=project, args=["show", "circulartarget.bst"])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.CIRCULAR_DEPENDENCY)
@pytest.mark.datafiles(DATA_DIR)
def test_build_dependency(cli, datafiles):
- project = os.path.join(str(datafiles), 'dependencies1')
+ project = os.path.join(str(datafiles), "dependencies1")
- elements = cli.get_pipeline(project, ['builddep.bst'], scope='run')
- assert elements == ['builddep.bst']
+ elements = cli.get_pipeline(project, ["builddep.bst"], scope="run")
+ assert elements == ["builddep.bst"]
- elements = cli.get_pipeline(project, ['builddep.bst'], scope='build')
- assert elements == ['firstdep.bst']
+ elements = cli.get_pipeline(project, ["builddep.bst"], scope="build")
+ assert elements == ["firstdep.bst"]
@pytest.mark.datafiles(DATA_DIR)
def test_runtime_dependency(cli, datafiles):
- project = os.path.join(str(datafiles), 'dependencies1')
- elements = cli.get_pipeline(project, ['runtimedep.bst'], scope='build')
+ project = os.path.join(str(datafiles), "dependencies1")
+ elements = cli.get_pipeline(project, ["runtimedep.bst"], scope="build")
# FIXME: The empty line should probably never happen here when there are no results.
- assert elements == ['']
- elements = cli.get_pipeline(project, ['runtimedep.bst'], scope='run')
- assert elements == ['firstdep.bst', 'runtimedep.bst']
+ assert elements == [""]
+ elements = cli.get_pipeline(project, ["runtimedep.bst"], scope="run")
+ assert elements == ["firstdep.bst", "runtimedep.bst"]
@pytest.mark.datafiles(DATA_DIR)
def test_all_dependency(cli, datafiles):
- project = os.path.join(str(datafiles), 'dependencies1')
+ project = os.path.join(str(datafiles), "dependencies1")
- elements = cli.get_pipeline(project, ['alldep.bst'], scope='build')
- assert elements == ['firstdep.bst']
+ elements = cli.get_pipeline(project, ["alldep.bst"], scope="build")
+ assert elements == ["firstdep.bst"]
- elements = cli.get_pipeline(project, ['alldep.bst'], scope='run')
- assert elements == ['firstdep.bst', 'alldep.bst']
+ elements = cli.get_pipeline(project, ["alldep.bst"], scope="run")
+ assert elements == ["firstdep.bst", "alldep.bst"]
@pytest.mark.datafiles(DATA_DIR)
def test_list_build_dependency(cli, datafiles):
- project = os.path.join(str(datafiles), 'dependencies1')
+ project = os.path.join(str(datafiles), "dependencies1")
# Check that the pipeline includes the build dependency
- deps = cli.get_pipeline(project, ['builddep-list.bst'], scope="build")
+ deps = cli.get_pipeline(project, ["builddep-list.bst"], scope="build")
assert "firstdep.bst" in deps
@pytest.mark.datafiles(DATA_DIR)
def test_list_runtime_dependency(cli, datafiles):
- project = os.path.join(str(datafiles), 'dependencies1')
+ project = os.path.join(str(datafiles), "dependencies1")
# Check that the pipeline includes the runtime dependency
- deps = cli.get_pipeline(project, ['runtimedep-list.bst'], scope="run")
+ deps = cli.get_pipeline(project, ["runtimedep-list.bst"], scope="run")
assert "firstdep.bst" in deps
@pytest.mark.datafiles(DATA_DIR)
def test_list_dependencies_combined(cli, datafiles):
- project = os.path.join(str(datafiles), 'dependencies1')
+ project = os.path.join(str(datafiles), "dependencies1")
# Check that runtime deps get combined
- rundeps = cli.get_pipeline(project, ['list-combine.bst'], scope="run")
+ rundeps = cli.get_pipeline(project, ["list-combine.bst"], scope="run")
assert "firstdep.bst" not in rundeps
assert "seconddep.bst" in rundeps
assert "thirddep.bst" in rundeps
# Check that build deps get combined
- builddeps = cli.get_pipeline(project, ['list-combine.bst'], scope="build")
+ builddeps = cli.get_pipeline(project, ["list-combine.bst"], scope="build")
assert "firstdep.bst" in builddeps
assert "seconddep.bst" not in builddeps
assert "thirddep.bst" in builddeps
@@ -141,12 +141,12 @@ def test_list_dependencies_combined(cli, datafiles):
@pytest.mark.datafiles(DATA_DIR)
def test_list_overlap(cli, datafiles):
- project = os.path.join(str(datafiles), 'dependencies1')
+ project = os.path.join(str(datafiles), "dependencies1")
# Check that dependencies get merged
- rundeps = cli.get_pipeline(project, ['list-overlap.bst'], scope="run")
+ rundeps = cli.get_pipeline(project, ["list-overlap.bst"], scope="run")
assert "firstdep.bst" in rundeps
- builddeps = cli.get_pipeline(project, ['list-overlap.bst'], scope="build")
+ builddeps = cli.get_pipeline(project, ["list-overlap.bst"], scope="build")
assert "firstdep.bst" in builddeps
@@ -156,10 +156,10 @@ def test_list_overlap(cli, datafiles):
#
@pytest.mark.datafiles(DATA_DIR)
def test_scope_all(cli, datafiles):
- project = os.path.join(str(datafiles), 'dependencies2')
- elements = ['target.bst']
+ project = os.path.join(str(datafiles), "dependencies2")
+ elements = ["target.bst"]
- element_list = cli.get_pipeline(project, elements, scope='all')
+ element_list = cli.get_pipeline(project, elements, scope="all")
assert element_list == [
"build-build.bst",
@@ -174,10 +174,10 @@ def test_scope_all(cli, datafiles):
@pytest.mark.datafiles(DATA_DIR)
def test_scope_run(cli, datafiles):
- project = os.path.join(str(datafiles), 'dependencies2')
- elements = ['target.bst']
+ project = os.path.join(str(datafiles), "dependencies2")
+ elements = ["target.bst"]
- element_list = cli.get_pipeline(project, elements, scope='run')
+ element_list = cli.get_pipeline(project, elements, scope="run")
assert element_list == [
"dep-one.bst",
@@ -189,69 +189,71 @@ def test_scope_run(cli, datafiles):
@pytest.mark.datafiles(DATA_DIR)
def test_scope_build(cli, datafiles):
- project = os.path.join(str(datafiles), 'dependencies2')
- elements = ['target.bst']
+ project = os.path.join(str(datafiles), "dependencies2")
+ elements = ["target.bst"]
- element_list = cli.get_pipeline(project, elements, scope='build')
+ element_list = cli.get_pipeline(project, elements, scope="build")
assert element_list == ["dep-one.bst", "run.bst", "dep-two.bst"]
@pytest.mark.datafiles(DATA_DIR)
def test_scope_build_of_child(cli, datafiles):
- project = os.path.join(str(datafiles), 'dependencies2')
- elements = ['target.bst']
+ project = os.path.join(str(datafiles), "dependencies2")
+ elements = ["target.bst"]
- element_list = cli.get_pipeline(project, elements, scope='build')
+ element_list = cli.get_pipeline(project, elements, scope="build")
# First pass, lets check dep-two
element = element_list[2]
# Pass two, let's look at these
- element_list = cli.get_pipeline(project, [element], scope='build')
+ element_list = cli.get_pipeline(project, [element], scope="build")
assert element_list == ["run-build.bst", "build.bst"]
@pytest.mark.datafiles(DATA_DIR)
def test_no_recurse(cli, datafiles):
- project = os.path.join(str(datafiles), 'dependencies2')
- elements = ['target.bst']
+ project = os.path.join(str(datafiles), "dependencies2")
+ elements = ["target.bst"]
# We abuse the 'plan' scope here to ensure that we call
# element.dependencies() with recurse=False - currently, no `bst
# show` option does this directly.
- element_list = cli.get_pipeline(project, elements, scope='plan')
+ element_list = cli.get_pipeline(project, elements, scope="plan")
assert element_list == [
- 'build-build.bst',
- 'run-build.bst',
- 'build.bst',
- 'dep-one.bst',
- 'run.bst',
- 'dep-two.bst',
- 'target.bst',
+ "build-build.bst",
+ "run-build.bst",
+ "build.bst",
+ "dep-one.bst",
+ "run.bst",
+ "dep-two.bst",
+ "target.bst",
]
@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize(("element", "asserts"), [
- ('build-runtime', False),
- ('build-build', True),
- ('build-all', True),
- ('runtime-runtime', True),
- ('runtime-all', True),
- ('all-all', True),
-])
+@pytest.mark.parametrize(
+ ("element", "asserts"),
+ [
+ ("build-runtime", False),
+ ("build-build", True),
+ ("build-all", True),
+ ("runtime-runtime", True),
+ ("runtime-all", True),
+ ("all-all", True),
+ ],
+)
def test_duplicate_deps(cli, datafiles, element, asserts):
- project = os.path.join(str(datafiles), 'dependencies3')
+ project = os.path.join(str(datafiles), "dependencies3")
- result = cli.run(project=project, args=['show', '{}.bst'.format(element)])
+ result = cli.run(project=project, args=["show", "{}.bst".format(element)])
if asserts:
- result.assert_main_error(ErrorDomain.LOAD,
- LoadErrorReason.DUPLICATE_DEPENDENCY)
- assert '[line 10 column 2]' in result.stderr
- assert '[line 8 column 2]' in result.stderr
+ result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.DUPLICATE_DEPENDENCY)
+ assert "[line 10 column 2]" in result.stderr
+ assert "[line 8 column 2]" in result.stderr
else:
result.assert_success()
diff --git a/tests/format/include.py b/tests/format/include.py
index 434a94d1f..5efbc62a9 100644
--- a/tests/format/include.py
+++ b/tests/format/include.py
@@ -12,97 +12,90 @@ from tests.testutils import generate_junction
# Project directory
-DATA_DIR = os.path.join(
- os.path.dirname(os.path.realpath(__file__)),
- 'include'
-)
+DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "include")
@pytest.mark.datafiles(DATA_DIR)
def test_include_project_file(cli, datafiles):
- project = os.path.join(str(datafiles), 'file')
- result = cli.run(project=project, args=[
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'element.bst'])
+ project = os.path.join(str(datafiles), "file")
+ result = cli.run(project=project, args=["show", "--deps", "none", "--format", "%{vars}", "element.bst"])
result.assert_success()
loaded = _yaml.load_data(result.output)
- assert loaded.get_bool('included')
+ assert loaded.get_bool("included")
def test_include_missing_file(cli, tmpdir):
- tmpdir.join('project.conf').write('{"name": "test"}')
- element = tmpdir.join('include_missing_file.bst')
+ tmpdir.join("project.conf").write('{"name": "test"}')
+ element = tmpdir.join("include_missing_file.bst")
# Normally we would use dicts and _yaml.roundtrip_dump to write such things, but here
# we want to be sure of a stable line and column number.
- element.write(textwrap.dedent("""
+ element.write(
+ textwrap.dedent(
+ """
kind: manual
"(@)":
- nosuch.yaml
- """).strip())
+ """
+ ).strip()
+ )
- result = cli.run(project=str(tmpdir), args=['show', str(element.basename)])
+ result = cli.run(project=str(tmpdir), args=["show", str(element.basename)])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.MISSING_FILE)
# Make sure the root cause provenance is in the output.
- assert 'line 4 column 2' in result.stderr
+ assert "line 4 column 2" in result.stderr
def test_include_dir(cli, tmpdir):
- tmpdir.join('project.conf').write('{"name": "test"}')
- tmpdir.mkdir('subdir')
- element = tmpdir.join('include_dir.bst')
+ tmpdir.join("project.conf").write('{"name": "test"}')
+ tmpdir.mkdir("subdir")
+ element = tmpdir.join("include_dir.bst")
# Normally we would use dicts and _yaml.roundtrip_dump to write such things, but here
# we want to be sure of a stable line and column number.
- element.write(textwrap.dedent("""
+ element.write(
+ textwrap.dedent(
+ """
kind: manual
"(@)":
- subdir/
- """).strip())
+ """
+ ).strip()
+ )
- result = cli.run(project=str(tmpdir), args=['show', str(element.basename)])
- result.assert_main_error(
- ErrorDomain.LOAD, LoadErrorReason.LOADING_DIRECTORY)
+ result = cli.run(project=str(tmpdir), args=["show", str(element.basename)])
+ result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.LOADING_DIRECTORY)
# Make sure the root cause provenance is in the output.
- assert 'line 4 column 2' in result.stderr
+ assert "line 4 column 2" in result.stderr
@pytest.mark.datafiles(DATA_DIR)
def test_include_junction_file(cli, tmpdir, datafiles):
- project = os.path.join(str(datafiles), 'junction')
-
- generate_junction(tmpdir,
- os.path.join(project, 'subproject'),
- os.path.join(project, 'junction.bst'),
- store_ref=True)
-
- result = cli.run(project=project, args=[
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'element.bst'])
+ project = os.path.join(str(datafiles), "junction")
+
+ generate_junction(
+ tmpdir, os.path.join(project, "subproject"), os.path.join(project, "junction.bst"), store_ref=True
+ )
+
+ result = cli.run(project=project, args=["show", "--deps", "none", "--format", "%{vars}", "element.bst"])
result.assert_success()
loaded = _yaml.load_data(result.output)
- assert loaded.get_bool('included')
+ assert loaded.get_bool("included")
@pytest.mark.datafiles(DATA_DIR)
def test_include_junction_options(cli, datafiles):
- project = os.path.join(str(datafiles), 'options')
-
- result = cli.run(project=project, args=[
- '-o', 'build_arch', 'x86_64',
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'element.bst'])
+ project = os.path.join(str(datafiles), "options")
+
+ result = cli.run(
+ project=project,
+ args=["-o", "build_arch", "x86_64", "show", "--deps", "none", "--format", "%{vars}", "element.bst"],
+ )
result.assert_success()
loaded = _yaml.load_data(result.output)
- assert loaded.get_str('build_arch') == 'x86_64'
+ assert loaded.get_str("build_arch") == "x86_64"
@pytest.mark.datafiles(DATA_DIR)
@@ -111,31 +104,22 @@ def test_junction_element_partial_project_project(cli, tmpdir, datafiles):
Junction elements never depend on fully include processed project.
"""
- project = os.path.join(str(datafiles), 'junction')
+ project = os.path.join(str(datafiles), "junction")
- subproject_path = os.path.join(project, 'subproject')
- junction_path = os.path.join(project, 'junction.bst')
+ subproject_path = os.path.join(project, "subproject")
+ junction_path = os.path.join(project, "junction.bst")
- repo = create_repo('git', str(tmpdir))
+ repo = create_repo("git", str(tmpdir))
ref = repo.create(subproject_path)
- element = {
- 'kind': 'junction',
- 'sources': [
- repo.source_config(ref=ref)
- ]
- }
+ element = {"kind": "junction", "sources": [repo.source_config(ref=ref)]}
_yaml.roundtrip_dump(element, junction_path)
- result = cli.run(project=project, args=[
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'junction.bst'])
+ result = cli.run(project=project, args=["show", "--deps", "none", "--format", "%{vars}", "junction.bst"])
result.assert_success()
loaded = _yaml.load_data(result.output)
- assert loaded.get_str('included', default=None) is None
+ assert loaded.get_str("included", default=None) is None
@pytest.mark.datafiles(DATA_DIR)
@@ -144,170 +128,127 @@ def test_junction_element_not_partial_project_file(cli, tmpdir, datafiles):
Junction elements never depend on fully include processed project.
"""
- project = os.path.join(str(datafiles), 'file_with_subproject')
+ project = os.path.join(str(datafiles), "file_with_subproject")
- subproject_path = os.path.join(project, 'subproject')
- junction_path = os.path.join(project, 'junction.bst')
+ subproject_path = os.path.join(project, "subproject")
+ junction_path = os.path.join(project, "junction.bst")
- repo = create_repo('git', str(tmpdir))
+ repo = create_repo("git", str(tmpdir))
ref = repo.create(subproject_path)
- element = {
- 'kind': 'junction',
- 'sources': [
- repo.source_config(ref=ref)
- ]
- }
+ element = {"kind": "junction", "sources": [repo.source_config(ref=ref)]}
_yaml.roundtrip_dump(element, junction_path)
- result = cli.run(project=project, args=[
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'junction.bst'])
+ result = cli.run(project=project, args=["show", "--deps", "none", "--format", "%{vars}", "junction.bst"])
result.assert_success()
loaded = _yaml.load_data(result.output)
- assert loaded.get_str('included', default=None) is not None
+ assert loaded.get_str("included", default=None) is not None
@pytest.mark.datafiles(DATA_DIR)
def test_include_element_overrides(cli, datafiles):
- project = os.path.join(str(datafiles), 'overrides')
+ project = os.path.join(str(datafiles), "overrides")
- result = cli.run(project=project, args=[
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'element.bst'])
+ result = cli.run(project=project, args=["show", "--deps", "none", "--format", "%{vars}", "element.bst"])
result.assert_success()
loaded = _yaml.load_data(result.output)
- assert loaded.get_str('manual_main_override', default=None) is not None
- assert loaded.get_str('manual_included_override', default=None) is not None
+ assert loaded.get_str("manual_main_override", default=None) is not None
+ assert loaded.get_str("manual_included_override", default=None) is not None
@pytest.mark.datafiles(DATA_DIR)
def test_include_element_overrides_composition(cli, datafiles):
- project = os.path.join(str(datafiles), 'overrides')
+ project = os.path.join(str(datafiles), "overrides")
- result = cli.run(project=project, args=[
- 'show',
- '--deps', 'none',
- '--format', '%{config}',
- 'element.bst'])
+ result = cli.run(project=project, args=["show", "--deps", "none", "--format", "%{config}", "element.bst"])
result.assert_success()
loaded = _yaml.load_data(result.output)
- assert loaded.get_str_list('build-commands') == ['first', 'second']
+ assert loaded.get_str_list("build-commands") == ["first", "second"]
@pytest.mark.datafiles(DATA_DIR)
def test_list_overide_does_not_fail_upon_first_composition(cli, datafiles):
- project = os.path.join(str(datafiles), 'eventual_overrides')
+ project = os.path.join(str(datafiles), "eventual_overrides")
- result = cli.run(project=project, args=[
- 'show',
- '--deps', 'none',
- '--format', '%{public}',
- 'element.bst'])
+ result = cli.run(project=project, args=["show", "--deps", "none", "--format", "%{public}", "element.bst"])
result.assert_success()
loaded = _yaml.load_data(result.output)
# Assert that the explicitly overwritten public data is present
- bst = loaded.get_mapping('bst')
- assert 'foo-commands' in bst
- assert bst.get_str_list('foo-commands') == ['need', 'this']
+ bst = loaded.get_mapping("bst")
+ assert "foo-commands" in bst
+ assert bst.get_str_list("foo-commands") == ["need", "this"]
@pytest.mark.datafiles(DATA_DIR)
def test_include_element_overrides_sub_include(cli, datafiles):
- project = os.path.join(str(datafiles), 'sub-include')
+ project = os.path.join(str(datafiles), "sub-include")
- result = cli.run(project=project, args=[
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'element.bst'])
+ result = cli.run(project=project, args=["show", "--deps", "none", "--format", "%{vars}", "element.bst"])
result.assert_success()
loaded = _yaml.load_data(result.output)
- assert loaded.get_str('included', default=None) is not None
+ assert loaded.get_str("included", default=None) is not None
@pytest.mark.datafiles(DATA_DIR)
def test_junction_do_not_use_included_overrides(cli, tmpdir, datafiles):
- project = os.path.join(str(datafiles), 'overrides-junction')
-
- generate_junction(tmpdir,
- os.path.join(project, 'subproject'),
- os.path.join(project, 'junction.bst'),
- store_ref=True)
-
- result = cli.run(project=project, args=[
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'junction.bst'])
+ project = os.path.join(str(datafiles), "overrides-junction")
+
+ generate_junction(
+ tmpdir, os.path.join(project, "subproject"), os.path.join(project, "junction.bst"), store_ref=True
+ )
+
+ result = cli.run(project=project, args=["show", "--deps", "none", "--format", "%{vars}", "junction.bst"])
result.assert_success()
loaded = _yaml.load_data(result.output)
- assert loaded.get_str('main_override', default=None) is not None
- assert loaded.get_str('included_override', default=None) is None
+ assert loaded.get_str("main_override", default=None) is not None
+ assert loaded.get_str("included_override", default=None) is None
@pytest.mark.datafiles(DATA_DIR)
def test_conditional_in_fragment(cli, datafiles):
- project = os.path.join(str(datafiles), 'conditional')
-
- result = cli.run(project=project, args=[
- '-o', 'build_arch', 'x86_64',
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'element.bst'])
+ project = os.path.join(str(datafiles), "conditional")
+
+ result = cli.run(
+ project=project,
+ args=["-o", "build_arch", "x86_64", "show", "--deps", "none", "--format", "%{vars}", "element.bst"],
+ )
result.assert_success()
loaded = _yaml.load_data(result.output)
- assert loaded.get_str('size') == '8'
+ assert loaded.get_str("size") == "8"
@pytest.mark.datafiles(DATA_DIR)
def test_inner(cli, datafiles):
- project = os.path.join(str(datafiles), 'inner')
- result = cli.run(project=project, args=[
- '-o', 'build_arch', 'x86_64',
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'element.bst'])
+ project = os.path.join(str(datafiles), "inner")
+ result = cli.run(
+ project=project,
+ args=["-o", "build_arch", "x86_64", "show", "--deps", "none", "--format", "%{vars}", "element.bst"],
+ )
result.assert_success()
loaded = _yaml.load_data(result.output)
- assert loaded.get_str('build_arch') == 'x86_64'
+ assert loaded.get_str("build_arch") == "x86_64"
@pytest.mark.datafiles(DATA_DIR)
def test_recursive_include(cli, datafiles):
- project = os.path.join(str(datafiles), 'recursive')
+ project = os.path.join(str(datafiles), "recursive")
- result = cli.run(project=project, args=[
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'element.bst'])
+ result = cli.run(project=project, args=["show", "--deps", "none", "--format", "%{vars}", "element.bst"])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.RECURSIVE_INCLUDE)
- assert 'line 2 column 2' in result.stderr
+ assert "line 2 column 2" in result.stderr
@pytest.mark.datafiles(DATA_DIR)
def test_local_to_junction(cli, tmpdir, datafiles):
- project = os.path.join(str(datafiles), 'local_to_junction')
-
- generate_junction(tmpdir,
- os.path.join(project, 'subproject'),
- os.path.join(project, 'junction.bst'),
- store_ref=True)
-
- result = cli.run(project=project, args=[
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'element.bst'])
+ project = os.path.join(str(datafiles), "local_to_junction")
+
+ generate_junction(
+ tmpdir, os.path.join(project, "subproject"), os.path.join(project, "junction.bst"), store_ref=True
+ )
+
+ result = cli.run(project=project, args=["show", "--deps", "none", "--format", "%{vars}", "element.bst"])
result.assert_success()
loaded = _yaml.load_data(result.output)
- assert loaded.get_bool('included')
+ assert loaded.get_bool("included")
diff --git a/tests/format/include_composition.py b/tests/format/include_composition.py
index e10e28bc0..4af6862fa 100644
--- a/tests/format/include_composition.py
+++ b/tests/format/include_composition.py
@@ -11,7 +11,7 @@ from tests.testutils import dummy_context
@contextmanager
def make_includes(basedir):
- _yaml.roundtrip_dump({'name': 'test'}, os.path.join(basedir, 'project.conf'))
+ _yaml.roundtrip_dump({"name": "test"}, os.path.join(basedir, "project.conf"))
with dummy_context() as context:
project = Project(basedir, context)
loader = project.loader
@@ -21,131 +21,118 @@ def make_includes(basedir):
def test_main_has_priority(tmpdir):
with make_includes(str(tmpdir)) as includes:
- _yaml.roundtrip_dump({'(@)': ['a.yml'], 'test': ['main']},
- str(tmpdir.join('main.yml')))
+ _yaml.roundtrip_dump({"(@)": ["a.yml"], "test": ["main"]}, str(tmpdir.join("main.yml")))
- main = _yaml.load(str(tmpdir.join('main.yml')))
+ main = _yaml.load(str(tmpdir.join("main.yml")))
- _yaml.roundtrip_dump({'test': ['a']}, str(tmpdir.join('a.yml')))
+ _yaml.roundtrip_dump({"test": ["a"]}, str(tmpdir.join("a.yml")))
includes.process(main)
- assert main.get_str_list('test') == ['main']
+ assert main.get_str_list("test") == ["main"]
def test_include_cannot_append(tmpdir):
with make_includes(str(tmpdir)) as includes:
- _yaml.roundtrip_dump({'(@)': ['a.yml'], 'test': ['main']},
- str(tmpdir.join('main.yml')))
- main = _yaml.load(str(tmpdir.join('main.yml')))
+ _yaml.roundtrip_dump({"(@)": ["a.yml"], "test": ["main"]}, str(tmpdir.join("main.yml")))
+ main = _yaml.load(str(tmpdir.join("main.yml")))
- _yaml.roundtrip_dump({'test': {'(>)': ['a']}},
- str(tmpdir.join('a.yml')))
+ _yaml.roundtrip_dump({"test": {"(>)": ["a"]}}, str(tmpdir.join("a.yml")))
includes.process(main)
- assert main.get_str_list('test') == ['main']
+ assert main.get_str_list("test") == ["main"]
def test_main_can_append(tmpdir):
with make_includes(str(tmpdir)) as includes:
- _yaml.roundtrip_dump({'(@)': ['a.yml'], 'test': {'(>)': ['main']}},
- str(tmpdir.join('main.yml')))
- main = _yaml.load(str(tmpdir.join('main.yml')))
+ _yaml.roundtrip_dump({"(@)": ["a.yml"], "test": {"(>)": ["main"]}}, str(tmpdir.join("main.yml")))
+ main = _yaml.load(str(tmpdir.join("main.yml")))
- _yaml.roundtrip_dump({'test': ['a']}, str(tmpdir.join('a.yml')))
+ _yaml.roundtrip_dump({"test": ["a"]}, str(tmpdir.join("a.yml")))
includes.process(main)
- assert main.get_str_list('test') == ['a', 'main']
+ assert main.get_str_list("test") == ["a", "main"]
def test_sibling_cannot_append_backward(tmpdir):
with make_includes(str(tmpdir)) as includes:
- _yaml.roundtrip_dump({'(@)': ['a.yml', 'b.yml']},
- str(tmpdir.join('main.yml')))
- main = _yaml.load(str(tmpdir.join('main.yml')))
+ _yaml.roundtrip_dump({"(@)": ["a.yml", "b.yml"]}, str(tmpdir.join("main.yml")))
+ main = _yaml.load(str(tmpdir.join("main.yml")))
- _yaml.roundtrip_dump({'test': {'(>)': ['a']}},
- str(tmpdir.join('a.yml')))
- _yaml.roundtrip_dump({'test': ['b']},
- str(tmpdir.join('b.yml')))
+ _yaml.roundtrip_dump({"test": {"(>)": ["a"]}}, str(tmpdir.join("a.yml")))
+ _yaml.roundtrip_dump({"test": ["b"]}, str(tmpdir.join("b.yml")))
includes.process(main)
- assert main.get_str_list('test') == ['b']
+ assert main.get_str_list("test") == ["b"]
def test_sibling_can_append_forward(tmpdir):
with make_includes(str(tmpdir)) as includes:
- _yaml.roundtrip_dump({'(@)': ['a.yml', 'b.yml']},
- str(tmpdir.join('main.yml')))
- main = _yaml.load(str(tmpdir.join('main.yml')))
+ _yaml.roundtrip_dump({"(@)": ["a.yml", "b.yml"]}, str(tmpdir.join("main.yml")))
+ main = _yaml.load(str(tmpdir.join("main.yml")))
- _yaml.roundtrip_dump({'test': ['a']},
- str(tmpdir.join('a.yml')))
- _yaml.roundtrip_dump({'test': {'(>)': ['b']}},
- str(tmpdir.join('b.yml')))
+ _yaml.roundtrip_dump({"test": ["a"]}, str(tmpdir.join("a.yml")))
+ _yaml.roundtrip_dump({"test": {"(>)": ["b"]}}, str(tmpdir.join("b.yml")))
includes.process(main)
- assert main.get_str_list('test') == ['a', 'b']
+ assert main.get_str_list("test") == ["a", "b"]
def test_lastest_sibling_has_priority(tmpdir):
with make_includes(str(tmpdir)) as includes:
- _yaml.roundtrip_dump({'(@)': ['a.yml', 'b.yml']},
- str(tmpdir.join('main.yml')))
- main = _yaml.load(str(tmpdir.join('main.yml')))
+ _yaml.roundtrip_dump({"(@)": ["a.yml", "b.yml"]}, str(tmpdir.join("main.yml")))
+ main = _yaml.load(str(tmpdir.join("main.yml")))
- _yaml.roundtrip_dump({'test': ['a']},
- str(tmpdir.join('a.yml')))
- _yaml.roundtrip_dump({'test': ['b']},
- str(tmpdir.join('b.yml')))
+ _yaml.roundtrip_dump({"test": ["a"]}, str(tmpdir.join("a.yml")))
+ _yaml.roundtrip_dump({"test": ["b"]}, str(tmpdir.join("b.yml")))
includes.process(main)
- assert main.get_str_list('test') == ['b']
+ assert main.get_str_list("test") == ["b"]
def test_main_keeps_keys(tmpdir):
with make_includes(str(tmpdir)) as includes:
- _yaml.roundtrip_dump({'(@)': ['a.yml'], 'something': 'else'},
- str(tmpdir.join('main.yml')))
- main = _yaml.load(str(tmpdir.join('main.yml')))
+ _yaml.roundtrip_dump({"(@)": ["a.yml"], "something": "else"}, str(tmpdir.join("main.yml")))
+ main = _yaml.load(str(tmpdir.join("main.yml")))
- _yaml.roundtrip_dump({'test': ['a']}, str(tmpdir.join('a.yml')))
+ _yaml.roundtrip_dump({"test": ["a"]}, str(tmpdir.join("a.yml")))
includes.process(main)
- assert main.get_str_list('test') == ['a']
- assert main.get_str('something') == 'else'
+ assert main.get_str_list("test") == ["a"]
+ assert main.get_str("something") == "else"
def test_overwrite_directive_on_later_composite(tmpdir):
with make_includes(str(tmpdir)) as includes:
- _yaml.roundtrip_dump({'(@)': ['a.yml', 'b.yml'], 'test': {'(=)': ['Overwritten']}},
- str(tmpdir.join('main.yml')))
+ _yaml.roundtrip_dump(
+ {"(@)": ["a.yml", "b.yml"], "test": {"(=)": ["Overwritten"]}}, str(tmpdir.join("main.yml"))
+ )
- main = _yaml.load(str(tmpdir.join('main.yml')))
+ main = _yaml.load(str(tmpdir.join("main.yml")))
# a.yml
- _yaml.roundtrip_dump({'test': ['some useless', 'list', 'to be overwritten'],
- 'foo': 'should not be present'},
- str(tmpdir.join('a.yml')))
+ _yaml.roundtrip_dump(
+ {"test": ["some useless", "list", "to be overwritten"], "foo": "should not be present"},
+ str(tmpdir.join("a.yml")),
+ )
# b.yaml isn't going to have a 'test' node to overwrite
- _yaml.roundtrip_dump({'foo': 'should be present'},
- str(tmpdir.join('b.yml')))
+ _yaml.roundtrip_dump({"foo": "should be present"}, str(tmpdir.join("b.yml")))
includes.process(main)
- assert main.get_str_list('test') == ['Overwritten']
- assert main.get_str('foo') == 'should be present'
+ assert main.get_str_list("test") == ["Overwritten"]
+ assert main.get_str("foo") == "should be present"
diff --git a/tests/format/invalid_keys.py b/tests/format/invalid_keys.py
index 861cfeabd..ce1e2e487 100644
--- a/tests/format/invalid_keys.py
+++ b/tests/format/invalid_keys.py
@@ -7,21 +7,21 @@ from buildstream._exceptions import ErrorDomain, LoadErrorReason
from buildstream.testing.runcli import cli # pylint: disable=unused-import
# Project directory
-DATA_DIR = os.path.join(
- os.path.dirname(os.path.realpath(__file__)),
- 'invalid-keys'
-)
+DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "invalid-keys")
@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize(("element", "location"), [
- ("no-path-specified.bst", "line 4 column 4"),
- ("optional-source.bst", "line 6 column 10"),
- ("included-source.bst", "line 4 column 4"),
-])
+@pytest.mark.parametrize(
+ ("element", "location"),
+ [
+ ("no-path-specified.bst", "line 4 column 4"),
+ ("optional-source.bst", "line 6 column 10"),
+ ("included-source.bst", "line 4 column 4"),
+ ],
+)
def test_compositied_node_fails_usefully(cli, datafiles, element, location):
project = str(datafiles)
- result = cli.run(project=project, args=['show', element])
+ result = cli.run(project=project, args=["show", element])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
assert "synthetic node" not in result.stderr
diff --git a/tests/format/junctions.py b/tests/format/junctions.py
index a0af521a2..45ccff222 100644
--- a/tests/format/junctions.py
+++ b/tests/format/junctions.py
@@ -13,10 +13,7 @@ from buildstream.testing import create_repo
from buildstream.testing._utils.site import HAVE_GIT
-DATA_DIR = os.path.join(
- os.path.dirname(os.path.realpath(__file__)),
- 'junctions',
-)
+DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "junctions",)
def copy_subprojects(project, datafiles, subprojects):
@@ -26,41 +23,41 @@ def copy_subprojects(project, datafiles, subprojects):
@pytest.mark.datafiles(DATA_DIR)
def test_simple_pipeline(cli, datafiles):
- project = os.path.join(str(datafiles), 'foo')
- copy_subprojects(project, datafiles, ['base'])
+ project = os.path.join(str(datafiles), "foo")
+ copy_subprojects(project, datafiles, ["base"])
# Check that the pipeline includes the subproject element
- element_list = cli.get_pipeline(project, ['target.bst'])
- assert 'base.bst:target.bst' in element_list
+ element_list = cli.get_pipeline(project, ["target.bst"])
+ assert "base.bst:target.bst" in element_list
@pytest.mark.datafiles(DATA_DIR)
def test_simple_build(cli, tmpdir, datafiles):
- project = os.path.join(str(datafiles), 'foo')
- copy_subprojects(project, datafiles, ['base'])
+ project = os.path.join(str(datafiles), "foo")
+ copy_subprojects(project, datafiles, ["base"])
checkoutdir = os.path.join(str(tmpdir), "checkout")
# Build, checkout
- result = cli.run(project=project, args=['build', 'target.bst'])
+ result = cli.run(project=project, args=["build", "target.bst"])
result.assert_success()
- result = cli.run(project=project, args=['artifact', 'checkout', 'target.bst', '--directory', checkoutdir])
+ result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir])
result.assert_success()
# Check that the checkout contains the expected files from both projects
- assert os.path.exists(os.path.join(checkoutdir, 'base.txt'))
- assert os.path.exists(os.path.join(checkoutdir, 'foo.txt'))
+ assert os.path.exists(os.path.join(checkoutdir, "base.txt"))
+ assert os.path.exists(os.path.join(checkoutdir, "foo.txt"))
@pytest.mark.datafiles(DATA_DIR)
def test_junction_missing_project_conf(cli, datafiles):
- project = datafiles / 'foo'
- copy_subprojects(project, datafiles, ['base'])
+ project = datafiles / "foo"
+ copy_subprojects(project, datafiles, ["base"])
# TODO: see if datafiles can tidy this concat up
# py3.5 requires this str conversion.
- os.remove(str(project / 'base' / 'project.conf'))
+ os.remove(str(project / "base" / "project.conf"))
# Note that both 'foo' and 'base' projects have a 'target.bst'. The
# 'app.bst' in 'foo' depends on the 'target.bst' in 'base', i.e.:
@@ -78,7 +75,7 @@ def test_junction_missing_project_conf(cli, datafiles):
# That would lead to a 'circular dependency error' in this setup, when we
# expect an 'invalid junction'.
#
- result = cli.run(project=project, args=['build', 'app.bst'])
+ result = cli.run(project=project, args=["build", "app.bst"])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_JUNCTION)
# Assert that we have the expected provenance encoded into the error
@@ -89,20 +86,18 @@ def test_junction_missing_project_conf(cli, datafiles):
def test_workspaced_junction_missing_project_conf(cli, datafiles):
# See test_junction_missing_project_conf for some more background.
- project = datafiles / 'foo'
- workspace_dir = project / 'base_workspace'
- copy_subprojects(project, datafiles, ['base'])
+ project = datafiles / "foo"
+ workspace_dir = project / "base_workspace"
+ copy_subprojects(project, datafiles, ["base"])
- result = cli.run(
- project=project,
- args=['workspace', 'open', 'base.bst', '--directory', workspace_dir])
+ result = cli.run(project=project, args=["workspace", "open", "base.bst", "--directory", workspace_dir])
print(result)
result.assert_success()
# py3.5 requires this str conversion.
- os.remove(str(workspace_dir / 'project.conf'))
+ os.remove(str(workspace_dir / "project.conf"))
- result = cli.run(project=project, args=['build', 'app.bst'])
+ result = cli.run(project=project, args=["build", "app.bst"])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_JUNCTION)
# Assert that we have the expected provenance encoded into the error
@@ -111,18 +106,18 @@ def test_workspaced_junction_missing_project_conf(cli, datafiles):
@pytest.mark.datafiles(DATA_DIR)
def test_build_of_same_junction_used_twice(cli, datafiles):
- project = os.path.join(str(datafiles), 'inconsistent-names')
+ project = os.path.join(str(datafiles), "inconsistent-names")
# Check we can build a project that contains the same junction
# that is used twice, but named differently
- result = cli.run(project=project, args=['build', 'target.bst'])
+ result = cli.run(project=project, args=["build", "target.bst"])
result.assert_success()
@pytest.mark.datafiles(DATA_DIR)
def test_missing_file_in_subproject(cli, datafiles):
- project = os.path.join(str(datafiles), 'missing-element')
- result = cli.run(project=project, args=['show', 'target.bst'])
+ project = os.path.join(str(datafiles), "missing-element")
+ result = cli.run(project=project, args=["show", "target.bst"])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.MISSING_FILE)
# Assert that we have the expected provenance encoded into the error
@@ -131,8 +126,8 @@ def test_missing_file_in_subproject(cli, datafiles):
@pytest.mark.datafiles(DATA_DIR)
def test_missing_file_in_subsubproject(cli, datafiles):
- project = os.path.join(str(datafiles), 'missing-element')
- result = cli.run(project=project, args=['show', 'sub-target.bst'])
+ project = os.path.join(str(datafiles), "missing-element")
+ result = cli.run(project=project, args=["show", "sub-target.bst"])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.MISSING_FILE)
# Assert that we have the expected provenance encoded into the error
@@ -141,8 +136,8 @@ def test_missing_file_in_subsubproject(cli, datafiles):
@pytest.mark.datafiles(DATA_DIR)
def test_missing_junction_in_subproject(cli, datafiles):
- project = os.path.join(str(datafiles), 'missing-element')
- result = cli.run(project=project, args=['show', 'sub-target-bad-junction.bst'])
+ project = os.path.join(str(datafiles), "missing-element")
+ result = cli.run(project=project, args=["show", "sub-target-bad-junction.bst"])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.MISSING_FILE)
# Assert that we have the expected provenance encoded into the error
@@ -151,62 +146,62 @@ def test_missing_junction_in_subproject(cli, datafiles):
@pytest.mark.datafiles(DATA_DIR)
def test_nested_simple(cli, tmpdir, datafiles):
- project = os.path.join(str(datafiles), 'foo')
- copy_subprojects(project, datafiles, ['base'])
+ project = os.path.join(str(datafiles), "foo")
+ copy_subprojects(project, datafiles, ["base"])
- project = os.path.join(str(datafiles), 'nested')
- copy_subprojects(project, datafiles, ['foo'])
+ project = os.path.join(str(datafiles), "nested")
+ copy_subprojects(project, datafiles, ["foo"])
checkoutdir = os.path.join(str(tmpdir), "checkout")
# Build, checkout
- result = cli.run(project=project, args=['build', 'target.bst'])
+ result = cli.run(project=project, args=["build", "target.bst"])
result.assert_success()
- result = cli.run(project=project, args=['artifact', 'checkout', 'target.bst', '--directory', checkoutdir])
+ result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir])
result.assert_success()
# Check that the checkout contains the expected files from all subprojects
- assert os.path.exists(os.path.join(checkoutdir, 'base.txt'))
- assert os.path.exists(os.path.join(checkoutdir, 'foo.txt'))
+ assert os.path.exists(os.path.join(checkoutdir, "base.txt"))
+ assert os.path.exists(os.path.join(checkoutdir, "foo.txt"))
@pytest.mark.datafiles(DATA_DIR)
def test_nested_double(cli, tmpdir, datafiles):
- project_foo = os.path.join(str(datafiles), 'foo')
- copy_subprojects(project_foo, datafiles, ['base'])
+ project_foo = os.path.join(str(datafiles), "foo")
+ copy_subprojects(project_foo, datafiles, ["base"])
- project_bar = os.path.join(str(datafiles), 'bar')
- copy_subprojects(project_bar, datafiles, ['base'])
+ project_bar = os.path.join(str(datafiles), "bar")
+ copy_subprojects(project_bar, datafiles, ["base"])
- project = os.path.join(str(datafiles), 'toplevel')
- copy_subprojects(project, datafiles, ['base', 'foo', 'bar'])
+ project = os.path.join(str(datafiles), "toplevel")
+ copy_subprojects(project, datafiles, ["base", "foo", "bar"])
checkoutdir = os.path.join(str(tmpdir), "checkout")
# Build, checkout
- result = cli.run(project=project, args=['build', 'target.bst'])
+ result = cli.run(project=project, args=["build", "target.bst"])
result.assert_success()
- result = cli.run(project=project, args=['artifact', 'checkout', 'target.bst', '--directory', checkoutdir])
+ result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir])
result.assert_success()
# Check that the checkout contains the expected files from all subprojects
- assert os.path.exists(os.path.join(checkoutdir, 'base.txt'))
- assert os.path.exists(os.path.join(checkoutdir, 'foo.txt'))
- assert os.path.exists(os.path.join(checkoutdir, 'bar.txt'))
+ assert os.path.exists(os.path.join(checkoutdir, "base.txt"))
+ assert os.path.exists(os.path.join(checkoutdir, "foo.txt"))
+ assert os.path.exists(os.path.join(checkoutdir, "bar.txt"))
@pytest.mark.datafiles(DATA_DIR)
def test_nested_conflict(cli, datafiles):
- project_foo = os.path.join(str(datafiles), 'foo')
- copy_subprojects(project_foo, datafiles, ['base'])
+ project_foo = os.path.join(str(datafiles), "foo")
+ copy_subprojects(project_foo, datafiles, ["base"])
- project_bar = os.path.join(str(datafiles), 'bar')
- copy_subprojects(project_bar, datafiles, ['base'])
+ project_bar = os.path.join(str(datafiles), "bar")
+ copy_subprojects(project_bar, datafiles, ["base"])
- project = os.path.join(str(datafiles), 'conflict')
- copy_subprojects(project, datafiles, ['foo', 'bar'])
+ project = os.path.join(str(datafiles), "conflict")
+ copy_subprojects(project, datafiles, ["foo", "bar"])
- result = cli.run(project=project, args=['build', 'target.bst'])
+ result = cli.run(project=project, args=["build", "target.bst"])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.CONFLICTING_JUNCTION)
assert "bar.bst:target.bst [line 3 column 2]" in result.stderr
@@ -215,49 +210,49 @@ def test_nested_conflict(cli, datafiles):
# Test that we error correctly when the junction element itself is missing
@pytest.mark.datafiles(DATA_DIR)
def test_missing_junction(cli, datafiles):
- project = os.path.join(str(datafiles), 'invalid')
+ project = os.path.join(str(datafiles), "invalid")
- result = cli.run(project=project, args=['build', 'missing.bst'])
+ result = cli.run(project=project, args=["build", "missing.bst"])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.MISSING_FILE)
# Test that we error correctly when an element is not found in the subproject
@pytest.mark.datafiles(DATA_DIR)
def test_missing_subproject_element(cli, datafiles):
- project = os.path.join(str(datafiles), 'invalid')
- copy_subprojects(project, datafiles, ['base'])
+ project = os.path.join(str(datafiles), "invalid")
+ copy_subprojects(project, datafiles, ["base"])
- result = cli.run(project=project, args=['build', 'missing-element.bst'])
+ result = cli.run(project=project, args=["build", "missing-element.bst"])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.MISSING_FILE)
# Test that we error correctly when a junction itself has dependencies
@pytest.mark.datafiles(DATA_DIR)
def test_invalid_with_deps(cli, datafiles):
- project = os.path.join(str(datafiles), 'invalid')
- copy_subprojects(project, datafiles, ['base'])
+ project = os.path.join(str(datafiles), "invalid")
+ copy_subprojects(project, datafiles, ["base"])
- result = cli.run(project=project, args=['build', 'junction-with-deps.bst'])
+ result = cli.run(project=project, args=["build", "junction-with-deps.bst"])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_JUNCTION)
# Test that we error correctly when a junction is directly depended on
@pytest.mark.datafiles(DATA_DIR)
def test_invalid_junction_dep(cli, datafiles):
- project = os.path.join(str(datafiles), 'invalid')
- copy_subprojects(project, datafiles, ['base'])
+ project = os.path.join(str(datafiles), "invalid")
+ copy_subprojects(project, datafiles, ["base"])
- result = cli.run(project=project, args=['build', 'junction-dep.bst'])
+ result = cli.run(project=project, args=["build", "junction-dep.bst"])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
# Test that we error correctly when we junction-depend on a non-junction
@pytest.mark.datafiles(DATA_DIR)
def test_invalid_junctiondep_not_a_junction(cli, datafiles):
- project = os.path.join(str(datafiles), 'invalid')
- copy_subprojects(project, datafiles, ['base'])
+ project = os.path.join(str(datafiles), "invalid")
+ copy_subprojects(project, datafiles, ["base"])
- result = cli.run(project=project, args=['build', 'junctiondep-not-a-junction.bst'])
+ result = cli.run(project=project, args=["build", "junctiondep-not-a-junction.bst"])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
# Assert that we have the expected provenance encoded into the error
@@ -266,132 +261,117 @@ def test_invalid_junctiondep_not_a_junction(cli, datafiles):
@pytest.mark.datafiles(DATA_DIR)
def test_options_default(cli, tmpdir, datafiles):
- project = os.path.join(str(datafiles), 'options-default')
- copy_subprojects(project, datafiles, ['options-base'])
+ project = os.path.join(str(datafiles), "options-default")
+ copy_subprojects(project, datafiles, ["options-base"])
checkoutdir = os.path.join(str(tmpdir), "checkout")
# Build, checkout
- result = cli.run(project=project, args=['build', 'target.bst'])
+ result = cli.run(project=project, args=["build", "target.bst"])
result.assert_success()
- result = cli.run(project=project, args=['artifact', 'checkout', 'target.bst', '--directory', checkoutdir])
+ result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir])
result.assert_success()
- assert os.path.exists(os.path.join(checkoutdir, 'pony.txt'))
- assert not os.path.exists(os.path.join(checkoutdir, 'horsy.txt'))
+ assert os.path.exists(os.path.join(checkoutdir, "pony.txt"))
+ assert not os.path.exists(os.path.join(checkoutdir, "horsy.txt"))
@pytest.mark.datafiles(DATA_DIR)
def test_options(cli, tmpdir, datafiles):
- project = os.path.join(str(datafiles), 'options')
- copy_subprojects(project, datafiles, ['options-base'])
+ project = os.path.join(str(datafiles), "options")
+ copy_subprojects(project, datafiles, ["options-base"])
checkoutdir = os.path.join(str(tmpdir), "checkout")
# Build, checkout
- result = cli.run(project=project, args=['build', 'target.bst'])
+ result = cli.run(project=project, args=["build", "target.bst"])
result.assert_success()
- result = cli.run(project=project, args=['artifact', 'checkout', 'target.bst', '--directory', checkoutdir])
+ result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir])
result.assert_success()
- assert not os.path.exists(os.path.join(checkoutdir, 'pony.txt'))
- assert os.path.exists(os.path.join(checkoutdir, 'horsy.txt'))
+ assert not os.path.exists(os.path.join(checkoutdir, "pony.txt"))
+ assert os.path.exists(os.path.join(checkoutdir, "horsy.txt"))
@pytest.mark.datafiles(DATA_DIR)
def test_options_inherit(cli, tmpdir, datafiles):
- project = os.path.join(str(datafiles), 'options-inherit')
- copy_subprojects(project, datafiles, ['options-base'])
+ project = os.path.join(str(datafiles), "options-inherit")
+ copy_subprojects(project, datafiles, ["options-base"])
checkoutdir = os.path.join(str(tmpdir), "checkout")
# Build, checkout
- result = cli.run(project=project, args=['build', 'target.bst'])
+ result = cli.run(project=project, args=["build", "target.bst"])
result.assert_success()
- result = cli.run(project=project, args=['artifact', 'checkout', 'target.bst', '--directory', checkoutdir])
+ result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir])
result.assert_success()
- assert not os.path.exists(os.path.join(checkoutdir, 'pony.txt'))
- assert os.path.exists(os.path.join(checkoutdir, 'horsy.txt'))
+ assert not os.path.exists(os.path.join(checkoutdir, "pony.txt"))
+ assert os.path.exists(os.path.join(checkoutdir, "horsy.txt"))
@pytest.mark.skipif(HAVE_GIT is False, reason="git is not available")
@pytest.mark.datafiles(DATA_DIR)
def test_git_show(cli, tmpdir, datafiles):
- project = os.path.join(str(datafiles), 'foo')
+ project = os.path.join(str(datafiles), "foo")
# Create the repo from 'base' subdir
- repo = create_repo('git', str(tmpdir))
- ref = repo.create(os.path.join(str(datafiles), 'base'))
+ repo = create_repo("git", str(tmpdir))
+ ref = repo.create(os.path.join(str(datafiles), "base"))
# Write out junction element with git source
- element = {
- 'kind': 'junction',
- 'sources': [
- repo.source_config(ref=ref)
- ]
- }
- _yaml.roundtrip_dump(element, os.path.join(project, 'base.bst'))
+ element = {"kind": "junction", "sources": [repo.source_config(ref=ref)]}
+ _yaml.roundtrip_dump(element, os.path.join(project, "base.bst"))
# Check that bst show succeeds with implicit subproject fetching and the
# pipeline includes the subproject element
- element_list = cli.get_pipeline(project, ['target.bst'])
- assert 'base.bst:target.bst' in element_list
+ element_list = cli.get_pipeline(project, ["target.bst"])
+ assert "base.bst:target.bst" in element_list
@pytest.mark.skipif(HAVE_GIT is False, reason="git is not available")
@pytest.mark.datafiles(DATA_DIR)
def test_git_build(cli, tmpdir, datafiles):
- project = os.path.join(str(datafiles), 'foo')
+ project = os.path.join(str(datafiles), "foo")
checkoutdir = os.path.join(str(tmpdir), "checkout")
# Create the repo from 'base' subdir
- repo = create_repo('git', str(tmpdir))
- ref = repo.create(os.path.join(str(datafiles), 'base'))
+ repo = create_repo("git", str(tmpdir))
+ ref = repo.create(os.path.join(str(datafiles), "base"))
# Write out junction element with git source
- element = {
- 'kind': 'junction',
- 'sources': [
- repo.source_config(ref=ref)
- ]
- }
- _yaml.roundtrip_dump(element, os.path.join(project, 'base.bst'))
+ element = {"kind": "junction", "sources": [repo.source_config(ref=ref)]}
+ _yaml.roundtrip_dump(element, os.path.join(project, "base.bst"))
# Build (with implicit fetch of subproject), checkout
- result = cli.run(project=project, args=['build', 'target.bst'])
+ result = cli.run(project=project, args=["build", "target.bst"])
result.assert_success()
- result = cli.run(project=project, args=['artifact', 'checkout', 'target.bst', '--directory', checkoutdir])
+ result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir])
result.assert_success()
# Check that the checkout contains the expected files from both projects
- assert os.path.exists(os.path.join(checkoutdir, 'base.txt'))
- assert os.path.exists(os.path.join(checkoutdir, 'foo.txt'))
+ assert os.path.exists(os.path.join(checkoutdir, "base.txt"))
+ assert os.path.exists(os.path.join(checkoutdir, "foo.txt"))
@pytest.mark.skipif(HAVE_GIT is False, reason="git is not available")
@pytest.mark.datafiles(DATA_DIR)
def test_git_missing_project_conf(cli, tmpdir, datafiles):
- project = datafiles / 'foo'
+ project = datafiles / "foo"
# See test_junction_missing_project_conf for some more background.
# py3.5 requires this str conversion.
- os.remove(str(datafiles / 'base' / 'project.conf'))
+ os.remove(str(datafiles / "base" / "project.conf"))
# Create the repo from 'base' subdir
- repo = create_repo('git', str(tmpdir))
- ref = repo.create(os.path.join(str(datafiles), 'base'))
+ repo = create_repo("git", str(tmpdir))
+ ref = repo.create(os.path.join(str(datafiles), "base"))
# Write out junction element with git source
- element = {
- 'kind': 'junction',
- 'sources': [
- repo.source_config(ref=ref)
- ]
- }
- _yaml.roundtrip_dump(element, str(project / 'base.bst'))
-
- result = cli.run(project=project, args=['build', 'app.bst'])
+ element = {"kind": "junction", "sources": [repo.source_config(ref=ref)]}
+ _yaml.roundtrip_dump(element, str(project / "base.bst"))
+
+ result = cli.run(project=project, args=["build", "app.bst"])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_JUNCTION)
# Assert that we have the expected provenance encoded into the error
@@ -400,64 +380,59 @@ def test_git_missing_project_conf(cli, tmpdir, datafiles):
@pytest.mark.datafiles(DATA_DIR)
def test_cross_junction_names(cli, datafiles):
- project = os.path.join(str(datafiles), 'foo')
- copy_subprojects(project, datafiles, ['base'])
+ project = os.path.join(str(datafiles), "foo")
+ copy_subprojects(project, datafiles, ["base"])
- element_list = cli.get_pipeline(project, ['base.bst:target.bst'])
- assert 'base.bst:target.bst' in element_list
+ element_list = cli.get_pipeline(project, ["base.bst:target.bst"])
+ assert "base.bst:target.bst" in element_list
@pytest.mark.datafiles(DATA_DIR)
def test_build_git_cross_junction_names(cli, tmpdir, datafiles):
- project = os.path.join(str(datafiles), 'foo')
+ project = os.path.join(str(datafiles), "foo")
checkoutdir = os.path.join(str(tmpdir), "checkout")
# Create the repo from 'base' subdir
- repo = create_repo('git', str(tmpdir))
- ref = repo.create(os.path.join(str(datafiles), 'base'))
+ repo = create_repo("git", str(tmpdir))
+ ref = repo.create(os.path.join(str(datafiles), "base"))
# Write out junction element with git source
- element = {
- 'kind': 'junction',
- 'sources': [
- repo.source_config(ref=ref)
- ]
- }
- _yaml.roundtrip_dump(element, os.path.join(project, 'base.bst'))
+ element = {"kind": "junction", "sources": [repo.source_config(ref=ref)]}
+ _yaml.roundtrip_dump(element, os.path.join(project, "base.bst"))
print(element)
- print(cli.get_pipeline(project, ['base.bst']))
+ print(cli.get_pipeline(project, ["base.bst"]))
# Build (with implicit fetch of subproject), checkout
- result = cli.run(project=project, args=['build', 'base.bst:target.bst'])
+ result = cli.run(project=project, args=["build", "base.bst:target.bst"])
result.assert_success()
- result = cli.run(project=project, args=['artifact', 'checkout', 'base.bst:target.bst', '--directory', checkoutdir])
+ result = cli.run(project=project, args=["artifact", "checkout", "base.bst:target.bst", "--directory", checkoutdir])
result.assert_success()
# Check that the checkout contains the expected files from both projects
- assert os.path.exists(os.path.join(checkoutdir, 'base.txt'))
+ assert os.path.exists(os.path.join(checkoutdir, "base.txt"))
@pytest.mark.datafiles(DATA_DIR)
def test_config_target(cli, tmpdir, datafiles):
- project = os.path.join(str(datafiles), 'config-target')
- checkoutdir = os.path.join(str(tmpdir), 'checkout')
+ project = os.path.join(str(datafiles), "config-target")
+ checkoutdir = os.path.join(str(tmpdir), "checkout")
# Build, checkout
- result = cli.run(project=project, args=['build', 'target.bst'])
+ result = cli.run(project=project, args=["build", "target.bst"])
result.assert_success()
- result = cli.run(project=project, args=['artifact', 'checkout', 'target.bst', '--directory', checkoutdir])
+ result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkoutdir])
result.assert_success()
# Check that the checkout contains the expected files from sub-sub-project
- assert os.path.exists(os.path.join(checkoutdir, 'hello.txt'))
+ assert os.path.exists(os.path.join(checkoutdir, "hello.txt"))
@pytest.mark.datafiles(DATA_DIR)
def test_invalid_sources_and_target(cli, tmpdir, datafiles):
- project = os.path.join(str(datafiles), 'config-target')
+ project = os.path.join(str(datafiles), "config-target")
- result = cli.run(project=project, args=['show', 'invalid-source-target.bst'])
+ result = cli.run(project=project, args=["show", "invalid-source-target.bst"])
result.assert_main_error(ErrorDomain.ELEMENT, None)
assert "junction elements cannot define both 'sources' and 'target' config option" in result.stderr
@@ -465,15 +440,15 @@ def test_invalid_sources_and_target(cli, tmpdir, datafiles):
@pytest.mark.datafiles(DATA_DIR)
def test_invalid_target_name(cli, tmpdir, datafiles):
- project = os.path.join(str(datafiles), 'config-target')
+ project = os.path.join(str(datafiles), "config-target")
# Rename our junction element to the same name as its target
- old_path = os.path.join(project, 'elements/subsubproject.bst')
- new_path = os.path.join(project, 'elements/subsubproject-junction.bst')
+ old_path = os.path.join(project, "elements/subsubproject.bst")
+ new_path = os.path.join(project, "elements/subsubproject-junction.bst")
os.rename(old_path, new_path)
# This should fail now
- result = cli.run(project=project, args=['show', 'subsubproject-junction.bst'])
+ result = cli.run(project=project, args=["show", "subsubproject-junction.bst"])
result.assert_main_error(ErrorDomain.ELEMENT, None)
assert "junction elements cannot target an element with the same name" in result.stderr
@@ -481,12 +456,12 @@ def test_invalid_target_name(cli, tmpdir, datafiles):
# We cannot exhaustively test all possible ways in which this can go wrong, so
# test a couple of common ways in which we expect this to go wrong.
-@pytest.mark.parametrize('target', ['no-junction.bst', 'nested-junction-target.bst'])
+@pytest.mark.parametrize("target", ["no-junction.bst", "nested-junction-target.bst"])
@pytest.mark.datafiles(DATA_DIR)
def test_invalid_target_format(cli, tmpdir, datafiles, target):
- project = os.path.join(str(datafiles), 'config-target')
+ project = os.path.join(str(datafiles), "config-target")
- result = cli.run(project=project, args=['show', target])
+ result = cli.run(project=project, args=["show", target])
result.assert_main_error(ErrorDomain.ELEMENT, None)
assert "'target' option must be in format '{junction-name}:{element-name}'" in result.stderr
diff --git a/tests/format/listdirectiveerrors.py b/tests/format/listdirectiveerrors.py
index 269b521a4..79102cb02 100644
--- a/tests/format/listdirectiveerrors.py
+++ b/tests/format/listdirectiveerrors.py
@@ -12,38 +12,28 @@ DATA_DIR = os.path.dirname(os.path.realpath(__file__))
@pytest.mark.datafiles(DATA_DIR)
def test_project_error(cli, datafiles):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'list-directive-error-project')
- result = cli.run(project=project, silent=True, args=[
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'element.bst'])
+ project = os.path.join(datafiles.dirname, datafiles.basename, "list-directive-error-project")
+ result = cli.run(
+ project=project, silent=True, args=["show", "--deps", "none", "--format", "%{vars}", "element.bst"]
+ )
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.TRAILING_LIST_DIRECTIVE)
@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize("target", [
- ('variables.bst'), ('environment.bst'), ('config.bst'), ('public.bst')
-])
+@pytest.mark.parametrize("target", [("variables.bst"), ("environment.bst"), ("config.bst"), ("public.bst")])
def test_element_error(cli, datafiles, target):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'list-directive-error-element')
- result = cli.run(project=project, silent=True, args=[
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- target])
+ project = os.path.join(datafiles.dirname, datafiles.basename, "list-directive-error-element")
+ result = cli.run(project=project, silent=True, args=["show", "--deps", "none", "--format", "%{vars}", target])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.TRAILING_LIST_DIRECTIVE)
@pytest.mark.datafiles(DATA_DIR)
def test_project_composite_error(cli, datafiles):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'list-directive-type-error')
- result = cli.run(project=project, silent=True, args=[
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'element.bst'])
+ project = os.path.join(datafiles.dirname, datafiles.basename, "list-directive-type-error")
+ result = cli.run(
+ project=project, silent=True, args=["show", "--deps", "none", "--format", "%{vars}", "element.bst"]
+ )
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.ILLEGAL_COMPOSITE)
diff --git a/tests/format/optionarch.py b/tests/format/optionarch.py
index f347e27ae..75cae9abe 100644
--- a/tests/format/optionarch.py
+++ b/tests/format/optionarch.py
@@ -16,52 +16,45 @@ DATA_DIR = os.path.dirname(os.path.realpath(__file__))
@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize("machine,value,expected", [
- # Test explicitly provided arches
- ('arm', 'aarch32', 'Army'),
- ('arm', 'aarch64', 'Aarchy'),
-
- # Test automatically derived arches
- ('arm', None, 'Army'),
- ('aarch64', None, 'Aarchy'),
-
- # Test that explicitly provided arches dont error out
- # when the `uname` reported arch is not supported
- ('i386', 'aarch32', 'Army'),
- ('x86_64', 'aarch64', 'Aarchy'),
-])
+@pytest.mark.parametrize(
+ "machine,value,expected",
+ [
+ # Test explicitly provided arches
+ ("arm", "aarch32", "Army"),
+ ("arm", "aarch64", "Aarchy"),
+ # Test automatically derived arches
+ ("arm", None, "Army"),
+ ("aarch64", None, "Aarchy"),
+ # Test that explicitly provided arches dont error out
+ # when the `uname` reported arch is not supported
+ ("i386", "aarch32", "Army"),
+ ("x86_64", "aarch64", "Aarchy"),
+ ],
+)
def test_conditional(cli, datafiles, machine, value, expected):
with override_platform_uname(machine=machine):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'option-arch')
+ project = os.path.join(datafiles.dirname, datafiles.basename, "option-arch")
bst_args = []
if value is not None:
- bst_args += ['--option', 'machine_arch', value]
-
- bst_args += [
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'element.bst'
- ]
+ bst_args += ["--option", "machine_arch", value]
+
+ bst_args += ["show", "--deps", "none", "--format", "%{vars}", "element.bst"]
result = cli.run(project=project, silent=True, args=bst_args)
result.assert_success()
loaded = _yaml.load_data(result.output)
- assert loaded.get_str('result') == expected
+ assert loaded.get_str("result") == expected
@pytest.mark.datafiles(DATA_DIR)
def test_unsupported_arch(cli, datafiles):
with override_platform_uname(machine="x86_64"):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'option-arch')
- result = cli.run(project=project, silent=True, args=[
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'element.bst'
- ])
+ project = os.path.join(datafiles.dirname, datafiles.basename, "option-arch")
+ result = cli.run(
+ project=project, silent=True, args=["show", "--deps", "none", "--format", "%{vars}", "element.bst"]
+ )
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
@@ -70,13 +63,10 @@ def test_unsupported_arch(cli, datafiles):
def test_alias(cli, datafiles):
with override_platform_uname(machine="arm"):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'option-arch-alias')
- result = cli.run(project=project, silent=True, args=[
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'element.bst'
- ])
+ project = os.path.join(datafiles.dirname, datafiles.basename, "option-arch-alias")
+ result = cli.run(
+ project=project, silent=True, args=["show", "--deps", "none", "--format", "%{vars}", "element.bst"]
+ )
result.assert_success()
@@ -85,13 +75,10 @@ def test_alias(cli, datafiles):
def test_unknown_host_arch(cli, datafiles):
with override_platform_uname(machine="x86_128"):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'option-arch')
- result = cli.run(project=project, silent=True, args=[
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'element.bst'
- ])
+ project = os.path.join(datafiles.dirname, datafiles.basename, "option-arch")
+ result = cli.run(
+ project=project, silent=True, args=["show", "--deps", "none", "--format", "%{vars}", "element.bst"]
+ )
result.assert_main_error(ErrorDomain.PLATFORM, None)
@@ -99,12 +86,9 @@ def test_unknown_host_arch(cli, datafiles):
@pytest.mark.datafiles(DATA_DIR)
def test_unknown_project_arch(cli, datafiles):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'option-arch-unknown')
- result = cli.run(project=project, silent=True, args=[
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'element.bst'
- ])
+ project = os.path.join(datafiles.dirname, datafiles.basename, "option-arch-unknown")
+ result = cli.run(
+ project=project, silent=True, args=["show", "--deps", "none", "--format", "%{vars}", "element.bst"]
+ )
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
diff --git a/tests/format/optionbool.py b/tests/format/optionbool.py
index d772b483c..3b05aafa1 100644
--- a/tests/format/optionbool.py
+++ b/tests/format/optionbool.py
@@ -12,101 +12,72 @@ DATA_DIR = os.path.dirname(os.path.realpath(__file__))
@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize("target,option,expected", [
- # Test 'foo' syntax, and valid values of 'True' / 'False'
- ('element.bst', 'True', 'a pony'),
- ('element.bst', 'true', 'a pony'),
- ('element.bst', 'False', 'not pony'),
- ('element.bst', 'false', 'not pony'),
-
- # Test 'not foo' syntax
- ('element-not.bst', 'False', 'not pony'),
- ('element-not.bst', 'True', 'a pony'),
-
- # Test 'foo == True' syntax
- ('element-equals.bst', 'False', 'not pony'),
- ('element-equals.bst', 'True', 'a pony'),
-
- # Test 'foo != True' syntax
- ('element-not-equals.bst', 'False', 'not pony'),
- ('element-not-equals.bst', 'True', 'a pony'),
-])
+@pytest.mark.parametrize(
+ "target,option,expected",
+ [
+ # Test 'foo' syntax, and valid values of 'True' / 'False'
+ ("element.bst", "True", "a pony"),
+ ("element.bst", "true", "a pony"),
+ ("element.bst", "False", "not pony"),
+ ("element.bst", "false", "not pony"),
+ # Test 'not foo' syntax
+ ("element-not.bst", "False", "not pony"),
+ ("element-not.bst", "True", "a pony"),
+ # Test 'foo == True' syntax
+ ("element-equals.bst", "False", "not pony"),
+ ("element-equals.bst", "True", "a pony"),
+ # Test 'foo != True' syntax
+ ("element-not-equals.bst", "False", "not pony"),
+ ("element-not-equals.bst", "True", "a pony"),
+ ],
+)
def test_conditional_cli(cli, datafiles, target, option, expected):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'option-bool')
- result = cli.run(project=project, silent=True, args=[
- '--option', 'pony', option,
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- target])
+ project = os.path.join(datafiles.dirname, datafiles.basename, "option-bool")
+ result = cli.run(
+ project=project,
+ silent=True,
+ args=["--option", "pony", option, "show", "--deps", "none", "--format", "%{vars}", target],
+ )
result.assert_success()
loaded = _yaml.load_data(result.output)
- assert loaded.get_str('thepony') == expected
+ assert loaded.get_str("thepony") == expected
# Test configuration of boolean option in the config file
#
@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize("target,option,expected", [
- ('element.bst', True, 'a pony'),
- ('element.bst', False, 'not pony'),
-])
+@pytest.mark.parametrize(
+ "target,option,expected", [("element.bst", True, "a pony"), ("element.bst", False, "not pony"),]
+)
def test_conditional_config(cli, datafiles, target, option, expected):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'option-bool')
- cli.configure({
- 'projects': {
- 'test': {
- 'options': {
- 'pony': option
- }
- }
- }
- })
- result = cli.run(project=project, silent=True, args=[
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- target])
+ project = os.path.join(datafiles.dirname, datafiles.basename, "option-bool")
+ cli.configure({"projects": {"test": {"options": {"pony": option}}}})
+ result = cli.run(project=project, silent=True, args=["show", "--deps", "none", "--format", "%{vars}", target])
result.assert_success()
loaded = _yaml.load_data(result.output)
- assert loaded.get_str('thepony') == expected
+ assert loaded.get_str("thepony") == expected
@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize("cli_option", [
- ('falsey'), ('pony'), ('trUE')
-])
+@pytest.mark.parametrize("cli_option", [("falsey"), ("pony"), ("trUE")])
def test_invalid_value_cli(cli, datafiles, cli_option):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'option-bool')
- result = cli.run(project=project, silent=True, args=[
- '--option', 'pony', cli_option,
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'element.bst'])
+ project = os.path.join(datafiles.dirname, datafiles.basename, "option-bool")
+ result = cli.run(
+ project=project,
+ silent=True,
+ args=["--option", "pony", cli_option, "show", "--deps", "none", "--format", "%{vars}", "element.bst"],
+ )
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize("config_option", [
- ('pony'), (['its', 'a', 'list']), ({'dic': 'tionary'})
-])
+@pytest.mark.parametrize("config_option", [("pony"), (["its", "a", "list"]), ({"dic": "tionary"})])
def test_invalid_value_config(cli, datafiles, config_option):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'option-bool')
- cli.configure({
- 'projects': {
- 'test': {
- 'options': {
- 'pony': config_option
- }
- }
- }
- })
- result = cli.run(project=project, silent=True, args=[
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'element.bst'])
+ project = os.path.join(datafiles.dirname, datafiles.basename, "option-bool")
+ cli.configure({"projects": {"test": {"options": {"pony": config_option}}}})
+ result = cli.run(
+ project=project, silent=True, args=["show", "--deps", "none", "--format", "%{vars}", "element.bst"]
+ )
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
diff --git a/tests/format/optioneltmask.py b/tests/format/optioneltmask.py
index 75265fdd7..399b37b97 100644
--- a/tests/format/optioneltmask.py
+++ b/tests/format/optioneltmask.py
@@ -12,73 +12,61 @@ DATA_DIR = os.path.dirname(os.path.realpath(__file__))
@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize("target,value,expected", [
- ('pony.bst', 'pony.bst', 'True'),
- ('horsy.bst', 'pony.bst, horsy.bst', 'True'),
- ('zebry.bst', 'pony.bst, horsy.bst', 'False'),
-])
+@pytest.mark.parametrize(
+ "target,value,expected",
+ [
+ ("pony.bst", "pony.bst", "True"),
+ ("horsy.bst", "pony.bst, horsy.bst", "True"),
+ ("zebry.bst", "pony.bst, horsy.bst", "False"),
+ ],
+)
def test_conditional_cli(cli, datafiles, target, value, expected):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'option-element-mask')
- result = cli.run(project=project, silent=True, args=[
- '--option', 'debug_elements', value,
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- target])
+ project = os.path.join(datafiles.dirname, datafiles.basename, "option-element-mask")
+ result = cli.run(
+ project=project,
+ silent=True,
+ args=["--option", "debug_elements", value, "show", "--deps", "none", "--format", "%{vars}", target],
+ )
result.assert_success()
loaded = _yaml.load_data(result.output)
- assert loaded.get_str('debug') == expected
+ assert loaded.get_str("debug") == expected
@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize("target,value,expected", [
- ('pony.bst', ['pony.bst'], 'True'),
- ('horsy.bst', ['pony.bst', 'horsy.bst'], 'True'),
- ('zebry.bst', ['pony.bst', 'horsy.bst'], 'False'),
-])
+@pytest.mark.parametrize(
+ "target,value,expected",
+ [
+ ("pony.bst", ["pony.bst"], "True"),
+ ("horsy.bst", ["pony.bst", "horsy.bst"], "True"),
+ ("zebry.bst", ["pony.bst", "horsy.bst"], "False"),
+ ],
+)
def test_conditional_config(cli, datafiles, target, value, expected):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'option-element-mask')
- cli.configure({
- 'projects': {
- 'test': {
- 'options': {
- 'debug_elements': value
- }
- }
- }
- })
- result = cli.run(project=project, silent=True, args=[
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- target])
+ project = os.path.join(datafiles.dirname, datafiles.basename, "option-element-mask")
+ cli.configure({"projects": {"test": {"options": {"debug_elements": value}}}})
+ result = cli.run(project=project, silent=True, args=["show", "--deps", "none", "--format", "%{vars}", target])
result.assert_success()
loaded = _yaml.load_data(result.output)
- assert loaded.get_str('debug') == expected
+ assert loaded.get_str("debug") == expected
@pytest.mark.datafiles(DATA_DIR)
def test_invalid_declaration(cli, datafiles):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'option-element-mask-invalid')
- result = cli.run(project=project, silent=True, args=[
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'pony.bst'])
+ project = os.path.join(datafiles.dirname, datafiles.basename, "option-element-mask-invalid")
+ result = cli.run(project=project, silent=True, args=["show", "--deps", "none", "--format", "%{vars}", "pony.bst"])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
@pytest.mark.datafiles(DATA_DIR)
def test_invalid_value(cli, datafiles):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'option-element-mask')
- result = cli.run(project=project, silent=True, args=[
- '--option', 'debug_elements', 'kitten.bst',
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'pony.bst'])
+ project = os.path.join(datafiles.dirname, datafiles.basename, "option-element-mask")
+ result = cli.run(
+ project=project,
+ silent=True,
+ args=["--option", "debug_elements", "kitten.bst", "show", "--deps", "none", "--format", "%{vars}", "pony.bst"],
+ )
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
diff --git a/tests/format/optionenum.py b/tests/format/optionenum.py
index f9aff503f..ba79bea79 100644
--- a/tests/format/optionenum.py
+++ b/tests/format/optionenum.py
@@ -12,104 +12,82 @@ DATA_DIR = os.path.dirname(os.path.realpath(__file__))
@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize("target,option,value,expected", [
- # Test 'var == "foo"' syntax
- ('element.bst', 'brother', 'pony', 'a pony'),
- ('element.bst', 'brother', 'zebry', 'a zebry'),
- ('element.bst', 'brother', 'horsy', 'a horsy'),
- # Test 'var1 == var2' syntax
- ('element-compare.bst', 'brother', 'horsy', 'different'),
- ('element-compare.bst', 'brother', 'zebry', 'same'),
- ('element-compare.bst', 'sister', 'pony', 'same'),
-])
+@pytest.mark.parametrize(
+ "target,option,value,expected",
+ [
+ # Test 'var == "foo"' syntax
+ ("element.bst", "brother", "pony", "a pony"),
+ ("element.bst", "brother", "zebry", "a zebry"),
+ ("element.bst", "brother", "horsy", "a horsy"),
+ # Test 'var1 == var2' syntax
+ ("element-compare.bst", "brother", "horsy", "different"),
+ ("element-compare.bst", "brother", "zebry", "same"),
+ ("element-compare.bst", "sister", "pony", "same"),
+ ],
+)
def test_conditional_cli(cli, datafiles, target, option, value, expected):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'option-enum')
- result = cli.run(project=project, silent=True, args=[
- '--option', option, value,
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- target])
+ project = os.path.join(datafiles.dirname, datafiles.basename, "option-enum")
+ result = cli.run(
+ project=project,
+ silent=True,
+ args=["--option", option, value, "show", "--deps", "none", "--format", "%{vars}", target],
+ )
result.assert_success()
loaded = _yaml.load_data(result.output)
- assert loaded.get_str('result') == expected
+ assert loaded.get_str("result") == expected
@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize("target,option,value,expected", [
- # Test 'var == "foo"' syntax
- ('element.bst', 'brother', 'pony', 'a pony'),
- ('element.bst', 'brother', 'zebry', 'a zebry'),
- ('element.bst', 'brother', 'horsy', 'a horsy'),
- # Test 'var1 == var2' syntax
- ('element-compare.bst', 'brother', 'horsy', 'different'),
- ('element-compare.bst', 'brother', 'zebry', 'same'),
- ('element-compare.bst', 'sister', 'pony', 'same'),
-])
+@pytest.mark.parametrize(
+ "target,option,value,expected",
+ [
+ # Test 'var == "foo"' syntax
+ ("element.bst", "brother", "pony", "a pony"),
+ ("element.bst", "brother", "zebry", "a zebry"),
+ ("element.bst", "brother", "horsy", "a horsy"),
+ # Test 'var1 == var2' syntax
+ ("element-compare.bst", "brother", "horsy", "different"),
+ ("element-compare.bst", "brother", "zebry", "same"),
+ ("element-compare.bst", "sister", "pony", "same"),
+ ],
+)
def test_conditional_config(cli, datafiles, target, option, value, expected):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'option-enum')
- cli.configure({
- 'projects': {
- 'test': {
- 'options': {
- option: value
- }
- }
- }
- })
- result = cli.run(project=project, silent=True, args=[
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- target])
+ project = os.path.join(datafiles.dirname, datafiles.basename, "option-enum")
+ cli.configure({"projects": {"test": {"options": {option: value}}}})
+ result = cli.run(project=project, silent=True, args=["show", "--deps", "none", "--format", "%{vars}", target])
result.assert_success()
loaded = _yaml.load_data(result.output)
- assert loaded.get_str('result') == expected
+ assert loaded.get_str("result") == expected
@pytest.mark.datafiles(DATA_DIR)
def test_invalid_value_cli(cli, datafiles):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'option-enum')
- result = cli.run(project=project, silent=True, args=[
- '--option', 'brother', 'giraffy',
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'element.bst'])
+ project = os.path.join(datafiles.dirname, datafiles.basename, "option-enum")
+ result = cli.run(
+ project=project,
+ silent=True,
+ args=["--option", "brother", "giraffy", "show", "--deps", "none", "--format", "%{vars}", "element.bst"],
+ )
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize("config_option", [
- ('giraffy'), (['its', 'a', 'list']), ({'dic': 'tionary'})
-])
+@pytest.mark.parametrize("config_option", [("giraffy"), (["its", "a", "list"]), ({"dic": "tionary"})])
def test_invalid_value_config(cli, datafiles, config_option):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'option-enum')
- cli.configure({
- 'projects': {
- 'test': {
- 'options': {
- 'brother': config_option
- }
- }
- }
- })
- result = cli.run(project=project, silent=True, args=[
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'element.bst'])
+ project = os.path.join(datafiles.dirname, datafiles.basename, "option-enum")
+ cli.configure({"projects": {"test": {"options": {"brother": config_option}}}})
+ result = cli.run(
+ project=project, silent=True, args=["show", "--deps", "none", "--format", "%{vars}", "element.bst"]
+ )
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
@pytest.mark.datafiles(DATA_DIR)
def test_missing_values(cli, datafiles):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'option-enum-missing')
- result = cli.run(project=project, silent=True, args=[
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'element.bst'])
+ project = os.path.join(datafiles.dirname, datafiles.basename, "option-enum-missing")
+ result = cli.run(
+ project=project, silent=True, args=["show", "--deps", "none", "--format", "%{vars}", "element.bst"]
+ )
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
diff --git a/tests/format/optionexports.py b/tests/format/optionexports.py
index 104abcf83..4f95dc109 100644
--- a/tests/format/optionexports.py
+++ b/tests/format/optionexports.py
@@ -11,28 +11,27 @@ DATA_DIR = os.path.dirname(os.path.realpath(__file__))
@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize("option_name,option_value,var_name,var_value", [
-
- # Test boolean
- ('bool_export', 'False', 'exported-bool', '0'),
- ('bool_export', 'True', 'exported-bool', '1'),
-
- # Enum
- ('enum_export', 'pony', 'exported-enum', 'pony'),
- ('enum_export', 'horsy', 'exported-enum', 'horsy'),
-
- # Flags
- ('flags_export', 'pony', 'exported-flags', 'pony'),
- ('flags_export', 'pony, horsy', 'exported-flags', 'horsy,pony'),
-])
+@pytest.mark.parametrize(
+ "option_name,option_value,var_name,var_value",
+ [
+ # Test boolean
+ ("bool_export", "False", "exported-bool", "0"),
+ ("bool_export", "True", "exported-bool", "1"),
+ # Enum
+ ("enum_export", "pony", "exported-enum", "pony"),
+ ("enum_export", "horsy", "exported-enum", "horsy"),
+ # Flags
+ ("flags_export", "pony", "exported-flags", "pony"),
+ ("flags_export", "pony, horsy", "exported-flags", "horsy,pony"),
+ ],
+)
def test_export(cli, datafiles, option_name, option_value, var_name, var_value):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'option-exports')
- result = cli.run(project=project, silent=True, args=[
- '--option', option_name, option_value,
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'element.bst'])
+ project = os.path.join(datafiles.dirname, datafiles.basename, "option-exports")
+ result = cli.run(
+ project=project,
+ silent=True,
+ args=["--option", option_name, option_value, "show", "--deps", "none", "--format", "%{vars}", "element.bst"],
+ )
result.assert_success()
loaded = _yaml.load_data(result.output)
diff --git a/tests/format/optionflags.py b/tests/format/optionflags.py
index 29bb7ec2c..53e674919 100644
--- a/tests/format/optionflags.py
+++ b/tests/format/optionflags.py
@@ -12,113 +12,93 @@ DATA_DIR = os.path.dirname(os.path.realpath(__file__))
@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize("target,option,value,expected", [
- # Test (var == [ "foo" ]) syntax
- ('element.bst', 'farm', 'pony', 'a pony'),
- ('element.bst', 'farm', 'zebry', 'a zebry'),
- ('element.bst', 'farm', 'pony, horsy', 'a pony and a horsy'),
- ('element.bst', 'farm', 'zebry,horsy , pony', 'all the animals'),
-
- # Test ("literal" in var) syntax
- ('element-in.bst', 'farm', 'zebry, horsy, pony', 'a zebry'),
-
- # Test ("literal" not in var) syntax
- ('element-in.bst', 'farm', 'zebry, horsy', 'no pony'),
-
- # Test (var1 not in var2) syntax (where var1 is enum and var2 is flags)
- ('element-in.bst', 'farm', 'zebry, pony', 'no horsy'),
-])
+@pytest.mark.parametrize(
+ "target,option,value,expected",
+ [
+ # Test (var == [ "foo" ]) syntax
+ ("element.bst", "farm", "pony", "a pony"),
+ ("element.bst", "farm", "zebry", "a zebry"),
+ ("element.bst", "farm", "pony, horsy", "a pony and a horsy"),
+ ("element.bst", "farm", "zebry,horsy , pony", "all the animals"),
+ # Test ("literal" in var) syntax
+ ("element-in.bst", "farm", "zebry, horsy, pony", "a zebry"),
+ # Test ("literal" not in var) syntax
+ ("element-in.bst", "farm", "zebry, horsy", "no pony"),
+ # Test (var1 not in var2) syntax (where var1 is enum and var2 is flags)
+ ("element-in.bst", "farm", "zebry, pony", "no horsy"),
+ ],
+)
def test_conditional_cli(cli, datafiles, target, option, value, expected):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'option-flags')
- result = cli.run(project=project, silent=True, args=[
- '--option', option, value,
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- target])
+ project = os.path.join(datafiles.dirname, datafiles.basename, "option-flags")
+ result = cli.run(
+ project=project,
+ silent=True,
+ args=["--option", option, value, "show", "--deps", "none", "--format", "%{vars}", target],
+ )
result.assert_success()
loaded = _yaml.load_data(result.output)
- assert loaded.get_str('result') == expected
+ assert loaded.get_str("result") == expected
@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize("target,option,value,expected", [
- # Test 'var == [ "foo" ]' syntax
- ('element.bst', 'farm', ['pony'], 'a pony'),
- ('element.bst', 'farm', ['zebry'], 'a zebry'),
- ('element.bst', 'farm', ['pony', 'horsy'], 'a pony and a horsy'),
- ('element.bst', 'farm', ['zebry', 'horsy', 'pony'], 'all the animals'),
-])
+@pytest.mark.parametrize(
+ "target,option,value,expected",
+ [
+ # Test 'var == [ "foo" ]' syntax
+ ("element.bst", "farm", ["pony"], "a pony"),
+ ("element.bst", "farm", ["zebry"], "a zebry"),
+ ("element.bst", "farm", ["pony", "horsy"], "a pony and a horsy"),
+ ("element.bst", "farm", ["zebry", "horsy", "pony"], "all the animals"),
+ ],
+)
def test_conditional_config(cli, datafiles, target, option, value, expected):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'option-flags')
- cli.configure({
- 'projects': {
- 'test': {
- 'options': {
- option: value
- }
- }
- }
- })
- result = cli.run(project=project, silent=True, args=[
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- target])
+ project = os.path.join(datafiles.dirname, datafiles.basename, "option-flags")
+ cli.configure({"projects": {"test": {"options": {option: value}}}})
+ result = cli.run(project=project, silent=True, args=["show", "--deps", "none", "--format", "%{vars}", target])
result.assert_success()
loaded = _yaml.load_data(result.output)
- assert loaded.get_str('result') == expected
+ assert loaded.get_str("result") == expected
@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize("cli_option", [
- ('giraffy'), # Not a valid animal for the farm option
- ('horsy pony') # Does not include comma separators
-])
+@pytest.mark.parametrize(
+ "cli_option",
+ [("giraffy"), ("horsy pony")], # Not a valid animal for the farm option # Does not include comma separators
+)
def test_invalid_value_cli(cli, datafiles, cli_option):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'option-flags')
- result = cli.run(project=project, silent=True, args=[
- '--option', 'farm', cli_option,
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'element.bst'])
+ project = os.path.join(datafiles.dirname, datafiles.basename, "option-flags")
+ result = cli.run(
+ project=project,
+ silent=True,
+ args=["--option", "farm", cli_option, "show", "--deps", "none", "--format", "%{vars}", "element.bst"],
+ )
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize("config_option", [
- ('pony'), # Not specified as a list
- (['horsy', 'pony', 'giraffy']), # Invalid giraffy animal for farm option
- ({'dic': 'tionary'}) # Dicts also dont make sense in the config for flags
-])
+@pytest.mark.parametrize(
+ "config_option",
+ [
+ ("pony"), # Not specified as a list
+ (["horsy", "pony", "giraffy"]), # Invalid giraffy animal for farm option
+ ({"dic": "tionary"}), # Dicts also dont make sense in the config for flags
+ ],
+)
def test_invalid_value_config(cli, datafiles, config_option):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'option-flags')
- cli.configure({
- 'projects': {
- 'test': {
- 'options': {
- 'farm': config_option
- }
- }
- }
- })
- result = cli.run(project=project, silent=True, args=[
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'element.bst'])
+ project = os.path.join(datafiles.dirname, datafiles.basename, "option-flags")
+ cli.configure({"projects": {"test": {"options": {"farm": config_option}}}})
+ result = cli.run(
+ project=project, silent=True, args=["show", "--deps", "none", "--format", "%{vars}", "element.bst"]
+ )
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
@pytest.mark.datafiles(DATA_DIR)
def test_missing_values(cli, datafiles):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'option-flags-missing')
- result = cli.run(project=project, silent=True, args=[
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'element.bst'])
+ project = os.path.join(datafiles.dirname, datafiles.basename, "option-flags-missing")
+ result = cli.run(
+ project=project, silent=True, args=["show", "--deps", "none", "--format", "%{vars}", "element.bst"]
+ )
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
diff --git a/tests/format/optionos.py b/tests/format/optionos.py
index f915d889e..92486104e 100644
--- a/tests/format/optionos.py
+++ b/tests/format/optionos.py
@@ -15,51 +15,44 @@ DATA_DIR = os.path.dirname(os.path.realpath(__file__))
@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize("system,value,expected", [
- # Test explicitly provided arches
- ('Darwin', 'Linux', 'Linuxy'),
- ('SunOS', 'FreeBSD', 'FreeBSDy'),
-
- # Test automatically derived arches
- ('Linux', None, 'Linuxy'),
- ('Darwin', None, 'Darwiny'),
-
- # Test that explicitly provided arches dont error out
- # when the `uname` reported arch is not supported
- ('AIX', 'Linux', 'Linuxy'),
- ('HaikuOS', 'SunOS', 'SunOSy'),
-])
+@pytest.mark.parametrize(
+ "system,value,expected",
+ [
+ # Test explicitly provided arches
+ ("Darwin", "Linux", "Linuxy"),
+ ("SunOS", "FreeBSD", "FreeBSDy"),
+ # Test automatically derived arches
+ ("Linux", None, "Linuxy"),
+ ("Darwin", None, "Darwiny"),
+ # Test that explicitly provided arches dont error out
+ # when the `uname` reported arch is not supported
+ ("AIX", "Linux", "Linuxy"),
+ ("HaikuOS", "SunOS", "SunOSy"),
+ ],
+)
def test_conditionals(cli, datafiles, system, value, expected):
with override_platform_uname(system=system):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'option-os')
+ project = os.path.join(datafiles.dirname, datafiles.basename, "option-os")
bst_args = []
if value is not None:
- bst_args += ['--option', 'machine_os', value]
+ bst_args += ["--option", "machine_os", value]
- bst_args += [
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'element.bst'
- ]
+ bst_args += ["show", "--deps", "none", "--format", "%{vars}", "element.bst"]
result = cli.run(project=project, silent=True, args=bst_args)
result.assert_success()
loaded = _yaml.load_data(result.output)
- assert loaded.get_str('result') == expected
+ assert loaded.get_str("result") == expected
@pytest.mark.datafiles(DATA_DIR)
def test_unsupported_arch(cli, datafiles):
with override_platform_uname(system="AIX"):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'option-os')
- result = cli.run(project=project, silent=True, args=[
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'element.bst'
- ])
+ project = os.path.join(datafiles.dirname, datafiles.basename, "option-os")
+ result = cli.run(
+ project=project, silent=True, args=["show", "--deps", "none", "--format", "%{vars}", "element.bst"]
+ )
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
diff --git a/tests/format/optionoverrides.py b/tests/format/optionoverrides.py
index d4ed257dd..ba12e751f 100644
--- a/tests/format/optionoverrides.py
+++ b/tests/format/optionoverrides.py
@@ -11,22 +11,17 @@ DATA_DIR = os.path.dirname(os.path.realpath(__file__))
@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize("arch", [('i686'), ('x86_64')])
+@pytest.mark.parametrize("arch", [("i686"), ("x86_64")])
def test_override(cli, datafiles, arch):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'option-overrides')
+ project = os.path.join(datafiles.dirname, datafiles.basename, "option-overrides")
- bst_args = ['--option', 'arch', arch]
- bst_args += [
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'element.bst'
- ]
+ bst_args = ["--option", "arch", arch]
+ bst_args += ["show", "--deps", "none", "--format", "%{vars}", "element.bst"]
result = cli.run(project=project, silent=True, args=bst_args)
result.assert_success()
# See the associated project.conf for the expected values
- expected_value = '--host={}-unknown-linux-gnu'.format(arch)
+ expected_value = "--host={}-unknown-linux-gnu".format(arch)
loaded = _yaml.load_data(result.output)
- assert loaded.get_str('conf-global') == expected_value
+ assert loaded.get_str("conf-global") == expected_value
diff --git a/tests/format/options.py b/tests/format/options.py
index 9c0e043f9..aa0854e96 100644
--- a/tests/format/options.py
+++ b/tests/format/options.py
@@ -8,244 +8,233 @@ from buildstream._exceptions import ErrorDomain, LoadErrorReason
from buildstream.testing.runcli import cli # pylint: disable=unused-import
# Project directory
-DATA_DIR = os.path.join(
- os.path.dirname(os.path.realpath(__file__)),
- 'options'
-)
+DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "options")
@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize("project_dir", [
- ('invalid-name-spaces'),
- ('invalid-name-dashes'),
- ('invalid-name-plus'),
- ('invalid-name-leading-number'),
-])
+@pytest.mark.parametrize(
+ "project_dir",
+ [("invalid-name-spaces"), ("invalid-name-dashes"), ("invalid-name-plus"), ("invalid-name-leading-number"),],
+)
def test_invalid_option_name(cli, datafiles, project_dir):
project = os.path.join(datafiles.dirname, datafiles.basename, project_dir)
- result = cli.run(project=project, silent=True, args=['show', 'element.bst'])
+ result = cli.run(project=project, silent=True, args=["show", "element.bst"])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_SYMBOL_NAME)
@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize("project_dir", [
- ('invalid-variable-name-spaces'),
- ('invalid-variable-name-plus'),
-])
+@pytest.mark.parametrize("project_dir", [("invalid-variable-name-spaces"), ("invalid-variable-name-plus"),])
def test_invalid_variable_name(cli, datafiles, project_dir):
project = os.path.join(datafiles.dirname, datafiles.basename, project_dir)
- result = cli.run(project=project, silent=True, args=['show', 'element.bst'])
+ result = cli.run(project=project, silent=True, args=["show", "element.bst"])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_SYMBOL_NAME)
@pytest.mark.datafiles(DATA_DIR)
def test_invalid_option_type(cli, datafiles):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'invalid-type')
+ project = os.path.join(datafiles.dirname, datafiles.basename, "invalid-type")
# Test with the opt option set
- result = cli.run(project=project, silent=True, args=[
- '--option', 'opt', 'funny',
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'element.bst'])
+ result = cli.run(
+ project=project,
+ silent=True,
+ args=["--option", "opt", "funny", "show", "--deps", "none", "--format", "%{vars}", "element.bst"],
+ )
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
@pytest.mark.datafiles(DATA_DIR)
def test_invalid_option_cli(cli, datafiles):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'simple-condition')
+ project = os.path.join(datafiles.dirname, datafiles.basename, "simple-condition")
# Test with the opt option set
- result = cli.run(project=project, silent=True, args=[
- '--option', 'fart', 'funny',
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'element.bst'])
+ result = cli.run(
+ project=project,
+ silent=True,
+ args=["--option", "fart", "funny", "show", "--deps", "none", "--format", "%{vars}", "element.bst"],
+ )
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
@pytest.mark.datafiles(DATA_DIR)
def test_invalid_option_config(cli, datafiles):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'simple-condition')
- cli.configure({
- 'projects': {
- 'test': {
- 'options': {
- 'fart': 'Hello'
- }
- }
- }
- })
- result = cli.run(project=project, silent=True, args=[
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'element.bst'])
+ project = os.path.join(datafiles.dirname, datafiles.basename, "simple-condition")
+ cli.configure({"projects": {"test": {"options": {"fart": "Hello"}}}})
+ result = cli.run(
+ project=project, silent=True, args=["show", "--deps", "none", "--format", "%{vars}", "element.bst"]
+ )
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
@pytest.mark.datafiles(DATA_DIR)
def test_invalid_expression(cli, datafiles):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'invalid-expression')
- result = cli.run(project=project, silent=True, args=[
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'element.bst'])
+ project = os.path.join(datafiles.dirname, datafiles.basename, "invalid-expression")
+ result = cli.run(
+ project=project, silent=True, args=["show", "--deps", "none", "--format", "%{vars}", "element.bst"]
+ )
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.EXPRESSION_FAILED)
@pytest.mark.datafiles(DATA_DIR)
def test_undefined(cli, datafiles):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'undefined-variable')
- result = cli.run(project=project, silent=True, args=[
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'element.bst'])
+ project = os.path.join(datafiles.dirname, datafiles.basename, "undefined-variable")
+ result = cli.run(
+ project=project, silent=True, args=["show", "--deps", "none", "--format", "%{vars}", "element.bst"]
+ )
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.EXPRESSION_FAILED)
@pytest.mark.datafiles(DATA_DIR)
def test_invalid_condition(cli, datafiles):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'invalid-condition')
- result = cli.run(project=project, silent=True, args=[
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'element.bst'])
+ project = os.path.join(datafiles.dirname, datafiles.basename, "invalid-condition")
+ result = cli.run(
+ project=project, silent=True, args=["show", "--deps", "none", "--format", "%{vars}", "element.bst"]
+ )
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize("opt_option,expected_prefix", [
- ('False', '/usr'),
- ('True', '/opt'),
-])
+@pytest.mark.parametrize("opt_option,expected_prefix", [("False", "/usr"), ("True", "/opt"),])
def test_simple_conditional(cli, datafiles, opt_option, expected_prefix):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'simple-condition')
+ project = os.path.join(datafiles.dirname, datafiles.basename, "simple-condition")
# Test with the opt option set
- result = cli.run(project=project, silent=True, args=[
- '--option', 'opt', opt_option,
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'element.bst'])
+ result = cli.run(
+ project=project,
+ silent=True,
+ args=["--option", "opt", opt_option, "show", "--deps", "none", "--format", "%{vars}", "element.bst"],
+ )
result.assert_success()
loaded = _yaml.load_data(result.output)
- assert loaded.get_str('prefix') == expected_prefix
+ assert loaded.get_str("prefix") == expected_prefix
@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize("debug,logging,expected", [
- ('False', 'False', 'False'),
- ('True', 'False', 'False'),
- ('False', 'True', 'False'),
- ('True', 'True', 'True'),
-])
+@pytest.mark.parametrize(
+ "debug,logging,expected",
+ [("False", "False", "False"), ("True", "False", "False"), ("False", "True", "False"), ("True", "True", "True"),],
+)
def test_nested_conditional(cli, datafiles, debug, logging, expected):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'nested-condition')
+ project = os.path.join(datafiles.dirname, datafiles.basename, "nested-condition")
# Test with the opt option set
- result = cli.run(project=project, silent=True, args=[
- '--option', 'debug', debug,
- '--option', 'logging', logging,
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'element.bst'])
+ result = cli.run(
+ project=project,
+ silent=True,
+ args=[
+ "--option",
+ "debug",
+ debug,
+ "--option",
+ "logging",
+ logging,
+ "show",
+ "--deps",
+ "none",
+ "--format",
+ "%{vars}",
+ "element.bst",
+ ],
+ )
result.assert_success()
loaded = _yaml.load_data(result.output)
- assert loaded.get_str('debug') == expected
+ assert loaded.get_str("debug") == expected
@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize("debug,logging,expected", [
- ('False', 'False', 'False'),
- ('True', 'False', 'False'),
- ('False', 'True', 'False'),
- ('True', 'True', 'True'),
-])
+@pytest.mark.parametrize(
+ "debug,logging,expected",
+ [("False", "False", "False"), ("True", "False", "False"), ("False", "True", "False"), ("True", "True", "True"),],
+)
def test_compound_and_conditional(cli, datafiles, debug, logging, expected):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'compound-and-condition')
+ project = os.path.join(datafiles.dirname, datafiles.basename, "compound-and-condition")
# Test with the opt option set
- result = cli.run(project=project, silent=True, args=[
- '--option', 'debug', debug,
- '--option', 'logging', logging,
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'element.bst'])
+ result = cli.run(
+ project=project,
+ silent=True,
+ args=[
+ "--option",
+ "debug",
+ debug,
+ "--option",
+ "logging",
+ logging,
+ "show",
+ "--deps",
+ "none",
+ "--format",
+ "%{vars}",
+ "element.bst",
+ ],
+ )
result.assert_success()
loaded = _yaml.load_data(result.output)
- assert loaded.get_str('debug') == expected
+ assert loaded.get_str("debug") == expected
@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize("debug,logging,expected", [
- ('False', 'False', 'False'),
- ('True', 'False', 'True'),
- ('False', 'True', 'True'),
- ('True', 'True', 'True'),
-])
+@pytest.mark.parametrize(
+ "debug,logging,expected",
+ [("False", "False", "False"), ("True", "False", "True"), ("False", "True", "True"), ("True", "True", "True"),],
+)
def test_compound_or_conditional(cli, datafiles, debug, logging, expected):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'compound-or-condition')
+ project = os.path.join(datafiles.dirname, datafiles.basename, "compound-or-condition")
# Test with the opt option set
- result = cli.run(project=project, silent=True, args=[
- '--option', 'debug', debug,
- '--option', 'logging', logging,
- 'show',
- '--deps', 'none',
- '--format', '%{vars}',
- 'element.bst'])
+ result = cli.run(
+ project=project,
+ silent=True,
+ args=[
+ "--option",
+ "debug",
+ debug,
+ "--option",
+ "logging",
+ logging,
+ "show",
+ "--deps",
+ "none",
+ "--format",
+ "%{vars}",
+ "element.bst",
+ ],
+ )
result.assert_success()
loaded = _yaml.load_data(result.output)
- assert loaded.get_str('logging') == expected
+ assert loaded.get_str("logging") == expected
@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize("option,expected", [
- ('False', 'horsy'),
- ('True', 'pony'),
-])
+@pytest.mark.parametrize("option,expected", [("False", "horsy"), ("True", "pony"),])
def test_deep_nesting_level1(cli, datafiles, option, expected):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'deep-nesting')
- result = cli.run(project=project, silent=True, args=[
- '--option', 'pony', option,
- 'show',
- '--deps', 'none',
- '--format', '%{public}',
- 'element.bst'])
+ project = os.path.join(datafiles.dirname, datafiles.basename, "deep-nesting")
+ result = cli.run(
+ project=project,
+ silent=True,
+ args=["--option", "pony", option, "show", "--deps", "none", "--format", "%{public}", "element.bst"],
+ )
result.assert_success()
loaded = _yaml.load_data(result.output)
- shallow_list = loaded.get_sequence('shallow-nest')
+ shallow_list = loaded.get_sequence("shallow-nest")
first_dict = shallow_list.mapping_at(0)
- assert first_dict.get_str('animal') == expected
+ assert first_dict.get_str("animal") == expected
@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize("option,expected", [
- ('False', 'horsy'),
- ('True', 'pony'),
-])
+@pytest.mark.parametrize("option,expected", [("False", "horsy"), ("True", "pony"),])
def test_deep_nesting_level2(cli, datafiles, option, expected):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'deep-nesting')
- result = cli.run(project=project, silent=True, args=[
- '--option', 'pony', option,
- 'show',
- '--deps', 'none',
- '--format', '%{public}',
- 'element-deeper.bst'])
+ project = os.path.join(datafiles.dirname, datafiles.basename, "deep-nesting")
+ result = cli.run(
+ project=project,
+ silent=True,
+ args=["--option", "pony", option, "show", "--deps", "none", "--format", "%{public}", "element-deeper.bst"],
+ )
result.assert_success()
loaded = _yaml.load_data(result.output)
- shallow_list = loaded.get_sequence('deep-nest')
+ shallow_list = loaded.get_sequence("deep-nest")
deeper_list = shallow_list.sequence_at(0)
first_dict = deeper_list.mapping_at(0)
- assert first_dict.get_str('animal') == expected
+ assert first_dict.get_str("animal") == expected
diff --git a/tests/format/project.py b/tests/format/project.py
index 2e0a729dc..e6bc6a5cd 100644
--- a/tests/format/project.py
+++ b/tests/format/project.py
@@ -11,30 +11,27 @@ from tests.testutils import filetypegenerator
# Project directory
-DATA_DIR = os.path.join(
- os.path.dirname(os.path.realpath(__file__)),
- "project"
-)
+DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project")
@pytest.mark.datafiles(os.path.join(DATA_DIR))
def test_missing_project_conf(cli, datafiles):
project = str(datafiles)
- result = cli.run(project=project, args=['workspace', 'list'])
+ result = cli.run(project=project, args=["workspace", "list"])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.MISSING_PROJECT_CONF)
@pytest.mark.datafiles(os.path.join(DATA_DIR))
def test_missing_project_name(cli, datafiles):
project = os.path.join(datafiles.dirname, datafiles.basename, "missingname")
- result = cli.run(project=project, args=['workspace', 'list'])
+ result = cli.run(project=project, args=["workspace", "list"])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
@pytest.mark.datafiles(os.path.join(DATA_DIR))
def test_missing_element(cli, datafiles):
project = os.path.join(datafiles.dirname, datafiles.basename, "missing-element")
- result = cli.run(project=project, args=['show', 'manual.bst'])
+ result = cli.run(project=project, args=["show", "manual.bst"])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.MISSING_FILE)
# Assert that we have the expected provenance encoded into the error
@@ -44,7 +41,7 @@ def test_missing_element(cli, datafiles):
@pytest.mark.datafiles(os.path.join(DATA_DIR))
def test_missing_junction(cli, datafiles):
project = os.path.join(datafiles.dirname, datafiles.basename, "missing-junction")
- result = cli.run(project=project, args=['show', 'manual.bst'])
+ result = cli.run(project=project, args=["show", "manual.bst"])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.MISSING_FILE)
# Assert that we have the expected provenance encoded into the error
@@ -54,176 +51,156 @@ def test_missing_junction(cli, datafiles):
@pytest.mark.datafiles(os.path.join(DATA_DIR))
def test_empty_project_name(cli, datafiles):
project = os.path.join(datafiles.dirname, datafiles.basename, "emptyname")
- result = cli.run(project=project, args=['workspace', 'list'])
+ result = cli.run(project=project, args=["workspace", "list"])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_SYMBOL_NAME)
@pytest.mark.datafiles(os.path.join(DATA_DIR))
def test_invalid_project_name(cli, datafiles):
project = os.path.join(datafiles.dirname, datafiles.basename, "invalidname")
- result = cli.run(project=project, args=['workspace', 'list'])
+ result = cli.run(project=project, args=["workspace", "list"])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_SYMBOL_NAME)
@pytest.mark.datafiles(os.path.join(DATA_DIR))
def test_invalid_yaml(cli, datafiles):
project = os.path.join(datafiles.dirname, datafiles.basename, "invalid-yaml")
- result = cli.run(project=project, args=['workspace', 'list'])
+ result = cli.run(project=project, args=["workspace", "list"])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_YAML)
@pytest.mark.datafiles(os.path.join(DATA_DIR))
def test_load_default_project(cli, datafiles):
project = os.path.join(datafiles.dirname, datafiles.basename, "default")
- result = cli.run(project=project, args=[
- 'show', '--format', '%{env}', 'manual.bst'
- ])
+ result = cli.run(project=project, args=["show", "--format", "%{env}", "manual.bst"])
result.assert_success()
# Read back some of our project defaults from the env
env = _yaml.load_data(result.output)
- assert env.get_str('USER') == "tomjon"
- assert env.get_str('TERM') == "dumb"
+ assert env.get_str("USER") == "tomjon"
+ assert env.get_str("TERM") == "dumb"
@pytest.mark.datafiles(os.path.join(DATA_DIR))
def test_load_project_from_subdir(cli, datafiles):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'project-from-subdir')
+ project = os.path.join(datafiles.dirname, datafiles.basename, "project-from-subdir")
result = cli.run(
- project=project,
- cwd=os.path.join(project, 'subdirectory'),
- args=['show', '--format', '%{env}', 'manual.bst'])
+ project=project, cwd=os.path.join(project, "subdirectory"), args=["show", "--format", "%{env}", "manual.bst"]
+ )
result.assert_success()
# Read back some of our project defaults from the env
env = _yaml.load_data(result.output)
- assert env.get_str('USER') == "tomjon"
- assert env.get_str('TERM') == "dumb"
+ assert env.get_str("USER") == "tomjon"
+ assert env.get_str("TERM") == "dumb"
@pytest.mark.datafiles(os.path.join(DATA_DIR))
def test_override_project_path(cli, datafiles):
project = os.path.join(datafiles.dirname, datafiles.basename, "overridepath")
- result = cli.run(project=project, args=[
- 'show', '--format', '%{env}', 'manual.bst'
- ])
+ result = cli.run(project=project, args=["show", "--format", "%{env}", "manual.bst"])
result.assert_success()
# Read back the overridden path
env = _yaml.load_data(result.output)
- assert env.get_str('PATH') == "/bin:/sbin"
+ assert env.get_str("PATH") == "/bin:/sbin"
@pytest.mark.datafiles(os.path.join(DATA_DIR))
def test_project_unsupported(cli, datafiles):
project = os.path.join(datafiles.dirname, datafiles.basename, "unsupported")
- result = cli.run(project=project, args=['workspace', 'list'])
+ result = cli.run(project=project, args=["workspace", "list"])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.UNSUPPORTED_PROJECT)
-@pytest.mark.datafiles(os.path.join(DATA_DIR, 'element-path'))
+@pytest.mark.datafiles(os.path.join(DATA_DIR, "element-path"))
def test_missing_element_path_directory(cli, datafiles):
project = str(datafiles)
- result = cli.run(project=project, args=['workspace', 'list'])
- result.assert_main_error(ErrorDomain.LOAD,
- LoadErrorReason.MISSING_FILE)
+ result = cli.run(project=project, args=["workspace", "list"])
+ result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.MISSING_FILE)
-@pytest.mark.datafiles(os.path.join(DATA_DIR, 'element-path'))
+@pytest.mark.datafiles(os.path.join(DATA_DIR, "element-path"))
def test_element_path_not_a_directory(cli, datafiles):
project = str(datafiles)
- path = os.path.join(project, 'elements')
+ path = os.path.join(project, "elements")
for _file_type in filetypegenerator.generate_file_types(path):
- result = cli.run(project=project, args=['workspace', 'list'])
+ result = cli.run(project=project, args=["workspace", "list"])
if not os.path.isdir(path):
- result.assert_main_error(ErrorDomain.LOAD,
- LoadErrorReason.PROJ_PATH_INVALID_KIND)
+ result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.PROJ_PATH_INVALID_KIND)
else:
result.assert_success()
-@pytest.mark.datafiles(os.path.join(DATA_DIR, 'local-plugin'))
+@pytest.mark.datafiles(os.path.join(DATA_DIR, "local-plugin"))
def test_missing_local_plugin_directory(cli, datafiles):
project = str(datafiles)
- result = cli.run(project=project, args=['workspace', 'list'])
- result.assert_main_error(ErrorDomain.LOAD,
- LoadErrorReason.MISSING_FILE)
+ result = cli.run(project=project, args=["workspace", "list"])
+ result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.MISSING_FILE)
-@pytest.mark.datafiles(os.path.join(DATA_DIR, 'local-plugin'))
+@pytest.mark.datafiles(os.path.join(DATA_DIR, "local-plugin"))
def test_local_plugin_not_directory(cli, datafiles):
project = str(datafiles)
- path = os.path.join(project, 'plugins')
+ path = os.path.join(project, "plugins")
for _file_type in filetypegenerator.generate_file_types(path):
- result = cli.run(project=project, args=['workspace', 'list'])
+ result = cli.run(project=project, args=["workspace", "list"])
if not os.path.isdir(path):
- result.assert_main_error(ErrorDomain.LOAD,
- LoadErrorReason.PROJ_PATH_INVALID_KIND)
+ result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.PROJ_PATH_INVALID_KIND)
else:
result.assert_success()
@pytest.mark.datafiles(DATA_DIR)
def test_plugin_load_allowed(cli, datafiles):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'plugin-allowed')
- result = cli.run(project=project, silent=True, args=[
- 'show', 'element.bst'])
+ project = os.path.join(datafiles.dirname, datafiles.basename, "plugin-allowed")
+ result = cli.run(project=project, silent=True, args=["show", "element.bst"])
result.assert_success()
@pytest.mark.datafiles(DATA_DIR)
def test_plugin_load_forbidden(cli, datafiles):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'plugin-forbidden')
- result = cli.run(project=project, silent=True, args=[
- 'show', 'element.bst'])
+ project = os.path.join(datafiles.dirname, datafiles.basename, "plugin-forbidden")
+ result = cli.run(project=project, silent=True, args=["show", "element.bst"])
result.assert_main_error(ErrorDomain.PLUGIN, None)
@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize("ref_storage", [('inline'), ('project.refs')])
+@pytest.mark.parametrize("ref_storage", [("inline"), ("project.refs")])
def test_plugin_no_load_ref(cli, datafiles, ref_storage):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'plugin-no-load-ref')
+ project = os.path.join(datafiles.dirname, datafiles.basename, "plugin-no-load-ref")
# Generate project with access to the noloadref plugin and project.refs enabled
#
config = {
- 'name': 'test',
- 'ref-storage': ref_storage,
- 'plugins': [
- {
- 'origin': 'local',
- 'path': 'plugins',
- 'sources': {
- 'noloadref': 0
- }
- }
- ]
+ "name": "test",
+ "ref-storage": ref_storage,
+ "plugins": [{"origin": "local", "path": "plugins", "sources": {"noloadref": 0}}],
}
- _yaml.roundtrip_dump(config, os.path.join(project, 'project.conf'))
+ _yaml.roundtrip_dump(config, os.path.join(project, "project.conf"))
- result = cli.run(project=project, silent=True, args=['show', 'noloadref.bst'])
+ result = cli.run(project=project, silent=True, args=["show", "noloadref.bst"])
# There is no error if project.refs is not in use, otherwise we
# assert our graceful failure
- if ref_storage == 'inline':
+ if ref_storage == "inline":
result.assert_success()
else:
- result.assert_main_error(ErrorDomain.SOURCE, 'unsupported-load-ref')
+ result.assert_main_error(ErrorDomain.SOURCE, "unsupported-load-ref")
@pytest.mark.datafiles(DATA_DIR)
def test_plugin_preflight_error(cli, datafiles):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'plugin-preflight-error')
- result = cli.run(project=project, args=['source', 'fetch', 'error.bst'])
+ project = os.path.join(datafiles.dirname, datafiles.basename, "plugin-preflight-error")
+ result = cli.run(project=project, args=["source", "fetch", "error.bst"])
result.assert_main_error(ErrorDomain.SOURCE, "the-preflight-error")
@pytest.mark.datafiles(DATA_DIR)
def test_duplicate_plugins(cli, datafiles):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'duplicate-plugins')
- result = cli.run(project=project, silent=True, args=[
- 'show', 'element.bst'])
+ project = os.path.join(datafiles.dirname, datafiles.basename, "duplicate-plugins")
+ result = cli.run(project=project, silent=True, args=["show", "element.bst"])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_YAML)
@@ -232,42 +209,40 @@ def test_duplicate_plugins(cli, datafiles):
#
@pytest.mark.datafiles(DATA_DIR)
def test_project_refs_options(cli, datafiles):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'refs-options')
-
- result1 = cli.run(project=project, silent=True, args=[
- '--option', 'test', 'True',
- 'show',
- '--deps', 'none',
- '--format', '%{key}',
- 'target.bst'])
+ project = os.path.join(datafiles.dirname, datafiles.basename, "refs-options")
+
+ result1 = cli.run(
+ project=project,
+ silent=True,
+ args=["--option", "test", "True", "show", "--deps", "none", "--format", "%{key}", "target.bst"],
+ )
result1.assert_success()
- result2 = cli.run(project=project, silent=True, args=[
- '--option', 'test', 'False',
- 'show',
- '--deps', 'none',
- '--format', '%{key}',
- 'target.bst'])
+ result2 = cli.run(
+ project=project,
+ silent=True,
+ args=["--option", "test", "False", "show", "--deps", "none", "--format", "%{key}", "target.bst"],
+ )
result2.assert_success()
# Assert that the cache keys are different
assert result1.output != result2.output
-@pytest.mark.datafiles(os.path.join(DATA_DIR, 'element-path'))
+@pytest.mark.datafiles(os.path.join(DATA_DIR, "element-path"))
def test_element_path_project_path_contains_symlinks(cli, datafiles, tmpdir):
real_project = str(datafiles)
- linked_project = os.path.join(str(tmpdir), 'linked')
+ linked_project = os.path.join(str(tmpdir), "linked")
os.symlink(real_project, linked_project)
- os.makedirs(os.path.join(real_project, 'elements'), exist_ok=True)
- with open(os.path.join(real_project, 'elements', 'element.bst'), 'w') as f:
+ os.makedirs(os.path.join(real_project, "elements"), exist_ok=True)
+ with open(os.path.join(real_project, "elements", "element.bst"), "w") as f:
f.write("kind: manual\n")
- result = cli.run(project=linked_project, args=['show', 'element.bst'])
+ result = cli.run(project=linked_project, args=["show", "element.bst"])
result.assert_success()
@pytest.mark.datafiles(os.path.join(DATA_DIR))
def test_empty_depends(cli, datafiles):
project = os.path.join(datafiles.dirname, datafiles.basename, "empty-depends")
- result = cli.run(project=project, args=['show', 'manual.bst'])
+ result = cli.run(project=project, args=["show", "manual.bst"])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
diff --git a/tests/format/project/plugin-no-load-ref/plugins/noloadref.py b/tests/format/project/plugin-no-load-ref/plugins/noloadref.py
index 0cc457f07..5d44cd5c7 100644
--- a/tests/format/project/plugin-no-load-ref/plugins/noloadref.py
+++ b/tests/format/project/plugin-no-load-ref/plugins/noloadref.py
@@ -6,7 +6,6 @@ from buildstream import Source, Consistency
# Use this to test that the core behaves as expected with such plugins.
#
class NoLoadRefSource(Source):
-
def configure(self, node):
pass
diff --git a/tests/format/project/plugin-preflight-error/errorplugin/preflighterror.py b/tests/format/project/plugin-preflight-error/errorplugin/preflighterror.py
index 0eee463ad..3fa8afb93 100644
--- a/tests/format/project/plugin-preflight-error/errorplugin/preflighterror.py
+++ b/tests/format/project/plugin-preflight-error/errorplugin/preflighterror.py
@@ -2,15 +2,13 @@ from buildstream import Source, SourceError, Consistency
class PreflightErrorSource(Source):
-
def configure(self, node):
pass
def preflight(self):
# Raise a preflight error unconditionally
- raise SourceError("Unsatisfied requirements in preflight, raising this error",
- reason="the-preflight-error")
+ raise SourceError("Unsatisfied requirements in preflight, raising this error", reason="the-preflight-error")
def get_unique_key(self):
return {}
diff --git a/tests/format/projectoverrides.py b/tests/format/projectoverrides.py
index 7932ffb4a..16aad2cf8 100644
--- a/tests/format/projectoverrides.py
+++ b/tests/format/projectoverrides.py
@@ -7,23 +7,18 @@ from buildstream import _yaml
from buildstream.testing.runcli import cli # pylint: disable=unused-import
# Project directory
-DATA_DIR = os.path.join(
- os.path.dirname(os.path.realpath(__file__)),
- "project-overrides"
-)
+DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project-overrides")
@pytest.mark.datafiles(DATA_DIR)
def test_prepend_configure_commands(cli, datafiles):
- project = os.path.join(datafiles.dirname, datafiles.basename, 'prepend-configure-commands')
- result = cli.run(project=project, silent=True, args=[
- 'show',
- '--deps', 'none',
- '--format', '%{config}',
- 'element.bst'])
+ project = os.path.join(datafiles.dirname, datafiles.basename, "prepend-configure-commands")
+ result = cli.run(
+ project=project, silent=True, args=["show", "--deps", "none", "--format", "%{config}", "element.bst"]
+ )
result.assert_success()
loaded = _yaml.load_data(result.output)
- config_commands = loaded.get_str_list('configure-commands')
+ config_commands = loaded.get_str_list("configure-commands")
assert len(config_commands) == 3
assert config_commands[0] == 'echo "Hello World!"'
diff --git a/tests/format/userconfig.py b/tests/format/userconfig.py
index 72172a24d..9b514cc3d 100644
--- a/tests/format/userconfig.py
+++ b/tests/format/userconfig.py
@@ -14,11 +14,7 @@ DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project")
@pytest.mark.datafiles(DATA_DIR)
def test_ensure_misformed_project_overrides_give_sensible_errors(cli, datafiles):
- userconfig = {
- "projects": {
- "test": []
- }
- }
+ userconfig = {"projects": {"test": []}}
cli.configure(userconfig)
result = cli.run(project=datafiles, args=["show"])
diff --git a/tests/format/variables.py b/tests/format/variables.py
index 4610e039f..35b105f66 100644
--- a/tests/format/variables.py
+++ b/tests/format/variables.py
@@ -12,13 +12,10 @@ from buildstream.testing.runcli import cli # pylint: disable=unused-import
# Project directory
-DATA_DIR = os.path.join(
- os.path.dirname(os.path.realpath(__file__)),
- "variables"
-)
+DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "variables")
# List of BuildStream protected variables
-PROTECTED_VARIABLES = [('project-name'), ('element-name'), ('max-jobs')]
+PROTECTED_VARIABLES = [("project-name"), ("element-name"), ("max-jobs")]
def print_warning(msg):
@@ -29,24 +26,31 @@ def print_warning(msg):
###############################################################
# Test proper loading of some default commands from plugins #
###############################################################
-@pytest.mark.parametrize("target,varname,expected", [
- ('autotools.bst', 'make-install', "make -j1 DESTDIR=\"/buildstream-install\" install"),
- ('cmake.bst', 'cmake',
- "cmake -B_builddir -H\".\" -G\"Unix Makefiles\" " + "-DCMAKE_INSTALL_PREFIX:PATH=\"/usr\" \\\n" +
- "-DCMAKE_INSTALL_LIBDIR:PATH=\"lib\""),
- ('distutils.bst', 'python-install',
- "python3 ./setup.py install --prefix \"/usr\" \\\n" +
- "--root \"/buildstream-install\""),
- ('makemaker.bst', 'configure', "perl Makefile.PL PREFIX=/buildstream-install/usr"),
- ('modulebuild.bst', 'configure', "perl Build.PL --prefix \"/buildstream-install/usr\""),
- ('qmake.bst', 'make-install', "make -j1 INSTALL_ROOT=\"/buildstream-install\" install"),
-])
-@pytest.mark.datafiles(os.path.join(DATA_DIR, 'defaults'))
+@pytest.mark.parametrize(
+ "target,varname,expected",
+ [
+ ("autotools.bst", "make-install", 'make -j1 DESTDIR="/buildstream-install" install'),
+ (
+ "cmake.bst",
+ "cmake",
+ 'cmake -B_builddir -H"." -G"Unix Makefiles" '
+ + '-DCMAKE_INSTALL_PREFIX:PATH="/usr" \\\n'
+ + '-DCMAKE_INSTALL_LIBDIR:PATH="lib"',
+ ),
+ (
+ "distutils.bst",
+ "python-install",
+ 'python3 ./setup.py install --prefix "/usr" \\\n' + '--root "/buildstream-install"',
+ ),
+ ("makemaker.bst", "configure", "perl Makefile.PL PREFIX=/buildstream-install/usr"),
+ ("modulebuild.bst", "configure", 'perl Build.PL --prefix "/buildstream-install/usr"'),
+ ("qmake.bst", "make-install", 'make -j1 INSTALL_ROOT="/buildstream-install" install'),
+ ],
+)
+@pytest.mark.datafiles(os.path.join(DATA_DIR, "defaults"))
def test_defaults(cli, datafiles, target, varname, expected):
project = str(datafiles)
- result = cli.run(project=project, silent=True, args=[
- 'show', '--deps', 'none', '--format', '%{vars}', target
- ])
+ result = cli.run(project=project, silent=True, args=["show", "--deps", "none", "--format", "%{vars}", target])
result.assert_success()
result_vars = _yaml.load_data(result.output)
assert result_vars.get_str(varname) == expected
@@ -55,130 +59,97 @@ def test_defaults(cli, datafiles, target, varname, expected):
################################################################
# Test overriding of variables to produce different commands #
################################################################
-@pytest.mark.parametrize("target,varname,expected", [
- ('autotools.bst', 'make-install', "make -j1 DESTDIR=\"/custom/install/root\" install"),
- ('cmake.bst', 'cmake',
- "cmake -B_builddir -H\".\" -G\"Ninja\" " + "-DCMAKE_INSTALL_PREFIX:PATH=\"/opt\" \\\n" +
- "-DCMAKE_INSTALL_LIBDIR:PATH=\"lib\""),
- ('distutils.bst', 'python-install',
- "python3 ./setup.py install --prefix \"/opt\" \\\n" +
- "--root \"/custom/install/root\""),
- ('makemaker.bst', 'configure', "perl Makefile.PL PREFIX=/custom/install/root/opt"),
- ('modulebuild.bst', 'configure', "perl Build.PL --prefix \"/custom/install/root/opt\""),
- ('qmake.bst', 'make-install', "make -j1 INSTALL_ROOT=\"/custom/install/root\" install"),
-])
-@pytest.mark.datafiles(os.path.join(DATA_DIR, 'overrides'))
+@pytest.mark.parametrize(
+ "target,varname,expected",
+ [
+ ("autotools.bst", "make-install", 'make -j1 DESTDIR="/custom/install/root" install'),
+ (
+ "cmake.bst",
+ "cmake",
+ 'cmake -B_builddir -H"." -G"Ninja" '
+ + '-DCMAKE_INSTALL_PREFIX:PATH="/opt" \\\n'
+ + '-DCMAKE_INSTALL_LIBDIR:PATH="lib"',
+ ),
+ (
+ "distutils.bst",
+ "python-install",
+ 'python3 ./setup.py install --prefix "/opt" \\\n' + '--root "/custom/install/root"',
+ ),
+ ("makemaker.bst", "configure", "perl Makefile.PL PREFIX=/custom/install/root/opt"),
+ ("modulebuild.bst", "configure", 'perl Build.PL --prefix "/custom/install/root/opt"'),
+ ("qmake.bst", "make-install", 'make -j1 INSTALL_ROOT="/custom/install/root" install'),
+ ],
+)
+@pytest.mark.datafiles(os.path.join(DATA_DIR, "overrides"))
def test_overrides(cli, datafiles, target, varname, expected):
project = str(datafiles)
- result = cli.run(project=project, silent=True, args=[
- 'show', '--deps', 'none', '--format', '%{vars}', target
- ])
+ result = cli.run(project=project, silent=True, args=["show", "--deps", "none", "--format", "%{vars}", target])
result.assert_success()
result_vars = _yaml.load_data(result.output)
assert result_vars.get_str(varname) == expected
@pytest.mark.parametrize("element", ["manual.bst", "manual2.bst"])
-@pytest.mark.datafiles(os.path.join(DATA_DIR, 'missing_variables'))
+@pytest.mark.datafiles(os.path.join(DATA_DIR, "missing_variables"))
def test_missing_variable(cli, datafiles, element):
project = str(datafiles)
- result = cli.run(project=project, silent=True, args=[
- 'show', '--deps', 'none', '--format', '%{config}', element
- ])
- result.assert_main_error(ErrorDomain.LOAD,
- LoadErrorReason.UNRESOLVED_VARIABLE)
+ result = cli.run(project=project, silent=True, args=["show", "--deps", "none", "--format", "%{config}", element])
+ result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.UNRESOLVED_VARIABLE)
@pytest.mark.timeout(3, method="signal")
-@pytest.mark.datafiles(os.path.join(DATA_DIR, 'cyclic_variables'))
+@pytest.mark.datafiles(os.path.join(DATA_DIR, "cyclic_variables"))
def test_cyclic_variables(cli, datafiles):
- print_warning("Performing cyclic test, if this test times out it will " +
- "exit the test sequence")
+ print_warning("Performing cyclic test, if this test times out it will " + "exit the test sequence")
project = str(datafiles)
- result = cli.run(project=project, silent=True, args=[
- "build", "cyclic.bst"
- ])
+ result = cli.run(project=project, silent=True, args=["build", "cyclic.bst"])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.RECURSIVE_VARIABLE)
-@pytest.mark.parametrize('protected_var', PROTECTED_VARIABLES)
-@pytest.mark.datafiles(os.path.join(DATA_DIR, 'protected-vars'))
+@pytest.mark.parametrize("protected_var", PROTECTED_VARIABLES)
+@pytest.mark.datafiles(os.path.join(DATA_DIR, "protected-vars"))
def test_use_of_protected_var_project_conf(cli, datafiles, protected_var):
project = str(datafiles)
- conf = {
- 'name': 'test',
- 'variables': {
- protected_var: 'some-value'
- }
- }
- _yaml.roundtrip_dump(conf, os.path.join(project, 'project.conf'))
+ conf = {"name": "test", "variables": {protected_var: "some-value"}}
+ _yaml.roundtrip_dump(conf, os.path.join(project, "project.conf"))
element = {
- 'kind': 'import',
- 'sources': [
- {
- 'kind': 'local',
- 'path': 'foo.txt'
- }
- ],
+ "kind": "import",
+ "sources": [{"kind": "local", "path": "foo.txt"}],
}
- _yaml.roundtrip_dump(element, os.path.join(project, 'target.bst'))
+ _yaml.roundtrip_dump(element, os.path.join(project, "target.bst"))
- result = cli.run(project=project, args=['build', 'target.bst'])
- result.assert_main_error(ErrorDomain.LOAD,
- LoadErrorReason.PROTECTED_VARIABLE_REDEFINED)
+ result = cli.run(project=project, args=["build", "target.bst"])
+ result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.PROTECTED_VARIABLE_REDEFINED)
-@pytest.mark.parametrize('protected_var', PROTECTED_VARIABLES)
-@pytest.mark.datafiles(os.path.join(DATA_DIR, 'protected-vars'))
+@pytest.mark.parametrize("protected_var", PROTECTED_VARIABLES)
+@pytest.mark.datafiles(os.path.join(DATA_DIR, "protected-vars"))
def test_use_of_protected_var_element_overrides(cli, datafiles, protected_var):
project = str(datafiles)
- conf = {
- 'name': 'test',
- 'elements': {
- 'manual': {
- 'variables': {
- protected_var: 'some-value'
- }
- }
- }
- }
- _yaml.roundtrip_dump(conf, os.path.join(project, 'project.conf'))
+ conf = {"name": "test", "elements": {"manual": {"variables": {protected_var: "some-value"}}}}
+ _yaml.roundtrip_dump(conf, os.path.join(project, "project.conf"))
element = {
- 'kind': 'manual',
- 'sources': [
- {
- 'kind': 'local',
- 'path': 'foo.txt'
- }
- ],
+ "kind": "manual",
+ "sources": [{"kind": "local", "path": "foo.txt"}],
}
- _yaml.roundtrip_dump(element, os.path.join(project, 'target.bst'))
+ _yaml.roundtrip_dump(element, os.path.join(project, "target.bst"))
- result = cli.run(project=project, args=['build', 'target.bst'])
- result.assert_main_error(ErrorDomain.LOAD,
- LoadErrorReason.PROTECTED_VARIABLE_REDEFINED)
+ result = cli.run(project=project, args=["build", "target.bst"])
+ result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.PROTECTED_VARIABLE_REDEFINED)
-@pytest.mark.parametrize('protected_var', PROTECTED_VARIABLES)
-@pytest.mark.datafiles(os.path.join(DATA_DIR, 'protected-vars'))
+@pytest.mark.parametrize("protected_var", PROTECTED_VARIABLES)
+@pytest.mark.datafiles(os.path.join(DATA_DIR, "protected-vars"))
def test_use_of_protected_var_in_element(cli, datafiles, protected_var):
project = str(datafiles)
element = {
- 'kind': 'import',
- 'sources': [
- {
- 'kind': 'local',
- 'path': 'foo.txt'
- }
- ],
- 'variables': {
- protected_var: 'some-value'
- }
+ "kind": "import",
+ "sources": [{"kind": "local", "path": "foo.txt"}],
+ "variables": {protected_var: "some-value"},
}
- _yaml.roundtrip_dump(element, os.path.join(project, 'target.bst'))
+ _yaml.roundtrip_dump(element, os.path.join(project, "target.bst"))
- result = cli.run(project=project, args=['build', 'target.bst'])
- result.assert_main_error(ErrorDomain.LOAD,
- LoadErrorReason.PROTECTED_VARIABLE_REDEFINED)
+ result = cli.run(project=project, args=["build", "target.bst"])
+ result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.PROTECTED_VARIABLE_REDEFINED)