Ejemplo n.º 1
0
    def setup_release(self):
        os.chdir(self.work_tree)
        cmd(['git', 'checkout', self.branch_rt])

        # step1_commit()
        stub_stdin(self, 'y')
        stub_stdouts(self)
        commit(self.config, rc=False)

        # step2_tag()
        stub_stdin(self, 'y')
        stub_stdouts(self)
        tag(self.config)

        # step3_commit_rebase()
        cmd(['git', 'checkout', self.branch_rt_rebase])
        cmd(['git', 'rebase', 'v4.4.14'])

        stub_stdin(self, 'y')
        stub_stdouts(self)
        commit(self.config, rc=False)

        # step4_tag_rebase()
        stub_stdin(self, 'y')
        stub_stdouts(self)
        tag(self.config)

        # step5_create()
        ctx = SrtContext(self.work_tree)
        ctx.add_tag('old', 'v4.4.13-rt3')
        ctx.add_tag('new', 'v4.4.14-rt4')
        ctx.init()

        # step8_push()
        os.chdir(self.work_tree)
        cmd(['git', 'checkout', self.branch_rt])

        stub_stdin(self, 'y')
        stub_stdouts(self)
        push(self.config, ctx)
Ejemplo n.º 2
0
class TestReleaseCanditate(TestSrtBase):
    def setup_release(self):
        os.chdir(self.work_tree)
        cmd(['git', 'checkout', self.branch_rt])

        # step1_commit()
        stub_stdin(self, 'y')
        stub_stdouts(self)
        commit(self.config, rc=False)

        # step2_tag()
        stub_stdin(self, 'y')
        stub_stdouts(self)
        tag(self.config)

        # step3_commit_rebase()
        cmd(['git', 'checkout', self.branch_rt_rebase])
        cmd(['git', 'rebase', 'v4.4.14'])

        stub_stdin(self, 'y')
        stub_stdouts(self)
        commit(self.config, rc=False)

        # step4_tag_rebase()
        stub_stdin(self, 'y')
        stub_stdouts(self)
        tag(self.config)

        # step5_create()
        ctx = SrtContext(self.work_tree)
        ctx.add_tag('old', 'v4.4.13-rt3')
        ctx.add_tag('new', 'v4.4.14-rt4')
        ctx.init()

        # step8_push()
        os.chdir(self.work_tree)
        cmd(['git', 'checkout', self.branch_rt])

        stub_stdin(self, 'y')
        stub_stdouts(self)
        push(self.config, ctx)

    def setup_add_patches(self):
        os.chdir(self.work_tree)
        cmd(['git', 'checkout', self.branch_rt_next])
        cmd(['git', 'reset', '--hard', self.branch_rt])

        for n in range(1, 3):
            filename = 'file{}.txt'.format(n)
            with open(filename, 'w') as f:
                f.write(filename)
                f.write('\n')

            cmd(['git', 'add', filename])
            msg = """\
            Add {}

            Here goes nothing and you are no fun.
            """.format(filename)
            msg = textwrap.dedent(msg)
            cmd(['git', 'commit', '-s', '-m', msg])

    def setUp(self):
        super().setUp()

        self.setup_release()

        cmd(['git', 'checkout', self.branch_rt_next])
        self.setup_add_patches()

    def step1_commit(self):
        stub_stdin(self, 'y')
        stub_stdouts(self)
        commit(self.config, rc=1)
        ans = 'git commit -m Linux 4.4.14-rt5-rc1 \nOK to commit? (y/n): '
        self.assertEqual(sys.stdout.getvalue(), ans)
        lines = cmd(['git', 'show'])
        self.assertTrue(find_string(lines, 'Linux 4.4.14-rt5-rc1'))

    def step2_tag(self):
        stub_stdin(self, 'y')
        stub_stdouts(self)
        tag(self.config)
        self.assertTrue(tag_exists('v4.4.14-rt5-rc1'))

    def step3_create(self):
        self.ctx = SrtContext(self.work_tree)
        self.ctx.add_tag('old', 'v4.4.14-rt4')
        self.ctx.add_tag('new', 'v4.4.14-rt5-rc1')
        self.ctx.init()

        create(self.config, self.ctx)

        path = self.work_tree + '/patches/v4.4.14-rt5-rc1/'
        files = [
            path + 'patch-4.4.14-rt5-rc1.patch.xz',
            path + 'patches-4.4.14-rt5-rc1.tar.xz'
        ]
        for f in files:
            self.assertEqual(os.path.isfile(f), True)

    def step4_sign(self):
        sign(self.config, self.ctx)

        path = self.work_tree + '/patches/v4.4.14-rt5-rc1/'
        files = [
            path + 'patch-4.4.14-rt5-rc1.patch.sign',
            path + 'patches-4.4.14-rt5-rc1.tar.sign'
        ]
        for f in files:
            self.assertEqual(os.path.isfile(f), True)

    def step5_upload(self):
        # XXX mocking kup server

        stub_stdin(self, 'n')
        stub_stdouts(self)
        upload(self.config, self.ctx)

        path = self.work_tree + '/patches/v4.4.14-rt5-rc1/'
        prj = self.config['PRJ_DIR']
        args = [
            'kup', 'put', path + 'patch-4.4.14-rt5-rc1.patch.xz',
            path + 'patch-4.4.14-rt5-rc1.patch.sign', prj + '/older/', '--',
            'put', path + 'patches-4.4.14-rt5-rc1.tar.xz',
            path + 'patches-4.4.14-rt5-rc1.tar.sign', prj + '/older/', '--',
            'put', path + 'patch-4.4.14-rt4-rt5-rc1.patch.xz',
            path + 'patch-4.4.14-rt4-rt5-rc1.patch.sign', prj + '/incr/', '--',
            'ln', prj + '/older/patch-4.4.14-rt5-rc1.patch.xz', '../', '--',
            'ln', prj + '/older/patches-4.4.14-rt5-rc1.tar.xz', '../', '--',
            'ls', prj
        ]
        msg = '{0}\nOK to commit? (y/n): '.format(pformat(args))
        self.maxDiff = None
        self.assertEqual(sys.stdout.getvalue(), msg)

    def step6_push(self):
        os.chdir(self.work_tree)

        stub_stdin(self, 'y')
        stub_stdouts(self)
        push(self.config, self.ctx)

    def step7_announce(self):
        os.chdir(self.work_tree)

        ap = argparse.ArgumentParser()
        ap.add_argument('--suppress-cc',
                        '-s',
                        action="store_true",
                        default=False,
                        help='Don'
                        't auto-cc anyone (for testing)')
        args = ap.parse_args("")

        stub_stdin(self, 'n')
        stub_stdouts(self)
        announce(self.config, self.ctx, args)
        msg = ('git send-email --dry-run ' +
               '--to="Foo Bar <*****@*****.**>" --to="*****@*****.**" ' +
               '{}/patches/v4.4.14-rt5-rc1/mails\n'.format(self.work_tree))
        res = sys.stdout.getvalue()
        self.maxDiff = None
        self.assertTrue(res.find(msg))

        patches = [
            '0000-cover-letter.patch', '0001-Add-file1.txt.patch',
            '0002-Add-file2.txt.patch', '0003-Linux-4.4.14-rt5-rc1.patch'
        ]
        for p in patches:
            file_path = self.ctx.new_dir_mails + '/' + p
            self.assertTrue(os.path.isfile(file_path))

        with open(self.ctx.new_dir_mails + '/0000-cover-letter.patch',
                  'r') as f:
            letter = f.read()
            logging.debug(letter)
            self.assertTrue(letter.find('Linux ' + str(self.ctx.new_tag)))
