Exemple #1
0
    def test_get_files(self):
        ctx = SrtContext(make_args('v4.4.115-rt38', 'v4.4.115-rt39'), '/tmp')

        path = '/tmp/patches/v4.4.115-rt39/'
        files = [
            path + 'patch-4.4.115-rt39.patch.xz',
            path + 'patches-4.4.115-rt39.tar.xz'
        ]
        self.assertEqual(ctx.get_files(), files)
    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)
Exemple #3
0
 def test_tag(self):
     ctx = SrtContext('/tmp')
     ctx.add_tag('new', 'v4.4.115-rt38')
     self.assertEqual(str(ctx.new_tag), 'v4.4.115-rt38')
     self.assertEqual(ctx.new_short_tag, '4.4.115-rt38')
     self.assertEqual(ctx.new_dir_patches, '/tmp/patches/v4.4.115-rt38')
     self.assertEqual(ctx.new_dir_series,
                      '/tmp/patches/v4.4.115-rt38/patches')
     self.assertEqual(ctx.new_dir_mails, '/tmp/patches/v4.4.115-rt38/mails')
     self.assertEqual(
         ctx.new_fln_patch,
         '/tmp/patches/v4.4.115-rt38/patch-4.4.115-rt38.patch.xz')
     self.assertEqual(
         ctx.new_fln_tar,
         '/tmp/patches/v4.4.115-rt38/patches-4.4.115-rt38.tar.xz')
Exemple #4
0
 def test_is_rc(self):
     ctx = SrtContext('/tmp')
     ctx.add_tag('old', 'v4.4.115-rt38')
     ctx.add_tag('new', 'v4.4.115-rt39-rc1')
     ctx.init()
     fname = ('/tmp/patches/v4.4.115-rt39-rc1/' +
              'patch-4.4.115-rt38-rt39-rc1.patch.xz')
     self.assertEqual(ctx.fln_incr, fname)
     self.assertEqual(ctx.is_rc, True)
Exemple #5
0
    def step0_get_context(self):
        ap = argparse.ArgumentParser()
        sap = ap.add_subparsers(dest='cmd')
        prs = sap.add_parser('create')
        prs.add_argument('OLD_TAG')
        prs.add_argument('NEW_TAG')

        args = ap.parse_args(['create', 'v4.4.13-rt3', 'v4.4.14-rt4'])
        ctx = SrtContext(args)
        self.assertTrue(ctx)
        print(ctx)
Exemple #6
0
 def test_tag(self):
     ctx = SrtContext(make_args('v4.4.114-rt37', 'v4.4.115-rt38'), '/tmp')
     path = '/tmp/patches/v4.4.115-rt38'
     self.assertEqual(str(ctx.new_tag), 'v4.4.115-rt38')
     self.assertEqual(ctx.new_short_tag, '4.4.115-rt38')
     self.assertEqual(ctx.new_dir_patches, path)
     self.assertEqual(ctx.new_dir_series, path + '/patches')
     self.assertEqual(ctx.new_dir_mails, path + '/mails')
     self.assertEqual(ctx.new_fln_patch,
                      path + '/patch-4.4.115-rt38.patch.xz')
     self.assertEqual(ctx.new_fln_tar,
                      path + '/patches-4.4.115-rt38.tar.xz')
Exemple #7
0
    def step10_create(self):
        cmd(['git', 'checkout', self.branch_rt])
        self.ctx = SrtContext(make_args(), path=self.work_tree)

        create(self.config, self.ctx)

        path = self.work_tree + '/patches/v4.4.15-rt5/'
        files = [
            path + 'patch-4.4.15-rt5.patch.xz',
            path + 'patches-4.4.15-rt5.tar.xz'
        ]
        for f in files:
            self.assertEqual(os.path.isfile(f), True)
Exemple #8
0
    def step3_create(self):
        self.ctx = SrtContext(make_args('v4.4.14-rt4', 'v4.4.14-rt5-rc1'),
                              path=self.work_tree)

        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)
Exemple #9
0
    def test_get_files(self):
        ctx = SrtContext('/tmp')
        ctx.add_tag('old', 'v4.4.115-rt38')
        ctx.add_tag('new', 'v4.4.115-rt39')
        ctx.init()

        path = '/tmp/patches/v4.4.115-rt39/'
        files = [
            path + 'patch-4.4.115-rt39.patch.xz',
            path + 'patches-4.4.115-rt39.tar.xz',
            path + 'patch-4.4.115-rt38-rt39.patch.xz'
        ]
        self.assertEqual(ctx.get_files(), files)
Exemple #10
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(make_args('v4.4.13-rt3', 'v4.4.14-rt4'),
                         path=self.work_tree)

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

        stub_stdin(self, 'y')
        stub_stdouts(self)
        push(self.config, ctx)
Exemple #11
0
def get_context(args):
    ctx = SrtContext()
    if not hasattr(args, 'OLD_TAG') or not hasattr(args, 'NEW_TAG'):
        return ctx

    ctx.add_tag('old', args.OLD_TAG)
    ctx.add_tag('new', args.NEW_TAG)
    ctx.init()
    debug(ctx.dump())

    tags = [ctx.old_tag, ctx.new_tag, ctx.new_tag.base]
    if not ctx.new_tag.is_rc:
        tags.append(ctx.new_tag.rebase)

    for tag in tags:
        debug('Check if tag {0} exists'.format(tag))
        if not tag_exists(tag):
            print('tag {0} doesn\'t exists'.format(tag), file=sys.stderr)
            return None

    return ctx
Exemple #12
0
def execute(args):
    ctx = SrtContext(args)
    check_context(ctx)

    push(get_config(), ctx)
Exemple #13
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)))
Exemple #14
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, '')
Exemple #15
0
def execute(args):
    ctx = SrtContext(args)
    check_context(ctx)

    upload(get_config(), ctx)
Exemple #16
0
def execute(args):
    ctx = SrtContext(args)
    check_context(ctx)

    announce(get_config(), ctx, args)