summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPhillip Smyth <phillip.smyth@codethink.co.uk>2018-04-04 13:18:49 +0100
committerPhillip Smyth <phillipsmyth@Nexus-x240.dyn.ducie.codethink.co.uk>2018-07-11 12:06:40 +0100
commitbc5a40e3dccbe1cb8066171fc2c0a4a5abeaa31e (patch)
tree267541f60300a773fba222e5e563cf84515f8e30 /tests
parent9defbb629120e2cf9dda8276f13240ba13d0a3b6 (diff)
downloadbuildstream-bc5a40e3dccbe1cb8066171fc2c0a4a5abeaa31e.tar.gz
Diffstat (limited to 'tests')
-rw-r--r--tests/sources/__init__.py11
-rw-r--r--tests/sources/deb.py23
-rw-r--r--tests/sources/tar.py31
-rw-r--r--tests/sources/zip.py23
4 files changed, 36 insertions, 52 deletions
diff --git a/tests/sources/__init__.py b/tests/sources/__init__.py
index e69de29bb..02a755074 100644
--- a/tests/sources/__init__.py
+++ b/tests/sources/__init__.py
@@ -0,0 +1,11 @@
+import os
+
+
+def list_dir_contents(srcdir):
+ contents = set()
+ for _, dirs, files in os.walk(srcdir):
+ for d in dirs:
+ contents.add(d)
+ for f in files:
+ contents.add(f)
+ return contents
diff --git a/tests/sources/deb.py b/tests/sources/deb.py
index b905f0dcb..7bd99c22d 100644
--- a/tests/sources/deb.py
+++ b/tests/sources/deb.py
@@ -10,6 +10,7 @@ from buildstream import _yaml
from tempfile import TemporaryFile
from tests.testutils import cli
from tests.testutils.site import HAVE_ARPY
+from . import list_dir_contents
DATA_DIR = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
@@ -35,16 +36,6 @@ def _copy_deb(start_location, tmpdir):
shutil.copyfile(source, destination)
-def _list_dir_contents(srcdir):
- contents = set()
- for _, dirs, files in os.walk(srcdir):
- for d in dirs:
- contents.add(d)
- for f in files:
- contents.add(f)
- return contents
-
-
# Test that without ref, consistency is set appropriately.
@pytest.mark.skipif(HAVE_ARPY is False, reason="arpy is not available")
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'no-ref'))
@@ -127,8 +118,8 @@ def test_stage_default_basedir(cli, tmpdir, datafiles):
# Check that the content of the first directory is checked out (base-dir: '')
original_dir = os.path.join(str(datafiles), "content")
- original_contents = _list_dir_contents(original_dir)
- checkout_contents = _list_dir_contents(checkoutdir)
+ original_contents = list_dir_contents(original_dir)
+ checkout_contents = list_dir_contents(checkoutdir)
assert(checkout_contents == original_contents)
@@ -155,8 +146,8 @@ def test_stage_no_basedir(cli, tmpdir, datafiles):
# Check that the full content of the tarball is checked out (base-dir: '')
original_dir = os.path.join(str(datafiles), "content")
- original_contents = _list_dir_contents(original_dir)
- checkout_contents = _list_dir_contents(checkoutdir)
+ original_contents = list_dir_contents(original_dir)
+ checkout_contents = list_dir_contents(checkoutdir)
assert(checkout_contents == original_contents)
@@ -183,6 +174,6 @@ def test_stage_explicit_basedir(cli, tmpdir, datafiles):
# Check that the content of the first directory is checked out (base-dir: '')
original_dir = os.path.join(str(datafiles), "content")
- original_contents = _list_dir_contents(original_dir)
- checkout_contents = _list_dir_contents(checkoutdir)
+ original_contents = list_dir_contents(original_dir)
+ checkout_contents = list_dir_contents(checkoutdir)
assert(checkout_contents == original_contents)
diff --git a/tests/sources/tar.py b/tests/sources/tar.py
index 95bbd3f66..556b12f31 100644
--- a/tests/sources/tar.py
+++ b/tests/sources/tar.py
@@ -8,6 +8,7 @@ from buildstream._exceptions import ErrorDomain
from buildstream import _yaml
from tests.testutils import cli
from tests.testutils.site import HAVE_LZIP
+from . import list_dir_contents
DATA_DIR = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
@@ -105,16 +106,6 @@ def test_track_warning(cli, tmpdir, datafiles):
assert "Potential man-in-the-middle attack!" in result.stderr
-def _list_dir_contents(srcdir):
- contents = set()
- for _, dirs, files in os.walk(srcdir):
- for d in dirs:
- contents.add(d)
- for f in files:
- contents.add(f)
- return contents
-
-
# Test that a staged checkout matches what was tarred up, with the default first subdir
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'fetch'))
@pytest.mark.parametrize("srcdir", ["a", "./a"])
@@ -139,8 +130,8 @@ def test_stage_default_basedir(cli, tmpdir, datafiles, srcdir):
# Check that the content of the first directory is checked out (base-dir: '*')
original_dir = os.path.join(str(datafiles), "content", "a")
- original_contents = _list_dir_contents(original_dir)
- checkout_contents = _list_dir_contents(checkoutdir)
+ original_contents = list_dir_contents(original_dir)
+ checkout_contents = list_dir_contents(checkoutdir)
assert(checkout_contents == original_contents)
@@ -168,8 +159,8 @@ def test_stage_no_basedir(cli, tmpdir, datafiles, srcdir):
# Check that the full content of the tarball is checked out (base-dir: '')
original_dir = os.path.join(str(datafiles), "content")
- original_contents = _list_dir_contents(original_dir)
- checkout_contents = _list_dir_contents(checkoutdir)
+ original_contents = list_dir_contents(original_dir)
+ checkout_contents = list_dir_contents(checkoutdir)
assert(checkout_contents == original_contents)
@@ -197,8 +188,8 @@ def test_stage_explicit_basedir(cli, tmpdir, datafiles, srcdir):
# Check that the content of the first directory is checked out (base-dir: '*')
original_dir = os.path.join(str(datafiles), "content", "a")
- original_contents = _list_dir_contents(original_dir)
- checkout_contents = _list_dir_contents(checkoutdir)
+ original_contents = list_dir_contents(original_dir)
+ checkout_contents = list_dir_contents(checkoutdir)
assert(checkout_contents == original_contents)
@@ -233,8 +224,8 @@ def test_stage_contains_links(cli, tmpdir, datafiles):
# Check that the content of the first directory is checked out (base-dir: '*')
original_dir = os.path.join(str(datafiles), "content", "base-directory")
- original_contents = _list_dir_contents(original_dir)
- checkout_contents = _list_dir_contents(checkoutdir)
+ original_contents = list_dir_contents(original_dir)
+ checkout_contents = list_dir_contents(checkoutdir)
assert(checkout_contents == original_contents)
@@ -262,6 +253,6 @@ def test_stage_default_basedir_lzip(cli, tmpdir, datafiles, srcdir):
# Check that the content of the first directory is checked out (base-dir: '*')
original_dir = os.path.join(str(datafiles), "content", "a")
- original_contents = _list_dir_contents(original_dir)
- checkout_contents = _list_dir_contents(checkoutdir)
+ original_contents = list_dir_contents(original_dir)
+ checkout_contents = list_dir_contents(checkoutdir)
assert(checkout_contents == original_contents)
diff --git a/tests/sources/zip.py b/tests/sources/zip.py
index 5281fcea2..200dafcaa 100644
--- a/tests/sources/zip.py
+++ b/tests/sources/zip.py
@@ -5,6 +5,7 @@ import zipfile
from buildstream._exceptions import ErrorDomain
from buildstream import _yaml
from tests.testutils import cli
+from . import list_dir_contents
DATA_DIR = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
@@ -92,16 +93,6 @@ def test_track_warning(cli, tmpdir, datafiles):
assert "Potential man-in-the-middle attack!" in result.stderr
-def _list_dir_contents(srcdir):
- contents = set()
- for _, dirs, files in os.walk(srcdir):
- for d in dirs:
- contents.add(d)
- for f in files:
- contents.add(f)
- return contents
-
-
# Test that a staged checkout matches what was tarred up, with the default first subdir
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'fetch'))
def test_stage_default_basedir(cli, tmpdir, datafiles):
@@ -125,8 +116,8 @@ def test_stage_default_basedir(cli, tmpdir, datafiles):
# Check that the content of the first directory is checked out (base-dir: '*')
original_dir = os.path.join(str(datafiles), "content", "a")
- original_contents = _list_dir_contents(original_dir)
- checkout_contents = _list_dir_contents(checkoutdir)
+ original_contents = list_dir_contents(original_dir)
+ checkout_contents = list_dir_contents(checkoutdir)
assert(checkout_contents == original_contents)
@@ -153,8 +144,8 @@ def test_stage_no_basedir(cli, tmpdir, datafiles):
# Check that the full content of the tarball is checked out (base-dir: '')
original_dir = os.path.join(str(datafiles), "content")
- original_contents = _list_dir_contents(original_dir)
- checkout_contents = _list_dir_contents(checkoutdir)
+ original_contents = list_dir_contents(original_dir)
+ checkout_contents = list_dir_contents(checkoutdir)
assert(checkout_contents == original_contents)
@@ -181,6 +172,6 @@ def test_stage_explicit_basedir(cli, tmpdir, datafiles):
# Check that the content of the first directory is checked out (base-dir: '*')
original_dir = os.path.join(str(datafiles), "content", "a")
- original_contents = _list_dir_contents(original_dir)
- checkout_contents = _list_dir_contents(checkoutdir)
+ original_contents = list_dir_contents(original_dir)
+ checkout_contents = list_dir_contents(checkoutdir)
assert(checkout_contents == original_contents)