def testWorkdir(self): self.build.setProperty("revision", 47) self.failUnlessEqual(self.build_status.getProperty("revision"), 47) c = ShellCommand(command=["tar", "czf", "foo.tar.gz", "source"]) c.setBuild(self.build) workdir = WithProperties("workdir-%d", "revision") workdir = c._interpolateWorkdir(workdir) self.failUnlessEqual(workdir, "workdir-47")
def testSlaveName(self): c = ShellCommand(workdir=dir, command=[ "touch", WithProperties("%s-slave", "slavename"), ]) c.setBuild(self.build) cmd = c._interpolateProperties(c.command) self.failUnlessEqual(cmd, ["touch", "bot12-slave"])
def testSlaveName(self): c = ShellCommand(workdir=dir, command=["touch", WithProperties("%s-slave", "slavename"), ]) c.setBuild(self.build) cmd = c._interpolateProperties(c.command) self.failUnlessEqual(cmd, ["touch", "bot12-slave"])
def testSourceStamp(self): c = ShellCommand(workdir=dir, command=[ "touch", WithProperties("%s-dir", "branch"), WithProperties("%s-rev", "revision"), ]) c.setBuild(self.build) cmd = c._interpolateProperties(c.command) self.failUnlessEqual(cmd, ["touch", "branch2-dir", "1234-rev"])
def testWithPropertiesEmpty(self): self.build.setProperty("empty", None) c = ShellCommand(workdir=dir, command=[ "tar", "czf", WithProperties("build-%(empty)s.tar.gz"), "source" ]) c.setBuild(self.build) cmd = c._interpolateProperties(c.command) self.failUnlessEqual(cmd, ["tar", "czf", "build-.tar.gz", "source"])
def testBuildNumber(self): c = ShellCommand(workdir=dir, command=[ "touch", WithProperties("build-%d", "buildnumber"), WithProperties("builder-%s", "buildername"), ]) c.setBuild(self.build) cmd = c._interpolateProperties(c.command) self.failUnlessEqual(cmd, ["touch", "build-5", "builder-fakebuilder"])
def testSourceStamp(self): c = ShellCommand(workdir=dir, command=["touch", WithProperties("%s-dir", "branch"), WithProperties("%s-rev", "revision"), ]) c.setBuild(self.build) cmd = c._interpolateProperties(c.command) self.failUnlessEqual(cmd, ["touch", "branch2-dir", "1234-rev"])
def testWithPropertiesEmpty(self): self.build.setProperty("empty", None) c = ShellCommand(workdir=dir, command=["tar", "czf", WithProperties("build-%(empty)s.tar.gz"), "source"]) c.setBuild(self.build) cmd = c._interpolateProperties(c.command) self.failUnlessEqual(cmd, ["tar", "czf", "build-.tar.gz", "source"])
def testBuildNumber(self): c = ShellCommand(workdir=dir, command=["touch", WithProperties("build-%d", "buildnumber"), WithProperties("builder-%s", "buildername"), ]) c.setBuild(self.build) cmd = c._interpolateProperties(c.command) self.failUnlessEqual(cmd, ["touch", "build-5", "builder-fakebuilder"])
def testWithPropertiesDict(self): self.build.setProperty("other", "foo") self.build.setProperty("missing", None) c = ShellCommand(workdir=dir, command=[ "tar", "czf", WithProperties("build-%(other)s.tar.gz"), "source" ]) c.setBuild(self.build) cmd = c._interpolateProperties(c.command) self.failUnlessEqual(cmd, ["tar", "czf", "build-foo.tar.gz", "source"])
def testWithPropertiesDict(self): self.build.setProperty("other", "foo") self.build.setProperty("missing", None) c = ShellCommand(workdir=dir, command=["tar", "czf", WithProperties("build-%(other)s.tar.gz"), "source"]) c.setBuild(self.build) cmd = c._interpolateProperties(c.command) self.failUnlessEqual(cmd, ["tar", "czf", "build-foo.tar.gz", "source"])
def testWithProperties(self): self.build.setProperty("revision", 47) self.failUnlessEqual(self.build_status.getProperty("revision"), 47) c = ShellCommand(workdir=dir, command=[ "tar", "czf", WithProperties("build-%s.tar.gz", "revision"), "source" ]) c.setBuild(self.build) cmd = c._interpolateProperties(c.command) self.failUnlessEqual(cmd, ["tar", "czf", "build-47.tar.gz", "source"])
def testWithProperties(self): self.build.setProperty("revision", 47) self.failUnlessEqual(self.build_status.getProperty("revision"), 47) c = ShellCommand(workdir=dir, command=["tar", "czf", WithProperties("build-%s.tar.gz", "revision"), "source"]) c.setBuild(self.build) cmd = c._interpolateProperties(c.command) self.failUnlessEqual(cmd, ["tar", "czf", "build-47.tar.gz", "source"])
def setBuild(self, build): ShellCommand.setBuild(self, build) sources = {} for source_stamp in build.getAllSourceStamps(): name = source_stamp.repository.split("/")[-1] sources[name] = {"repository": source_stamp.repository, "revision": source_stamp.revision} command = ["./osbuild", "pull"] if sources: sources_json = json.dumps(sources) command.extend(["--sources", sources_json]) self.setCommand(command)
def setBuild(self, build): ShellCommand.setBuild(self, build) sources = {} for source_stamp in build.getAllSourceStamps(): name = source_stamp.repository.split("/")[-1] sources[name] = { "repository": source_stamp.repository, "revision": source_stamp.revision } command = ["./osbuild", "pull"] if sources: sources_json = json.dumps(sources) command.extend(["--sources", sources_json]) self.setCommand(command)