michael@0: #!/usr/bin/env python michael@0: michael@0: import mozprofile michael@0: import os michael@0: import shutil michael@0: import tempfile michael@0: import unittest michael@0: michael@0: michael@0: here = os.path.dirname(os.path.abspath(__file__)) michael@0: michael@0: michael@0: class Bug758250(unittest.TestCase): michael@0: """ michael@0: use of --profile in mozrunner just blows away addon sources: michael@0: https://bugzilla.mozilla.org/show_bug.cgi?id=758250 michael@0: """ michael@0: michael@0: def setUp(self): michael@0: self.tmpdir = tempfile.mkdtemp() michael@0: self.addon = os.path.join(here, 'addons', 'empty') michael@0: michael@0: def tearDown(self): michael@0: # remove vestiges michael@0: shutil.rmtree(self.tmpdir) michael@0: michael@0: def test_profile_addon_cleanup(self): michael@0: michael@0: # sanity check: the empty addon should be here michael@0: self.assertTrue(os.path.exists(self.addon)) michael@0: self.assertTrue(os.path.isdir(self.addon)) michael@0: self.assertTrue(os.path.exists(os.path.join(self.addon, 'install.rdf'))) michael@0: michael@0: # because we are testing data loss, let's make sure we make a copy michael@0: shutil.rmtree(self.tmpdir) michael@0: shutil.copytree(self.addon, self.tmpdir) michael@0: self.assertTrue(os.path.exists(os.path.join(self.tmpdir, 'install.rdf'))) michael@0: michael@0: # make a starter profile michael@0: profile = mozprofile.FirefoxProfile() michael@0: path = profile.profile michael@0: michael@0: # make a new profile based on the old michael@0: newprofile = mozprofile.FirefoxProfile(profile=path, addons=[self.tmpdir]) michael@0: newprofile.cleanup() michael@0: michael@0: # the source addon *should* still exist michael@0: self.assertTrue(os.path.exists(self.tmpdir)) michael@0: self.assertTrue(os.path.exists(os.path.join(self.tmpdir, 'install.rdf'))) michael@0: michael@0: michael@0: if __name__ == '__main__': michael@0: unittest.main()