Exemplo n.º 1
0
    def test_mode_incremental_p4base_with_revision(self):
        self.setupStep(P4(p4port='localhost:12000', mode='incremental',
                          p4base='//depot', p4branch='trunk',
                          p4user='******', p4client='p4_client1', p4passwd='pass'),
                       dict(revision='100',))

        root_dir = '/home/user/workspace/wkdir'
        if _is_windows:
            root_dir = r'C:\Users\username\Workspace\wkdir'
        client_spec = textwrap.dedent('''\
        Client: p4_client1

        Owner: user

        Description:
        \tCreated by user

        Root:\t%s

        Options:\tallwrite rmdir

        LineEnd:\tlocal

        View:
        \t//depot/trunk/... //p4_client1/...
        ''' % root_dir)

        self.expectCommands(
            ExpectShell(workdir='wkdir',  # defaults to this, only changes if it has a copy mode.
                        command=['p4', '-V'])  # expected remote command
            + 0,  # expected exit status

            ExpectShell(workdir='wkdir',
                        command=['p4', '-p', 'localhost:12000', '-u', 'user',
                                 '-P', 'pass', '-c', 'p4_client1',
                                 'client', '-i'],
                        initialStdin=client_spec)
            + 0,
            ExpectShell(workdir='wkdir',
                        command=['p4', '-p', 'localhost:12000', '-u', 'user',
                                 '-P', 'pass', '-c', 'p4_client1',
                                 'sync', '//depot...@100'])
            + 0,
            ExpectShell(workdir='wkdir',
                        command=['p4', '-p', 'localhost:12000', '-u', 'user',
                                 '-P', 'pass', '-c', 'p4_client1',
                                 'changes', '-m1', '#have'])
            + ExpectShell.log('stdio',
                              stdout="Change 100 on 2013/03/21 by user@machine \'duh\'")
            + 0,
        )
        self.expectOutcome(result=SUCCESS)
        self.expectProperty('got_revision', '100', 'P4')
        return self.runStep()
Exemplo n.º 2
0
    def test_worker_connection_lost(self):
        self.setupStep(P4(p4port='localhost:12000', mode='incremental',
                          p4base='//depot', p4branch='trunk',
                          p4user='******', p4client='p4_client1', p4passwd='pass'),
                       dict(revision='100',))

        self.expectCommands(
            ExpectShell(workdir='wkdir',
                        command=['p4', '-V'])
            + ('err', error.ConnectionLost()),
        )
        self.expectOutcome(result=RETRY, state_string="update (retry)")
        return self.runStep()
Exemplo n.º 3
0
    def test_mode_full_p4viewspec_suffix(self):
        self.setupStep(
            P4(p4port='localhost:12000',
               mode='full',
               p4viewspec_suffix=None,
               p4viewspec=[('//depot/trunk/foo.xml', 'bar.xml'),
                           ('//depot/trunk/white space/...',
                            'white space/...'),
                           ('-//depot/trunk/white space/excluded/...',
                            'white space/excluded/...')],
               p4user='******',
               p4client='p4_client1',
               p4passwd='pass'))

        root_dir = '/home/user/workspace/wkdir'
        if _is_windows:
            root_dir = r'C:\Users\username\Workspace\wkdir'
        client_spec = textwrap.dedent('''\
        Client: p4_client1

        Owner: user

        Description:
        \tCreated by user

        Root:\t%s

        Options:\tallwrite rmdir

        LineEnd:\tlocal

        View:
        \t//depot/trunk/foo.xml //p4_client1/bar.xml
        \t"//depot/trunk/white space/..." "//p4_client1/white space/..."
        \t"-//depot/trunk/white space/excluded/..." "//p4_client1/white space/excluded/..."
        ''' % root_dir)
        self._full(client_stdin=client_spec)
