summaryrefslogtreecommitdiff
path: root/morphlib/bins_tests.py
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2011-11-03 17:04:17 +0000
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2011-11-03 17:04:17 +0000
commit222fcd9945e127d15282cd628e2e956500783213 (patch)
tree66445709c4651f57956121e61b20f4ef4108cd6f /morphlib/bins_tests.py
parentf205ebeef227115021ee764458508ef3a139d1aa (diff)
downloadmorph-222fcd9945e127d15282cd628e2e956500783213.tar.gz
Add tests for create_chunk's glob handling
Diffstat (limited to 'morphlib/bins_tests.py')
-rw-r--r--morphlib/bins_tests.py33
1 files changed, 29 insertions, 4 deletions
diff --git a/morphlib/bins_tests.py b/morphlib/bins_tests.py
index 30076120..64858e7a 100644
--- a/morphlib/bins_tests.py
+++ b/morphlib/bins_tests.py
@@ -66,16 +66,41 @@ class ChunkTests(unittest.TestCase):
def populate_instdir(self):
os.mkdir(self.instdir)
- os.mkdir(os.path.join(self.instdir, 'bin'))
+
+ bindir = os.path.join(self.instdir, 'bin')
+ os.mkdir(bindir)
+ with open(os.path.join(bindir, 'foo'), 'w'):
+ pass
+
+ libdir = os.path.join(self.instdir, 'lib')
+ os.mkdir(libdir)
+ with open(os.path.join(libdir, 'libfoo.so'), 'w'):
+ pass
+
+ def test_empties_everything(self):
+ self.populate_instdir()
+ morphlib.bins.create_chunk(self.instdir, self.chunk_file, ['*'])
+ empty = os.path.join(self.tempdir, 'empty')
+ os.mkdir(empty)
+ self.assertEqual(recursive_lstat(self.instdir), empty)
def test_creates_and_unpacks_chunk_exactly(self):
self.populate_instdir()
- morphlib.bins.create_chunk(self.instdir, self.chunk_file)
+ orig_files = recursive_lstat(self.instdir)
+ morphlib.bins.create_chunk(self.instdir, self.chunk_file, ['*'])
os.mkdir(self.unpacked)
morphlib.bins.unpack_chunk(self.chunk_file, self.unpacked)
- self.assertEqual(recursive_lstat(self.instdir),
- recursive_lstat(self.unpacked))
+ self.assertEqual(orig_files, recursive_lstat(self.unpacked))
+ def test_uses_only_matching_names(self):
+ self.populate_instdir()
+ morphlib.bins.create_chunk(self.instdir, self.chunk_file, ['bin/*'])
+ os.mkdir(self.unpacked)
+ morphlib.bins.unpack_chunk(self.chunk_file, self.unpacked)
+ self.assertEqual([x for x,y in recursive_lstat(self.unpacked)],
+ ['bin/foo'])
+ self.assertEqual([x for x,y in recursive_lstat(self.instdir)],
+ ['lib/libfoo.so'])
class StratumTests(unittest.TestCase):