Ejemplo n.º 3
0
class TestRelease(TestSrtBase):
    def step1_commit(self):
        stub_stdin(self, 'y')
        stub_stdouts(self)
        commit(self.config, rc=False)
        ans = 'git commit -m Linux 4.4.14-rt4 \nOK to commit? (y/n): '
        self.assertEqual(sys.stdout.getvalue(), ans)
        lines = cmd(['git', 'show'])
        self.assertTrue(find_string(lines, 'Linux 4.4.14-rt4'))

    def step2_tag(self):
        stub_stdin(self, 'y')
        stub_stdouts(self)
        tag(self.config)
        self.assertTrue(tag_exists('v4.4.14-rt4'))

    def step3_commit_rebase(self):
        cmd(['git', 'checkout', self.branch_rt_rebase])
        cmd(['git', 'rebase', 'v4.4.14'])

        stub_stdin(self, 'y')
        stub_stdouts(self)
        commit(self.config, rc=False)
        ans = 'git commit -m Linux 4.4.14-rt4 REBASE\nOK to commit? (y/n): '
        self.assertEqual(sys.stdout.getvalue(), ans)
        lines = cmd(['git', 'show'])
        self.assertTrue(find_string(lines, 'Linux 4.4.14-rt4 REBASE'))

    def step4_tag_rebase(self):
        stub_stdin(self, 'y')
        stub_stdouts(self)
        tag(self.config)
        self.assertTrue(tag_exists('v4.4.14-rt4-rebase'))

    def step5_create(self):
        self.ctx = SrtContext(self.work_tree)
        self.ctx.add_tag('old', 'v4.4.13-rt3')
        self.ctx.add_tag('new', 'v4.4.14-rt4')
        self.ctx.init()

        create(self.config, self.ctx)

        path = self.work_tree + '/patches/v4.4.14-rt4/'
        files = [
            path + 'patch-4.4.14-rt4.patch.xz',
            path + 'patches-4.4.14-rt4.tar.xz'
        ]
        for f in files:
            self.assertEqual(os.path.isfile(f), True)

    def step6_sign(self):
        sign(self.config, self.ctx)

        path = self.work_tree + '/patches/v4.4.14-rt4/'
        files = [
            path + 'patch-4.4.14-rt4.patch.sign',
            path + 'patches-4.4.14-rt4.tar.sign'
        ]
        for f in files:
            self.assertEqual(os.path.isfile(f), True)

    def step7_upload(self):
        # XXX mocking kup server

        stub_stdin(self, 'n')
        stub_stdouts(self)
        upload(self.config, self.ctx)

        path = self.work_tree + '/patches/v4.4.14-rt4/'
        prj = self.config['PRJ_DIR']
        args = [
            'kup', 'put', path + 'patch-4.4.14-rt4.patch.xz',
            path + 'patch-4.4.14-rt4.patch.sign', prj + '/older/', '--', 'put',
            path + 'patches-4.4.14-rt4.tar.xz',
            path + 'patches-4.4.14-rt4.tar.sign', prj + '/older/', '--', 'ln',
            prj + '/older/patch-4.4.14-rt4.patch.xz', '../', '--', 'ln',
            prj + '/older/patches-4.4.14-rt4.tar.xz', '../', '--', 'rm',
            prj + '/patch-4.4.13-rt3.patch.xz', '--', 'rm',
            prj + '/patches-4.4.13-rt3.tar.xz', '--', 'ls', prj
        ]
        msg = '{0}\nOK to commit? (y/n): '.format(pformat(args))
        self.maxDiff = None
        self.assertEqual(sys.stdout.getvalue(), msg)

    def step8_push(self):
        os.chdir(self.work_tree)
        cmd(['git', 'checkout', self.branch_rt])

        stub_stdin(self, 'y')
        stub_stdouts(self)
        push(self.config, self.ctx)

    def step9_announce(self):
        ap = argparse.ArgumentParser()
        ap.add_argument('--suppress-cc',
                        '-s',
                        action="store_true",
                        default=False,
                        help='Don'
                        't auto-cc anyone (for testing)')
        args = ap.parse_args("")

        stub_stdin(self, '')
        stub_stdouts(self)
        announce(self.config, self.ctx, args)

        letter = sys.stdout.getvalue()
        logging.debug(letter)
        self.assertNotEqual(letter, '')