Exemplo n.º 4
0
    def test_mode_incremental_p4base_with_p4extra_views(self):
        self.setupStep(
            P4(p4port='localhost:12000',
               mode='incremental',
               p4base='//depot',
               p4branch='trunk',
               p4extra_views=[('-//depot/trunk/test', 'test'),
                              ('-//depot/trunk/doc', 'doc'),
                              ('-//depot/trunk/white space', 'white space')],
               p4user='******',
               p4client='p4_client1',
               p4passwd='pass'))

        root_dir = '/home/user/workspace/wkdir'
        if _is_windows:
            root_dir = r'C:\Users\username\Workspace\wkdir'
        client_spec = textwrap.dedent('''\
        Client: p4_client1

        Owner: user

        Description:
        \tCreated by user

        Root:\t%s

        Options:\tallwrite rmdir

        LineEnd:\tlocal

        View:
        \t//depot/trunk/... //p4_client1/...
        \t-//depot/trunk/test/... //p4_client1/test/...
        \t-//depot/trunk/doc/... //p4_client1/doc/...
        \t"-//depot/trunk/white space/..." "//p4_client1/white space/..."
        ''' % root_dir)
        self._incremental(client_stdin=client_spec)
 def test_no_empty_step_config(self):
     with self.assertRaises(config.ConfigErrors):
         P4()
Exemplo n.º 6
0
 def test_p4branch_has_whitespace(self):
     with self.assertRaises(config.ConfigErrors):
         P4(p4base='//depot/', p4branch='branch with space')
 def test_no_p4extra_views_with_no_p4base_step_config(self):
     self.assertRaises(config.ConfigErrors,
                       lambda: P4(p4extra_views='blah'))
 def test_no_p4branch_has_trailing_slash_step_config(self):
     self.assertRaises(config.ConfigErrors,
                       lambda: P4(p4base='//depot', p4branch='blah/'))
 def test_no_multiple_type_step_config(self):
     self.assertRaises(
         config.ConfigErrors, lambda: P4(p4viewspec=('//depot/trunk', ''),
                                         p4base='//depot',
                                         p4branch='trunk',
                                         p4extra_views=['src', 'doc']))
Exemplo n.º 10
0
 def test_p4base_has_whitespace(self):
     with self.assertRaisesConfigError(
             'p4base should not end with a trailing / [p4base = //depot with space/]'
     ):
         P4(p4base='//depot with space/')
Exemplo n.º 11
0
 def test_no_empty_step_config(self):
     with self.assertRaisesConfigError(
             'You must provide p4base or p4viewspec'):
         P4()
Exemplo n.º 12
0
 def test_incorrect_mode(self):
     with self.assertRaisesConfigError(
             "mode invalid is not an IRenderable, or one of ('incremental', 'full')"
     ):
         P4(p4base='//depot', mode='invalid')
Exemplo n.º 13
0
 def test_no_p4extra_views_with_no_p4base_step_config(self):
     with self.assertRaisesConfigError(
             'You must provide p4base or p4viewspec'):
         P4(p4extra_views='blah')
Exemplo n.º 14
0
 def test_no_p4branch_has_trailing_slash_step_config(self):
     with self.assertRaisesConfigError(
             'p4branch should not end with a trailing / [p4branch = blah/]'
     ):
         P4(p4base='//depot', p4branch='blah/')
Exemplo n.º 15
0
 def test_no_multiple_type_step_config(self):
     with self.assertRaisesConfigError(
             'Either provide p4viewspec or p4base and p4branch (and optionally p4extra_views)'):
         P4(p4viewspec=('//depot/trunk', ''), p4base='//depot',
            p4branch='trunk', p4extra_views=['src', 'doc'])
Exemplo n.º 16
0
 def test_no_p4base_has_trailing_slash_step_config(self):
     with self.assertRaises(config.ConfigErrors):
         P4(p4base='//depot/')
