summaryrefslogtreecommitdiff
path: root/tests/elements
diff options
context:
space:
mode:
authorAngelos Evripiotis <jevripiotis@bloomberg.net>2019-03-20 11:06:42 +0000
committerbst-marge-bot <marge-bot@buildstream.build>2019-03-21 14:57:31 +0000
commitf2b15d86debd32241228f7b728016ed0057cd0d2 (patch)
treee98e085e4f0a9020725aa3a25df7809a96d807ba /tests/elements
parentbc1b971e169f2fc721c61276c071640caee6a3f8 (diff)
downloadbuildstream-f2b15d86debd32241228f7b728016ed0057cd0d2.tar.gz
tests: str(datafiles) instead of a longer thing
Replace some popular copypasta. This important-looking invocation: os.path.join(datafiles.dirname, datafiles.basename) is equivalent to this shorter invocation: project = str(datafiles) It seems like it's very popular copypasta, replace it with the shorter one thus: # Use 'gsed' or 'sed' etc. as appropriate for your system. git config --global alias.sub '!f() { git grep --name-only --null "$1" | gxargs --null gsed --in-place --expression "s/$1/$2/g" ; }; f' git sub 'os.path.join(datafiles.dirname, datafiles.basename)' 'str(datafiles)'
Diffstat (limited to 'tests/elements')
-rw-r--r--tests/elements/filter.py32
1 files changed, 16 insertions, 16 deletions
diff --git a/tests/elements/filter.py b/tests/elements/filter.py
index 94a704c92..56e4c2b5a 100644
--- a/tests/elements/filter.py
+++ b/tests/elements/filter.py
@@ -19,7 +19,7 @@ DATA_DIR = os.path.join(
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
def test_filter_include(datafiles, cli, tmpdir):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
result = cli.run(project=project, args=['build', 'output-include.bst'])
result.assert_success()
@@ -32,7 +32,7 @@ def test_filter_include(datafiles, cli, tmpdir):
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
def test_filter_include_dynamic(datafiles, cli, tmpdir):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
result = cli.run(project=project, args=['build', 'output-dynamic-include.bst'])
result.assert_success()
@@ -46,7 +46,7 @@ def test_filter_include_dynamic(datafiles, cli, tmpdir):
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
def test_filter_exclude(datafiles, cli, tmpdir):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
result = cli.run(project=project, args=['build', 'output-exclude.bst'])
result.assert_success()
@@ -59,7 +59,7 @@ def test_filter_exclude(datafiles, cli, tmpdir):
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
def test_filter_orphans(datafiles, cli, tmpdir):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
result = cli.run(project=project, args=['build', 'output-orphans.bst'])
result.assert_success()
@@ -71,7 +71,7 @@ def test_filter_orphans(datafiles, cli, tmpdir):
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
def test_filter_deps_ok(datafiles, cli):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
result = cli.run(project=project, args=['build', 'deps-permitted.bst'])
result.assert_success()
@@ -85,35 +85,35 @@ def test_filter_deps_ok(datafiles, cli):
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
def test_filter_forbid_sources(datafiles, cli):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
result = cli.run(project=project, args=['build', 'forbidden-source.bst'])
result.assert_main_error(ErrorDomain.ELEMENT, 'element-forbidden-sources')
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
def test_filter_forbid_multi_bdep(datafiles, cli):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
result = cli.run(project=project, args=['build', 'forbidden-multi-bdep.bst'])
result.assert_main_error(ErrorDomain.ELEMENT, 'filter-bdepend-wrong-count')
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
def test_filter_forbid_no_bdep(datafiles, cli):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
result = cli.run(project=project, args=['build', 'forbidden-no-bdep.bst'])
result.assert_main_error(ErrorDomain.ELEMENT, 'filter-bdepend-wrong-count')
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
def test_filter_forbid_also_rdep(datafiles, cli):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
result = cli.run(project=project, args=['build', 'forbidden-also-rdep.bst'])
result.assert_main_error(ErrorDomain.ELEMENT, 'filter-bdepend-also-rdepend')
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
def test_filter_workspace_open(datafiles, cli, tmpdir):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
workspace_dir = os.path.join(tmpdir.dirname, tmpdir.basename, "workspace")
result = cli.run(project=project, args=['workspace', 'open', '--directory', workspace_dir, 'deps-permitted.bst'])
result.assert_success()
@@ -124,7 +124,7 @@ def test_filter_workspace_open(datafiles, cli, tmpdir):
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
def test_filter_workspace_open_multi(datafiles, cli):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
result = cli.run(cwd=project, project=project, args=['workspace', 'open', 'deps-permitted.bst',
'output-orphans.bst'])
result.assert_success()
@@ -133,7 +133,7 @@ def test_filter_workspace_open_multi(datafiles, cli):
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
def test_filter_workspace_build(datafiles, cli, tmpdir):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
tempdir = os.path.join(tmpdir.dirname, tmpdir.basename)
workspace_dir = os.path.join(tempdir, "workspace")
result = cli.run(project=project, args=['workspace', 'open', '--directory', workspace_dir, 'output-orphans.bst'])
@@ -151,7 +151,7 @@ def test_filter_workspace_build(datafiles, cli, tmpdir):
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
def test_filter_workspace_close(datafiles, cli, tmpdir):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
tempdir = os.path.join(tmpdir.dirname, tmpdir.basename)
workspace_dir = os.path.join(tempdir, "workspace")
result = cli.run(project=project, args=['workspace', 'open', '--directory', workspace_dir, 'output-orphans.bst'])
@@ -171,7 +171,7 @@ def test_filter_workspace_close(datafiles, cli, tmpdir):
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
def test_filter_workspace_reset(datafiles, cli, tmpdir):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
tempdir = os.path.join(tmpdir.dirname, tmpdir.basename)
workspace_dir = os.path.join(tempdir, "workspace")
result = cli.run(project=project, args=['workspace', 'open', '--directory', workspace_dir, 'output-orphans.bst'])
@@ -474,7 +474,7 @@ def test_filter_track_multi_exclude(datafiles, cli, tmpdir):
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
def test_filter_include_with_indirect_deps(datafiles, cli, tmpdir):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
result = cli.run(project=project, args=[
'build', 'output-include-with-indirect-deps.bst'])
result.assert_success()
@@ -494,7 +494,7 @@ def test_filter_include_with_indirect_deps(datafiles, cli, tmpdir):
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
def test_filter_fails_for_nonexisting_domain(datafiles, cli):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
result = cli.run(project=project, args=['build', 'output-include-nonexistent-domain.bst'])
result.assert_main_error(ErrorDomain.STREAM, None)