summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2013-09-17 15:13:40 +0300
committerGuido Günther <agx@sigxcpu.org>2014-12-28 13:03:40 +0100
commit4cd6627ab728acf0e08bb62bd981de6601c773ea (patch)
treefba44faf2544db8886a5a7702b6a2a8da18324d9 /tests
parent578e394e3933fbae30d7185572317b63188ffbc0 (diff)
buildpackage/dump_tree: add 'recursive' option
For selecting whether to dump all the files recursively or just the top level directory of the tree. Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/04_test_submodules.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/tests/04_test_submodules.py b/tests/04_test_submodules.py
index 4b07220..a18f8b5 100644
--- a/tests/04_test_submodules.py
+++ b/tests/04_test_submodules.py
@@ -22,6 +22,7 @@ SUBMODULES = []
SUBMODULE_NAMES = ["test_submodule", "sub module"]
TMPDIR = None
TESTFILE_NAME = "testfile"
+TESTDIR_NAME = "testdir"
class Submodule(object):
"""Class representing remote repo for Git submodule"""
@@ -57,6 +58,8 @@ def test_empty_has_submodules():
def _add_dummy_data(repo, msg):
"""Commit dummy data to a Git repository"""
shutil.copy(".git/HEAD", TESTFILE_NAME)
+ os.mkdir(TESTDIR_NAME)
+ shutil.copy(TESTFILE_NAME, os.path.join(TESTDIR_NAME, TESTFILE_NAME))
repo.add_files('.', force=True)
repo.commit_all(msg)
@@ -99,8 +102,16 @@ def test_dump_tree():
os.mkdir(dumpdir)
ok_(buildpackage.dump_tree(REPO, dumpdir, "master", True))
ok_(os.path.exists(os.path.join(dumpdir, TESTFILE_NAME)))
+ ok_(os.path.exists(os.path.join(dumpdir, TESTDIR_NAME, TESTFILE_NAME)))
ok_(os.path.exists(os.path.join(dumpdir, SUBMODULES[0].name,
TESTFILE_NAME)))
+ # No submodules or subdirs if recursive is False
+ dumpdir = TMPDIR.join("dump2")
+ os.mkdir(dumpdir)
+ ok_(buildpackage.dump_tree(REPO, dumpdir, "master", True, False))
+ ok_(os.path.exists(os.path.join(dumpdir, TESTFILE_NAME)))
+ ok_(not os.path.exists(os.path.join(dumpdir, TESTDIR_NAME)))
+ ok_(not os.path.exists(os.path.join(dumpdir, SUBMODULES[0].name)))
def test_create_tarballs():
@@ -120,12 +131,12 @@ def test_check_tarfiles():
tarobj = tarfile.open(TMPDIR.join("test_0.1.orig.tar.bz2"), 'r:*')
files = tarobj.getmembers()
ok_("test-0.1/.gitmodules" in [ f.name for f in files ])
- eq_(len(files) , 6)
+ eq_(len(files) , 10)
# Check tarball without submodules
tarobj = tarfile.open(TMPDIR.join("test_0.2.orig.tar.bz2"), 'r:*')
files = tarobj.getmembers()
ok_(("test-0.2/%s" % TESTFILE_NAME) in [ f.name for f in files ])
- eq_(len(files) , 4)
+ eq_(len(files) , 6)
def test_add_whitespace_submodule():
"""Add a second submodule with name containing whitespace"""