コード例 #1
0
 def test_run_property(self):
     self.setupStep(shell.SetProperty(property="res", command="cmd"))
     self.expectCommands(
         ExpectShell(workdir='wkdir', usePTY='slave-config', command="cmd")
         + ExpectShell.log('stdio', stdout='\n\nabcdef\n') + 0)
     self.expectOutcome(result=SUCCESS, status_text=["property 'res' set"])
     self.expectProperty("res", "abcdef")  # note: stripped
     self.expectLogfile('property changes', r"res: 'abcdef'")
     return self.runStep()
コード例 #2
0
 def test_run_failure(self):
     self.setupStep(shell.SetProperty(property="res", command="blarg"))
     self.expectCommands(
         ExpectShell(
             workdir='wkdir', usePTY='slave-config', command="blarg") +
         ExpectShell.log('stdio', stderr='cannot blarg: File not found') +
         1)
     self.expectOutcome(result=FAILURE, status_text=["'blarg'", "failed"])
     self.expectNoProperty("res")
     return self.runStep()
コード例 #3
0
    def test_run_extract_fn_cmdfail_empty(self):
        def extract_fn(rc, stdout, stderr):
            self.assertEqual((rc, stdout, stderr), (3, '', ''))
            return dict()

        self.setupStep(shell.SetProperty(extract_fn=extract_fn, command="cmd"))
        self.expectCommands(
            ExpectShell(workdir='wkdir', usePTY='slave-config', command="cmd")
            + 3)
        # note that extract_fn *is* called anyway, but returns no properties
        self.expectOutcome(result=FAILURE, status_text=["'cmd'", "failed"])
        return self.runStep()
コード例 #4
0
    def test_run_extract_fn_cmdfail(self):
        def extract_fn(rc, stdout, stderr):
            self.assertEqual((rc, stdout, stderr), (3, '', ''))
            return dict(a=1, b=2)

        self.setupStep(shell.SetProperty(extract_fn=extract_fn, command="cmd"))
        self.expectCommands(
            ExpectShell(workdir='wkdir', usePTY='slave-config', command="cmd")
            + 3)
        # note that extract_fn *is* called anyway
        self.expectOutcome(result=FAILURE, status_text=["2 properties set"])
        self.expectLogfile('property changes', 'a: 1\nb: 2')
        return self.runStep()
コード例 #5
0
    def test_run_extract_fn_exception(self):
        def extract_fn(rc, stdout, stderr):
            raise RuntimeError("oh noes")

        self.setupStep(shell.SetProperty(extract_fn=extract_fn, command="cmd"))
        self.expectCommands(
            ExpectShell(workdir='wkdir', usePTY='slave-config', command="cmd")
            + 0)
        # note that extract_fn *is* called anyway, but returns no properties
        self.expectOutcome(result=EXCEPTION,
                           status_text=["setproperty", "exception"])
        d = self.runStep()
        d.addCallback(lambda _: self.assertEqual(
            len(self.flushLoggedErrors(RuntimeError)), 1))
        return d
コード例 #6
0
    def test_run_extract_fn(self):
        def extract_fn(rc, stdout, stderr):
            self.assertEqual((rc, stdout, stderr), (0, 'startend', 'STARTEND'))
            return dict(a=1, b=2)

        self.setupStep(shell.SetProperty(extract_fn=extract_fn, command="cmd"))
        self.expectCommands(
            ExpectShell(workdir='wkdir', usePTY='slave-config', command="cmd")
            + ExpectShell.log('stdio', stdout='start', stderr='START') +
            ExpectShell.log('stdio', stdout='end') +
            ExpectShell.log('stdio', stderr='END') + 0)
        self.expectOutcome(result=SUCCESS, status_text=["2 properties set"])
        self.expectLogfile('property changes', 'a: 1\nb: 2')
        self.expectProperty("a", 1)
        self.expectProperty("b", 2)
        return self.runStep()
コード例 #7
0
ファイル: builders.py プロジェクト: garciaadrian/Buildbot
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
コード例 #8
0
 def test_constructor_conflict(self):
     self.assertRaises(
         config.ConfigErrors,
         lambda: shell.SetProperty(property='foo', extract_fn=lambda: None))
