Example #1
0
    def setUp(self):
        # Setup some ebuilds to test against.
        ebuild = os.path.join(self.tempdir, 'chromeos-chrome-%s-r12.ebuild')
        # The best version we'll be expecting.
        best_version = '4.3.2.1'
        best_ebuild_path = ebuild % best_version

        # Other versions to set up to compare against.
        versions = ['1.2.3.4', '4.3.2.0']
        ebuild_paths = [ebuild % version for version in versions]

        # Create a separate ebuild with the same chrome version as the best ebuild.
        rev_tiebreak_ebuild_path = best_ebuild_path.replace('-r12', '-r2')
        ebuild_paths.append(rev_tiebreak_ebuild_path)

        # Write stable ebuild data.
        stable_data = 'KEYWORDS=*'
        osutils.WriteFile(best_ebuild_path, stable_data)
        for path in ebuild_paths:
            osutils.WriteFile(path, stable_data)

        # Create the ebuilds.
        ebuilds = [uprev_lib.ChromeEBuild(path) for path in ebuild_paths]
        self.best_ebuild = uprev_lib.ChromeEBuild(best_ebuild_path)
        self.ebuilds = ebuilds + [self.best_ebuild]
Example #2
0
    def test_new_version(self):
        """Test a new chrome version."""
        # The stable ebuild should be replaced with one of the new version.
        manager = uprev_lib.UprevChromeManager(self.new_chrome_version,
                                               overlay_dir=self.tempdir)
        manager.uprev(constants.CHROME_CP)

        # The old one should be deleted and the new one should exist.
        new_path = self.stable_path.replace(self.stable_chrome_version,
                                            self.new_chrome_version)
        self.assertCountEqual([self.stable_path, new_path],
                              manager.modified_ebuilds)
        self.assertExists(new_path)
        self.assertNotExists(self.stable_path)

        new_ebuild = uprev_lib.ChromeEBuild(new_path)
        expected_version = '%s_rc-r1' % self.new_chrome_version
        self.assertEqual(expected_version, new_ebuild.version)
Example #3
0
    def test_uprev(self):
        """Test a revision bump."""
        # Make the contents different to force the uprev.
        osutils.WriteFile(self.unstable_path, 'IUSE=""', mode='a')
        manager = uprev_lib.UprevChromeManager(self.stable_chrome_version,
                                               overlay_dir=self.tempdir)
        manager.uprev(constants.CHROME_CP)

        new_path = self.stable_path.replace(
            '-r%d' % self.stable_revision, '-r%d' % (self.stable_revision + 1))

        self.assertCountEqual([self.stable_path, new_path],
                              manager.modified_ebuilds)
        self.assertExists(new_path)
        self.assertNotExists(self.stable_path)

        new_ebuild = uprev_lib.ChromeEBuild(new_path)
        expected_version = '%s_rc-r%d' % (self.stable_chrome_version,
                                          self.stable_revision + 1)
        self.assertEqual(expected_version, new_ebuild.version)