Exemplo n.º 1
0
 def test_prop_rendering(self):
     cmd = [
         sys.executable, '-c',
         WithProperties(
             'import os; print "%s"; print os.environ[\"BUILD\"]',
             'project')
     ]
     self.setupStep(
         master.MasterShellCommand(
             command=cmd, env={'BUILD': WithProperties('%s', "project")}))
     self.properties.setProperty("project", "BUILDBOT-TEST", "TEST")
     if runtime.platformType == 'win32':
         self.expectLogfile('stdio', "BUILDBOT-TEST\r\nBUILDBOT-TEST\r\n")
     else:
         self.expectLogfile('stdio', "BUILDBOT-TEST\nBUILDBOT-TEST\n")
     self.expectOutcome(result=SUCCESS)
     return self.runStep()
Exemplo n.º 2
0
    def test_env_subst(self):
        cmd = [sys.executable, '-c', 'import os; print os.environ["HELLO"]']
        os.environ['WORLD'] = 'hello'
        self.setupStep(
            master.MasterShellCommand(command=cmd, env={'HELLO': '${WORLD}'}))
        if runtime.platformType == 'win32':
            self.expectLogfile('stdio', "hello\r\n")
        else:
            self.expectLogfile('stdio', "hello\n")
        self.expectOutcome(result=SUCCESS)

        def _restore_env(res):
            del os.environ['WORLD']
            return res

        d = self.runStep()
        d.addBoth(_restore_env)
        return d
Exemplo n.º 3
0
    def test_path_absolute(self):
        """
        If the ``path`` argument is absolute, the command is executed in that directory,
        and that directory is logged.
        """
        path = FilePath(self.mktemp())
        path.createDirectory()
        cmd = [sys.executable, '-c', 'import os, sys; sys.stdout.write(os.getcwd())']
        self.setupStep(
            master.MasterShellCommand(command=cmd, path=path.path))
        self.expectLogfile('stdio', path.path)
        self.expectOutcome(result=SUCCESS, status_text=["Ran"])
        d = self.runStep()

        @d.addCallback
        def check(_):
            headers = self.step_status.logs['stdio'].header.splitlines()
            self.assertIn(" in dir %s" % (path.path,), headers)
        return d
Exemplo n.º 4
0
    def test_constr_args_descriptionSuffix(self):
        self.setup_step(master.MasterShellCommand(description='x', descriptionDone='y',
                                                 descriptionSuffix='z',
                                                 env={'a': 'b'}, workdir='build', usePTY=True,
                                                 command='true'))

        if runtime.platformType == 'win32':
            exp_argv = [r'C:\WINDOWS\system32\cmd.exe', '/c', 'true']
        else:
            exp_argv = ['/bin/sh', '-c', 'true']

        self.expect_commands(
            ExpectMasterShell(exp_argv)
            .workdir('build')
            .env({'a': 'b'})
            .exit(0))

        self.expect_outcome(result=SUCCESS, state_string='y z')
        return self.run_step()
Exemplo n.º 5
0
    def test_env_list_subst(self):
        cmd = [sys.executable, '-c', 'import os; print os.environ["HELLO"]']
        os.environ['WORLD'] = 'hello'
        os.environ['LIST'] = 'world'
        self.setupStep(
            master.MasterShellCommand(command=cmd,
                                      env={'HELLO': ['${WORLD}', '${LIST}']}))
        if runtime.platformType == 'win32':
            self.expectLogfile('stdio', "hello;world\r\n")
        else:
            self.expectLogfile('stdio', "hello:world\n")
        self.expectOutcome(result=SUCCESS, status_text=["Ran"])

        def _restore_env(res):
            del os.environ['WORLD']
            del os.environ['LIST']
            return res
        d = self.runStep()
        d.addBoth(_restore_env)
        return d
