def test_prepare_base(self): basedir = utils.mkdtemp(self) export_target = join(basedir, 'artifacts', 'export.js') with pretty_logging(stream=mocks.StringIO()) as s: self.assertTrue(prepare_export_location(export_target)) self.assertTrue(exists(join(basedir, 'artifacts'))) self.assertIn("artifacts", s.getvalue())
def test_prepare_existed_dir_removed(self): basedir = utils.mkdtemp(self) export_target = join(basedir, 'export.js') os.mkdir(export_target) with pretty_logging(stream=mocks.StringIO()) as s: self.assertTrue(prepare_export_location(export_target)) self.assertIn( "removing existing export target directory at '%s'" % export_target, s.getvalue()) self.assertFalse(exists(export_target))
def test_prepare_base_parent_is_file(self): basedir = utils.mkdtemp(self) export_target = join(basedir, 'artifacts', 'export.js') with open(join(basedir, 'artifacts'), 'w'): pass with self.assertRaises(ToolchainAbort): with pretty_logging(stream=mocks.StringIO()) as s: self.assertFalse(prepare_export_location(export_target)) self.assertIn("cannot export to '%s'" % export_target, s.getvalue()) self.assertTrue(isfile(join(basedir, 'artifacts')))
def test_prepare_existed_dir_collision(self): basedir = utils.mkdtemp(self) conflict = join(basedir, 'some') export_target = join(conflict, 'target', 'export.js') with open(conflict, 'w'): pass with self.assertRaises(ToolchainAbort): with pretty_logging(stream=mocks.StringIO()) as s: self.assertFalse(prepare_export_location(export_target)) self.assertIn("failed to prepare export location", s.getvalue()) self.assertFalse(exists(export_target))
def check_target(export_target): # manually create the root here, to allow the completion # of the build process by doing what an existing # implementation that reuse existing code might have done. targets.append(export_target) prepare_export_location(export_target)