diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2011-12-09 14:46:37 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2011-12-09 15:06:26 +0000 |
commit | 396e990faa49359ed440456a01d5a2815e6396e7 (patch) | |
tree | 22495046a817352346b57edf37d196abef4a3176 | |
parent | a2634251b06bdf0b917d21b458e868722de7c541 (diff) | |
download | morph-396e990faa49359ed440456a01d5a2815e6396e7.tar.gz |
Fix tests to reflect changes
bins now takes an Execute, so the test needed to be changed to also pass one
Execute had to be changed to ignore a statement from coverage
Also fixed Execute.runv not outputting its error. I think it is not logged
this way, but it does get output like it was before.
Also check no longer runs cmdtest from the home directory.
-rwxr-xr-x | check | 2 | ||||
-rw-r--r-- | morphlib/bins_tests.py | 21 | ||||
-rw-r--r-- | morphlib/execute.py | 8 |
3 files changed, 19 insertions, 12 deletions
@@ -20,4 +20,4 @@ set -e python setup.py clean check -$HOME/cmdtest/cmdtest/cmdtest -c ./morph tests +cmdtest -c ./morph tests diff --git a/morphlib/bins_tests.py b/morphlib/bins_tests.py index 171b9652..6fe48aa7 100644 --- a/morphlib/bins_tests.py +++ b/morphlib/bins_tests.py @@ -56,6 +56,7 @@ def recursive_lstat(root): class ChunkTests(unittest.TestCase): def setUp(self): + self.ex = morphlib.execute.Execute('.', lambda s: None) self.tempdir = tempfile.mkdtemp() self.instdir = os.path.join(self.tempdir, 'inst') self.chunk_file = os.path.join(self.tempdir, 'chunk') @@ -79,7 +80,8 @@ class ChunkTests(unittest.TestCase): def test_empties_everything(self): self.populate_instdir() - morphlib.bins.create_chunk(self.instdir, self.chunk_file, ['.']) + morphlib.bins.create_chunk(self.instdir, self.chunk_file, ['.'], + self.ex) empty = os.path.join(self.tempdir, 'empty') os.mkdir(empty) self.assertEqual([x for x,y in recursive_lstat(self.instdir)], ['.']) @@ -87,16 +89,19 @@ class ChunkTests(unittest.TestCase): def test_creates_and_unpacks_chunk_exactly(self): self.populate_instdir() orig_files = recursive_lstat(self.instdir) - morphlib.bins.create_chunk(self.instdir, self.chunk_file, ['.']) + morphlib.bins.create_chunk(self.instdir, self.chunk_file, ['.'], + self.ex) os.mkdir(self.unpacked) - morphlib.bins.unpack_binary(self.chunk_file, self.unpacked) + morphlib.bins.unpack_binary(self.chunk_file, self.unpacked, self.ex, + as_fakeroot=True) 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']) + morphlib.bins.create_chunk(self.instdir, self.chunk_file, ['bin'], + self.ex) os.mkdir(self.unpacked) - morphlib.bins.unpack_binary(self.chunk_file, self.unpacked) + morphlib.bins.unpack_binary(self.chunk_file, self.unpacked, self.ex) self.assertEqual([x for x,y in recursive_lstat(self.unpacked)], ['.', 'bin', 'bin/foo']) self.assertEqual([x for x,y in recursive_lstat(self.instdir)], @@ -105,6 +110,7 @@ class ChunkTests(unittest.TestCase): class StratumTests(unittest.TestCase): def setUp(self): + self.ex = morphlib.execute.Execute('.', lambda s: None) self.tempdir = tempfile.mkdtemp() self.instdir = os.path.join(self.tempdir, 'inst') self.stratum_file = os.path.join(self.tempdir, 'stratum') @@ -119,9 +125,10 @@ class StratumTests(unittest.TestCase): def test_creates_and_unpacks_stratum_exactly(self): self.populate_instdir() - morphlib.bins.create_stratum(self.instdir, self.stratum_file) + morphlib.bins.create_stratum(self.instdir, self.stratum_file, self.ex) os.mkdir(self.unpacked) - morphlib.bins.unpack_binary(self.stratum_file, self.unpacked) + morphlib.bins.unpack_binary(self.stratum_file, self.unpacked, self.ex, + as_fakeroot=True) self.assertEqual(recursive_lstat(self.instdir), recursive_lstat(self.unpacked)) diff --git a/morphlib/execute.py b/morphlib/execute.py index 5e7c4470..b502cb11 100644 --- a/morphlib/execute.py +++ b/morphlib/execute.py @@ -41,7 +41,7 @@ class Execute(object): self.msg = msg self._fakeroot_session = None - def __del__(self): + def __del__(self): # pragma: no cover try: object.__del__(self) except AttributeError: @@ -101,10 +101,10 @@ class Execute(object): ''' if 'stdout' not in kwargs: kwargs['stdout'] = subprocess.PIPE - if feed_stdin is not None and 'stdin' not in kwargs: - kwargs['stdin'] = subprocess.PIPE + if feed_stdin is not None and 'stdin' not in kwargs: + kwargs['stdin'] = subprocess.PIPE # pragma: no cover if 'stderr' not in kwargs: - kwargs['stderr'] = subprocess.PIPE + kwargs['stderr'] = subprocess.STDOUT if 'cwd' not in kwargs: kwargs['cwd'] = self.dirname if 'env' not in kwargs: |