Exemplo n.º 6
0
    def test_constr_args(self):
        self.setupStep(
            master.MasterShellCommand(description='x', descriptionDone='y',
                                      env={'a': 'b'}, workdir='build', usePTY=True,
                                      command='true'))

        if runtime.platformType == 'win32':
            exp_argv = [r'C:\WINDOWS\system32\cmd.exe', '/c', 'true']
        else:
            exp_argv = ['/bin/sh', '-c', 'true']
        self.patchSpawnProcess(
            exp_cmd=exp_argv[0], exp_argv=exp_argv,
            exp_path='build', exp_usePTY=True, exp_env={'a': 'b'},
            outputs=[
                ('out', 'hello!\n'),
                ('err', 'world\n'),
                ('rc', 0),
            ])
        self.expectOutcome(result=SUCCESS, state_string='y')
        return self.runStep()
Exemplo n.º 7
0
    def test_env_subst(self):
        os.environ['WORLD'] = 'hello'
        self.setup_step(
            master.MasterShellCommand(command='true', env={'HELLO': '${WORLD}'}))

        if runtime.platformType == 'win32':
            exp_argv = [r'C:\WINDOWS\system32\cmd.exe', '/c', 'true']
        else:
            exp_argv = ['/bin/sh', '-c', 'true']

        self.expect_commands(
            ExpectMasterShell(exp_argv)
            .env({'HELLO': 'hello'})
            .exit(0))

        self.expect_outcome(result=SUCCESS)

        try:
            yield self.run_step()
        finally:
            del os.environ['WORLD']
Exemplo n.º 8
0
def MakeSpotifyBlobBuilder():
    cmake_cmd = [
        "cmake",
        "..",
        "-DCMAKE_INSTALL_PREFIX=source/bin/installprefix",
    ]

    f = factory.BuildFactory()
    f.addStep(git.Git(**GitArgs("Clementine")))
    f.addStep(
        shell.ShellCommand(name="cmake",
                           workdir="source/bin",
                           haltOnFailure=True,
                           command=cmake_cmd))
    f.addStep(
        shell.Compile(workdir="source/bin",
                      haltOnFailure=True,
                      command=["make", "clementine-spotifyblob", "-j4"]))
    f.addStep(
        shell.ShellCommand(name="install",
                           workdir="source/bin/ext/clementine-spotifyblob",
                           haltOnFailure=True,
                           command=["make", "install"]))
    f.addStep(
        shell.ShellCommand(name="strip",
                           workdir="source/bin",
                           haltOnFailure=True,
                           command="strip spotify/version*/blob"))
    f.addStep(OutputFinder(pattern="bin/spotify/version*-*bit"))
    f.addStep(
        shell.SetProperty(command=["echo", SPOTIFYBASE],
                          property="spotifybase"))
    f.addStep(
        master.MasterShellCommand(name="verify",
                                  command=util.Interpolate("""
    openssl dgst -sha512 -verify %(prop:spotifybase)s/clementine-spotify-public.pem \
      -signature %(prop:spotifybase)s/%(prop:output-filename)s/blob.sha512 \
      %(prop:spotifybase)s/%(prop:output-filename)s/blob
  """)))
    return f
Exemplo n.º 9
0
    def test_env_list_subst(self):
        cmd = [sys.executable, '-c', 'import os; print(os.environ["HELLO"])']
        os.environ['WORLD'] = 'hello'
        os.environ['LIST'] = 'world'
        self.setup_step(
            master.MasterShellCommand(command=cmd,
                                      env={'HELLO': ['${WORLD}', '${LIST}']}))
        if runtime.platformType == 'win32':
            self.expect_log_file('stdio', "hello;world\r\n")
        else:
            self.expect_log_file('stdio', "hello:world\n")
        self.expect_outcome(result=SUCCESS)

        d = self.run_step()

        @d.addBoth
        def _restore_env(res):
            del os.environ['WORLD']
            del os.environ['LIST']
            return res

        return d
Exemplo n.º 10
0
 def test_real_cmd_fails(self):
     cmd = [sys.executable, '-c', 'import sys; sys.exit(1)']
     self.setupStep(master.MasterShellCommand(command=cmd))
     self.expectLogfile('stdio', "")
     self.expectOutcome(result=FAILURE, state_string="failed (1) (failure)")
     return self.runStep()