Make setUp fail if sdist fails.
Hygiene - fail at the point of failure, not later. Change-Id: Id0328f1afad5dd2fb4f5ef22e025d60eef1d4e52
This commit is contained in:
parent
e01b28e4c3
commit
2e2245c783
|
@ -116,17 +116,20 @@ class BaseTestCase(testtools.TestCase, testresources.ResourcedTestCase):
|
|||
k.startswith('pbr_testpackage.')):
|
||||
del sys.modules[k]
|
||||
|
||||
def run_setup(self, *args):
|
||||
return self._run_cmd(sys.executable, ('setup.py',) + args)
|
||||
def run_setup(self, *args, **kwargs):
|
||||
return self._run_cmd(sys.executable, ('setup.py',) + args, **kwargs)
|
||||
|
||||
def _run_cmd(self, cmd, args=[]):
|
||||
def _run_cmd(self, cmd, args=[], allow_fail=True):
|
||||
"""Run a command in the root of the test working copy.
|
||||
|
||||
Runs a command, with the given argument list, in the root of the test
|
||||
working copy--returns the stdout and stderr streams and the exit code
|
||||
from the subprocess.
|
||||
"""
|
||||
return _run_cmd([cmd] + list(args), cwd=self.package_dir)
|
||||
result = _run_cmd([cmd] + list(args), cwd=self.package_dir)
|
||||
if result[2] and not allow_fail:
|
||||
raise Exception("Command failed retcode=%s" % result[2])
|
||||
return result
|
||||
|
||||
|
||||
def _run_cmd(args, cwd):
|
||||
|
|
|
@ -78,8 +78,7 @@ class TestPackagingInGitRepoWithCommit(base.BaseTestCase):
|
|||
super(TestPackagingInGitRepoWithCommit, self).setUp()
|
||||
repo = self.useFixture(TestRepo(self.package_dir))
|
||||
repo.commit()
|
||||
self.run_setup('sdist')
|
||||
return
|
||||
self.run_setup('sdist', allow_fail=False)
|
||||
|
||||
def test_authors(self):
|
||||
# One commit, something should be in the authors list
|
||||
|
@ -99,8 +98,7 @@ class TestPackagingInGitRepoWithoutCommit(base.BaseTestCase):
|
|||
def setUp(self):
|
||||
super(TestPackagingInGitRepoWithoutCommit, self).setUp()
|
||||
self.useFixture(TestRepo(self.package_dir))
|
||||
self.run_setup('sdist')
|
||||
return
|
||||
self.run_setup('sdist', allow_fail=False)
|
||||
|
||||
def test_authors(self):
|
||||
# No commits, no authors in list
|
||||
|
@ -119,8 +117,7 @@ class TestPackagingInPlainDirectory(base.BaseTestCase):
|
|||
|
||||
def setUp(self):
|
||||
super(TestPackagingInPlainDirectory, self).setUp()
|
||||
self.run_setup('sdist')
|
||||
return
|
||||
self.run_setup('sdist', allow_fail=False)
|
||||
|
||||
def test_authors(self):
|
||||
# Not a git repo, no AUTHORS file created
|
||||
|
|
Loading…
Reference in New Issue