summaryrefslogtreecommitdiff
path: root/tests/integration/shell.py
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/integration/shell.py
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/integration/shell.py')
-rw-r--r--tests/integration/shell.py30
1 files changed, 15 insertions, 15 deletions
diff --git a/tests/integration/shell.py b/tests/integration/shell.py
index 3246d108a..fb01f45ea 100644
--- a/tests/integration/shell.py
+++ b/tests/integration/shell.py
@@ -49,7 +49,7 @@ def execute_shell(cli, project, command, *, config=None, mount=None, element='ba
@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.skipif(not HAVE_SANDBOX, reason='Only available with a functioning sandbox')
def test_shell(cli, datafiles):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
result = execute_shell(cli, project, ["echo", "Ponies!"])
assert result.exit_code == 0
@@ -60,7 +60,7 @@ def test_shell(cli, datafiles):
@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.skipif(not HAVE_SANDBOX, reason='Only available with a functioning sandbox')
def test_executable(cli, datafiles):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
result = execute_shell(cli, project, ["/bin/echo", "Horseys!"])
assert result.exit_code == 0
@@ -72,7 +72,7 @@ def test_executable(cli, datafiles):
@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.skipif(not HAVE_SANDBOX, reason='Only available with a functioning sandbox')
def test_env_assign(cli, datafiles, animal):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
expected = animal + '\n'
result = execute_shell(cli, project, ['/bin/sh', '-c', 'echo ${ANIMAL}'], config={
@@ -92,7 +92,7 @@ def test_env_assign(cli, datafiles, animal):
@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.skipif(not HAVE_SANDBOX, reason='Only available with a functioning sandbox')
def test_env_assign_expand_host_environ(cli, datafiles, animal):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
expected = 'The animal is: {}\n'.format(animal)
os.environ['BEAST'] = animal
@@ -115,7 +115,7 @@ def test_env_assign_expand_host_environ(cli, datafiles, animal):
@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.skipif(not HAVE_SANDBOX, reason='Only available with a functioning sandbox')
def test_env_assign_isolated(cli, datafiles, animal):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
result = execute_shell(cli, project, ['/bin/sh', '-c', 'echo ${ANIMAL}'], isolate=True, config={
'shell': {
'environment': {
@@ -133,7 +133,7 @@ def test_env_assign_isolated(cli, datafiles, animal):
@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.skipif(not HAVE_SANDBOX, reason='Only available with a functioning sandbox')
def test_no_shell(cli, datafiles):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
element_path = os.path.join(project, 'elements')
element_name = 'shell/no-shell.bst'
@@ -166,7 +166,7 @@ def test_no_shell(cli, datafiles):
@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.skipif(not HAVE_SANDBOX, reason='Only available with a functioning sandbox')
def test_host_files(cli, datafiles, path):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
ponyfile = os.path.join(project, 'files', 'shell-mount', 'pony.txt')
result = execute_shell(cli, project, ['cat', path], config={
'shell': {
@@ -187,7 +187,7 @@ def test_host_files(cli, datafiles, path):
@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.skipif(not HAVE_SANDBOX, reason='Only available with a functioning sandbox')
def test_host_files_expand_environ(cli, datafiles, path):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
hostpath = os.path.join(project, 'files', 'shell-mount')
fullpath = os.path.join(path, 'pony.txt')
@@ -213,7 +213,7 @@ def test_host_files_expand_environ(cli, datafiles, path):
@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.skipif(not HAVE_SANDBOX, reason='Only available with a functioning sandbox')
def test_isolated_no_mount(cli, datafiles, path):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
ponyfile = os.path.join(project, 'files', 'shell-mount', 'pony.txt')
result = execute_shell(cli, project, ['cat', path], isolate=True, config={
'shell': {
@@ -236,7 +236,7 @@ def test_isolated_no_mount(cli, datafiles, path):
@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.skipif(not HAVE_SANDBOX, reason='Only available with a functioning sandbox')
def test_host_files_missing(cli, datafiles, optional):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
ponyfile = os.path.join(project, 'files', 'shell-mount', 'horsy.txt')
if optional == "optional":
@@ -272,7 +272,7 @@ def test_host_files_missing(cli, datafiles, optional):
@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.skipif(not HAVE_SANDBOX, reason='Only available with a functioning sandbox')
def test_cli_mount(cli, datafiles, path):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
ponyfile = os.path.join(project, 'files', 'shell-mount', 'pony.txt')
result = execute_shell(cli, project, ['cat', path], mount=(ponyfile, path))
@@ -284,7 +284,7 @@ def test_cli_mount(cli, datafiles, path):
@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.skipif(not HAVE_SANDBOX, reason='Only available with a functioning sandbox')
def test_workspace_visible(cli, datafiles):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
workspace = os.path.join(cli.directory, 'workspace')
element_name = 'workspace/workspace-mount-fail.bst'
@@ -318,7 +318,7 @@ def test_workspace_visible(cli, datafiles):
@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.skipif(not HAVE_SANDBOX, reason='Only available with a functioning sandbox')
def test_sysroot(cli, tmpdir, datafiles):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
base_element = "base/base-alpine.bst"
# test element only needs to be something lightweight for this test
test_element = "script/script.bst"
@@ -348,7 +348,7 @@ def test_sysroot(cli, tmpdir, datafiles):
@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.skipif(not HAVE_SANDBOX, reason='Only available with a functioning sandbox')
def test_integration_devices(cli, datafiles):
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
element_name = 'integration.bst'
result = execute_shell(cli, project, ["true"], element=element_name)
@@ -362,7 +362,7 @@ def test_integration_devices(cli, datafiles):
@pytest.mark.skipif(not HAVE_SANDBOX, reason='Only available with a functioning sandbox')
def test_integration_external_workspace(cli, tmpdir_factory, datafiles, build_shell, guess_element):
tmpdir = tmpdir_factory.mktemp("")
- project = os.path.join(datafiles.dirname, datafiles.basename)
+ project = str(datafiles)
element_name = 'autotools/amhello.bst'
workspace_dir = os.path.join(str(tmpdir), 'workspace')