コード例 #9
0
ファイル: master.py プロジェクト: astagi/r2d2
from buildbot.steps import shell
from time import gmtime, strftime
from buildbot.process.properties import WithProperties, Interpolate

git_fetch_step = Git(repourl=config.REPOSITORY,
                     mode='incremental',
                     submodules=True,
                     timeout=120)

export_sdk_cmd = 'export ANDROID_HOME={};'.format(config.ANDROID_HOME)
export_sdk_step = ShellCommand(command=export_sdk_cmd)
make_step = ShellCommand(command=export_sdk_cmd + config.PRE_MAKE_STEP +
                         config.MAKE_STEP)
test_step = ShellCommand(command=export_sdk_cmd + config.TEST_STEP)

update_rev_step = shell.SetProperty(command='git rev-parse HEAD',
                                    property='gitlastrev')
update_tag_step = shell.SetProperty(
    command='git describe --tags | awk -F\'-\' \'{print $1}\'',
    property='gitversion')


def get_release_step(type):
    new_build_path = '../../../builds/{}_%(prop:gitversion)s_{}_{}.apk'.format(
        config.APP_NAME, type, strftime('%Y%m%d', gmtime()))

    return ShellCommand(
        command=['cp', config.BUILD_LOCATION,
                 Interpolate(new_build_path)])


def get_changelog_step(type):
コード例 #10
0
    def __init__ ( self, baseURL, useBuildType=None, arguments=[]):
        """Factory for CMake out-of-source builds with extra buildbot code.

        Uses the following builder properties (strings) when generating a build:
        - generator: CMake generator
        - arguments: build-specific CMake arguments

        @cvar baseURL: url of the svn repository
        @cvar useBuildType: for multi-configuration generators (see CMAKE_BUILD_TYPE)
        @cvar arguments: extra CMake arguments
        """
        assert baseURL is not None
        assert type(arguments) == type([])
        from buildbot.steps import source, slave, shell
        from buildbot.process.properties import WithProperties, Property
        BuildFactory.__init__(self)
        if useBuildType is None:
            buildTypeArgument=[]
        else:
            buildTypeArgument=["--config", useBuildType]

        # update svn
        self.addStep(source.SVN(
            workdir=self.sourcedir,
            mode='update',
            baseURL=baseURL,
            defaultBranch='trunk',
            retry=(30,2) ))
        # recreate build dir
        self.addStep(slave.RemoveDirectory(
            dir=self.workdir,
            haltOnFailure=False,
            flunkOnFailure=False))
        self.addStep(slave.MakeDirectory(
            dir=self.workdir))
        # configure
        self.addStep(shell.Configure(
            command=["cmake", "../source", WithProperties("-G%s", 'generator'), arguments, Property('extra_arguments', default=[])],
            logEnviron=False))
        # compile - the install target builds and then copies files to the
        # production directory (default is subdirectory 'install') and removes
        # full paths from library dependencies so it works when you copy the
        # production files elsewhere
        self.addStep(shell.Compile(
            command=["cmake", "--build", ".", "--target", "install"] + buildTypeArgument,
            logEnviron=False))
        # package - the package target creates an installer/package/archive
        # that contains the production files; the target is only available if 
        # CPack and a package generator are available
        self.addStep(shell.SetProperty(
            haltOnFailure = True,
            flunkOnFailure = True,
            extract_fn=lambda rc, stdout, stderr: {"WITH_CPACK": stdout.find("WITH_CPACK:BOOL=ON") != -1},
            command=["cmake", "-N", "-LA"],
            logEnviron=False))
        self.addStep(shell.ShellCommand(
            name = "Package",
            description = ["packaging"],
            descriptionDone = ["package"],
            haltOnFailure = False,
            flunkOnFailure = False,
            doStepIf=lambda step: step.build.getProperty("WITH_CPACK"),
            command=["cmake", "--build", ".", "--target", "package"] + buildTypeArgument,
            logEnviron=False))