提交 b459397c 编写于 作者: C Cleber Rosa

Job: do not count on base_logdir when using dry run mode

As in previous commits, job should not count on arguments being
present, such as "base_logdir".  This also needs to be handled
when using dry run mode.

Since the dry run implementation creates a temporary directory
itself, it needs to be cleaned up in addition to the tmpdir
created by setUp.
Signed-off-by: NCleber Rosa <crosa@redhat.com>
上级 33ea34a1
......@@ -82,7 +82,8 @@ class Job(object):
if unique_id is None:
self.args.unique_job_id = "0" * 40
self.args.sysinfo = False
if self.args.base_logdir is None:
base_logdir = getattr(self.args, "base_logdir", None)
if base_logdir is None:
self.args.base_logdir = tempfile.mkdtemp(prefix="avocado-dry-run-")
unique_id = getattr(self.args, 'unique_job_id', None)
......
......@@ -171,6 +171,15 @@ class JobTest(unittest.TestCase):
self.assertEqual(os.path.dirname(empty_job.logdir), self.tmpdir)
self.assertTrue(os.path.isfile(os.path.join(empty_job.logdir, 'id')))
def test_job_dryrun_no_base_logdir(self):
args = argparse.Namespace(dry_run=True)
empty_job = job.Job(args)
try:
self.assertTrue(os.path.isdir(empty_job.logdir))
self.assertTrue(os.path.isfile(os.path.join(empty_job.logdir, 'id')))
finally:
shutil.rmtree(empty_job.args.base_logdir)
def tearDown(self):
data_dir._tmp_tracker.unittest_refresh_dir_tracker()
shutil.rmtree(self.tmpdir)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册