Exemplo n.º 17
0
    def test_ticket_auth(self):
        self.setupStep(
            P4(p4port='localhost:12000',
               p4base='//depot',
               p4branch='trunk',
               p4user='******',
               p4client='p4_client1',
               p4passwd='pass',
               use_tickets=True))

        root_dir = '/home/user/workspace/wkdir'
        if _is_windows:
            root_dir = r'C:\Users\username\Workspace\wkdir'
        client_spec = textwrap.dedent('''\
        Client: p4_client1

        Owner: user

        Description:
        \tCreated by user

        Root:\t%s

        Options:\tallwrite rmdir

        LineEnd:\tlocal

        View:
        \t//depot/trunk/... //p4_client1/...
        ''' % root_dir)

        self.expectCommands(
            ExpectShell(workdir='wkdir', command=['p4', '-V']) + 0,

            # This is the extra step that gets run when using tickets,
            # and the password is not passed anymore after that.
            ExpectShell(workdir='wkdir',
                        command=[
                            'p4', '-p', 'localhost:12000', '-u', 'user', '-c',
                            'p4_client1', 'login'
                        ],
                        initialStdin='pass\n') + 0,
            ExpectShell(workdir='wkdir',
                        command=[
                            'p4', '-p', 'localhost:12000', '-u', 'user', '-c',
                            'p4_client1', 'client', '-i'
                        ],
                        initialStdin=client_spec) + 0,
            ExpectShell(workdir='wkdir',
                        command=([
                            'p4', '-p', 'localhost:12000', '-u', 'user', '-c',
                            'p4_client1', 'sync'
                        ])) + 0,
            ExpectShell(workdir='wkdir',
                        command=[
                            'p4', '-p', 'localhost:12000', '-u', 'user', '-c',
                            'p4_client1', 'changes', '-m1', '#have'
                        ]) +
            ExpectShell.log(
                'stdio',
                stdout="Change 100 on 2013/03/21 by user@machine \'duh\'") + 0,
        )
        self.expectOutcome(result=SUCCESS, status_text=["update"])
        return self.runStep()
Exemplo n.º 18
0
 def test_p4branch_has_whitespace(self):
     with self.assertRaisesConfigError(
             'p4base should not end with a trailing / [p4base = //depot/]'):
         P4(p4base='//depot/', p4branch='branch with space')
Exemplo n.º 19
0
 def test_no_empty_step_config(self):
     self.assertRaises(config.ConfigErrors, lambda: P4())
Exemplo n.º 20
0
 def test_no_p4base_has_leading_slash_step_config(self):
     with self.assertRaisesConfigError(
             'p4base should start with // [p4base = depot/]'):
         P4(p4base='depot/')
Exemplo n.º 21
0
 def test_no_p4viewspec_is_string_step_config(self):
     self.assertRaises(config.ConfigErrors,
                       lambda: P4(p4viewspec='a_bad_idea'))
Exemplo n.º 22
0
 def test_no_p4viewspec_is_string_step_config(self):
     with self.assertRaisesConfigError(
             'p4viewspec must not be a string, and should be a sequence of 2 element sequences'
     ):
         P4(p4viewspec='a_bad_idea')
Exemplo n.º 23
0
 def test_no_p4branch_with_no_p4base_step_config(self):
     self.assertRaises(config.ConfigErrors, lambda: P4(p4branch='blah'))
Exemplo n.º 24
0
 def test_no_p4base_has_trailing_slash_step_config(self):
     with self.assertRaisesConfigError(
             'p4base should not end with a trailing / [p4base = //depot/]'):
         P4(p4base='//depot/')
Exemplo n.º 25
0
 def test_incorrect_mode(self):
     self.assertRaises(config.ConfigErrors,
                       lambda: P4(p4base='//depot', mode='invalid'))
Exemplo n.º 26
0
 def test_p4base_has_whitespace(self):
     with self.assertRaises(config.ConfigErrors):
         P4(p4base='//depot with space/')