Exemplo n.º 1
0
    def test_workDirty(self):
        self.producer = gitwrapper.GitHub("producer")
        localProducer = gitwrapper.LocalClone(self.producer)
        localProducer.writeFile("build/theDirectory/theProduct",
                                "the contents")
        localProducer.writeFile("imaketheprojectdirty", "dirty dirty boy")
        localProducer.writeFile("../isullytheworkspace", "and my pants too")
        solventwrapper.runShouldFail(localProducer,
                                     "submitproduct theProductName build",
                                     "sullied",
                                     env=dict(SOLVENT_CLEAN="yes"))
        solventwrapper.run(localProducer, "submitproduct theProductName build")

        self.assertEquals(len(self.osmosisPair.local.client().listLabels()), 1)
        label = 'solvent__producer__theProductName__%s__dirty' % self.producer.hash(
        )
        self.assertEquals(self.osmosisPair.local.client().listLabels(),
                          [label])
        self.assertEquals(len(self.osmosisPair.official.client().listLabels()),
                          1)

        solventwrapper.runWhatever(
            localProducer.directory(),
            "python -m coverage run --parallel-mode -m solvent.cheating --configurationFile=%s "
            "changestate --fromState=dirty --toState=official --product=theProductName"
            % solventwrapper.configurationFile)

        self.assertEquals(len(self.osmosisPair.local.client().listLabels()), 1)
        label = 'solvent__producer__theProductName__%s__official' % self.producer.hash(
        )
        self.assertEquals(self.osmosisPair.local.client().listLabels(),
                          [label])
        self.assertEquals(len(self.osmosisPair.official.client().listLabels()),
                          1)
Exemplo n.º 2
0
    def test_localize(self):
        self.createBuildProduct()

        self.assertEquals(len(self.osmosisPair.local.client().listLabels()), 1)
        label = 'solvent__producer__theProductName__%s__official' % self.producer.hash(
        )
        self.assertEquals(self.osmosisPair.local.client().listLabels(),
                          [label])
        self.assertEquals(len(self.osmosisPair.official.client().listLabels()),
                          1)

        self.osmosisPair.local.client().eraseLabel(label)
        self.assertEquals(self.osmosisPair.local.client().listLabels(), [])
        solventwrapper.run(os.getcwd(), "localize --label=%s" % label)
        self.assertEquals(self.osmosisPair.local.client().listLabels(),
                          [label])

        solventwrapper.run(os.getcwd(), "localize --label=%s" % label)

        self.osmosisPair.local.client().eraseLabel(label)
        solventwrapper.runShouldFail(
            os.getcwd(),
            "localize --label=%s" % label,
            "official",
            env=dict(SOLVENT_CONFIG="WITH_OFFICIAL_OBJECT_STORE: No"))
Exemplo n.º 3
0
    def test_updateRequirement(self):
        self.createBuildProduct()
        self.cleanLocalClonesDir()
        localClone1 = gitwrapper.LocalClone(self.project1)
        self.assertNotEquals(self.producer.hash()[-2:], "00")
        solventwrapper.run(
            localClone1, "addrequirement --originURL=%s --hash=%s" %
            (self.producer.url(), self.producer.hash()[:-2] + "00"))
        previous = localClone1.readFile("solvent.manifest")
        solventwrapper.run(
            localClone1, "addrequirement --originURL=%s --hash=%s" %
            (self.producer.url(), self.producer.hash()))
        self.assertEquals(len(localClone1.readFile("solvent.manifest")),
                          len(previous))

        solventwrapper.run(
            localClone1,
            "bring --repository=producer --product=theProductName --destination=%s"
            %
            (os.path.join(localClone1.directory(), "build", "theProductDir")))

        solventwrapper.run(localClone1,
                           "removerequirement --originURLBasename=producer")
        solventwrapper.runShouldFail(
            localClone1,
            "bring --repository=producer --product=theProductName --destination=%s"
            %
            (os.path.join(localClone1.directory(), "build", "theProductDir")),
            "requirement")
Exemplo n.º 4
0
    def test_FulfillUpsetoRequirements(self):
        localRequiringProject = gitwrapper.LocalClone(self.requiringProject)
        localClone1 = gitwrapper.LocalClone(self.project1)
        localClone1.writeFile("build/product1", "product1 contents")
        solventwrapper.upseto(localRequiringProject, "fulfillRequirements")
        localRequiringProject.writeFile("build/product2", "product2 contents")

        solventwrapper.configureAsOfficial()
        solventwrapper.run(localRequiringProject, "submitbuild")
        solventwrapper.run(localRequiringProject, "approve")
        solventwrapper.configureAsNonOfficial()

        self.cleanLocalClonesDir()
        localRecursiveProject = gitwrapper.LocalClone(self.recursiveProject)
        solventwrapper.run(localRecursiveProject, "checkrequirements")
        solventwrapper.run(localRecursiveProject, "fulfillrequirements")

        self.assertTrue(localClone1.fileExists("build/product1"))
        self.assertTrue(localRequiringProject.fileExists("build/product2"))

        solventwrapper.run(localRecursiveProject, "checkrequirements")
        labels = self.osmosisPair.local.client().listLabels()
        self.assertEquals(len(labels), 1)
        label = labels[0]
        self.osmosisPair.local.client().eraseLabel(label)
        solventwrapper.run(localRecursiveProject, "checkrequirements")
        self.osmosisPair.official.client().eraseLabel(label)
        solventwrapper.runShouldFail(localRecursiveProject,
                                     "checkrequirements", "label")
Exemplo n.º 5
0
    def test_SubmitANonUpsetoedProject_FailsIfWorkspaceIsSullied(self):
        localClone1 = gitwrapper.LocalClone(self.project1)
        localClone2 = gitwrapper.LocalClone(self.project2)

        solventwrapper.runShouldFail(localClone1,
                                     "submitbuild",
                                     "sullied",
                                     env=dict(SOLVENT_CLEAN="yes"))
Exemplo n.º 6
0
    def test_ConfigurationMissingOfficialOsmosis(self):
        configuration = tempfile.NamedTemporaryFile()
        solventwrapper.configurationFile = configuration.name
        localClone1 = gitwrapper.LocalClone(self.project1)
        solventwrapper.runShouldFail(localClone1, "submitbuild", "empty")

        configuration.write("key: value\n")
        configuration.flush()
        solventwrapper.runShouldFail(localClone1, "submitbuild", "official")
Exemplo n.º 7
0
    def test_SubmitTwiceDoesNotWork_ForceWorks(self):
        localClone1 = gitwrapper.LocalClone(self.project1)

        solventwrapper.run(localClone1, "submitbuild")
        solventwrapper.runShouldFail(localClone1, "submitbuild", "already")
        solventwrapper.run(localClone1, "submitbuild --force")
        solventwrapper.runShouldFail(localClone1, "submitbuild", "already")
        solventwrapper.run(localClone1,
                           "submitbuild",
                           env=dict(SOLVENT_CONFIG="FORCE: yes"))
Exemplo n.º 8
0
    def test_ApproveTwiceDoesNotWork_ForceDoesNothing(self):
        localClone1 = gitwrapper.LocalClone(self.project1)

        solventwrapper.configureAsOfficial()
        solventwrapper.run(localClone1, "submitbuild")
        solventwrapper.run(localClone1, "approve")
        solventwrapper.runShouldFail(localClone1, "approve", "already")
        solventwrapper.runShouldFail(localClone1,
                                     "approve",
                                     "already",
                                     env=dict(SOLVENT_CONFIG="FORCE: yes"))
Exemplo n.º 9
0
    def test_LabelExists(self):
        localClone1 = gitwrapper.LocalClone(self.project1)
        hash = localClone1.hash()
        localClone1.writeFile("build/product1", "product1 contents")

        solventwrapper.run(localClone1, "submitbuild")
        self.assertEquals(len(self.osmosisPair.local.client().listLabels()), 1)
        label = 'solvent__project1__build__%s__dirty' % hash
        self.assertEquals(self.osmosisPair.local.client().listLabels(),
                          [label])
        self.assertEquals(len(self.osmosisPair.official.client().listLabels()),
                          1)
        self.assertEquals(self.osmosisPair.official.client().listLabels(),
                          [label])

        solventwrapper.run(localClone1, 'labelexists --label=%s' % label)
        solventwrapper.runShouldFail(localClone1,
                                     'labelexists --label=%sA' % label,
                                     "exist")
        solventwrapper.runShouldFail(localClone1,
                                     'labelexists --label=A%s' % label,
                                     "exist")
        solventwrapper.runShouldFail(localClone1, 'labelexists --label=A',
                                     "exist")
        solventwrapper.runShouldFail(localClone1,
                                     'labelexists --label=%s' % label[:-1],
                                     "exist")
Exemplo n.º 10
0
 def test_checkSolventRequirements_DependsOnSolvent__build__productName(
         self):
     self.createBuildProduct()
     self.cleanLocalClonesDir()
     localClone1 = gitwrapper.LocalClone(self.project1)
     solventwrapper.run(
         localClone1, "addrequirement --originURL=%s --hash=%s" %
         (self.producer.url(), self.producer.hash()))
     label = 'solvent__producer__theProductName__%s__official' % self.producer.hash(
     )
     buildLabel = 'solvent__producer__build__%s__official' % self.producer.hash(
     )
     solventwrapper.runShouldFail(localClone1, "checkrequirements", "label")
     self.osmosisPair.local.client().renameLabel(label, buildLabel)
     solventwrapper.run(localClone1, "checkrequirements")
Exemplo n.º 11
0
    def test_FulfillUpsetoRequirements_NoOfficialBuild(self):
        localClone1 = gitwrapper.LocalClone(self.project1)
        localClone1.writeFile("build/product1", "product1 contents")
        solventwrapper.configureAsOfficial()
        solventwrapper.run(localClone1, "submitbuild")

        self.cleanLocalClonesDir()
        localClone2 = gitwrapper.LocalClone(self.project2)
        localClone2.writeFile("build/product2", "product2 contents")
        solventwrapper.run(localClone2, "submitbuild")
        solventwrapper.run(localClone2, "approve")
        solventwrapper.configureAsNonOfficial()

        self.cleanLocalClonesDir()
        localRequiringProject = gitwrapper.LocalClone(self.requiringProject)
        solventwrapper.runShouldFail(localRequiringProject,
                                     "fulfillrequirements", "build")
Exemplo n.º 12
0
    def test_solventCanBeConfiguredFromTheEnvironment(self):
        self.producer = gitwrapper.GitHub("producer")
        localProducer = gitwrapper.LocalClone(self.producer)
        localProducer.writeFile("build/theDirectory/theProduct",
                                "the contents")
        localProducer.writeFile("imaketheprojectdirty", "dirty dirty boy")
        localProducer.writeFile("../isullytheworkspace", "and my pants too")
        solventwrapper.runShouldFail(localProducer,
                                     "submitproduct theProductName build",
                                     "sullied",
                                     env=dict(SOLVENT_CONFIG="CLEAN: yes"))
        solventwrapper.run(localProducer, "submitproduct theProductName build")

        self.assertEquals(len(self.osmosisPair.local.client().listLabels()), 1)
        label = 'solvent__producer__theProductName__%s__dirty' % self.producer.hash(
        )
        self.assertEquals(self.osmosisPair.local.client().listLabels(),
                          [label])
        self.assertEquals(len(self.osmosisPair.official.client().listLabels()),
                          1)
Exemplo n.º 13
0
    def test_ProtectAgainstCommonMistakes_ProcMounted(self):
        self.producer = gitwrapper.GitHub("producer")
        localProducer = gitwrapper.LocalClone(self.producer)
        localProducer.writeFile("build/rootfs/etc/config", "the contents")
        os.mkdir(os.path.join(localProducer.directory(), "proc"))
        with open("build/mount.txt", "a") as f:
            f.write(
                "proc on %s/proc type proc (rw,nosuid,nodev,noexec,relatime)\n"
                % (os.path.join(localProducer.directory(), 'build', 'rootfs',
                                'proc'), ))
        solventwrapper.runShouldFail(localProducer,
                                     "submitproduct rootfs build/rootfs",
                                     "mounted")

        solventwrapper.run(
            localProducer,
            "submitproduct rootfs build/rootfs --noCommonMistakesProtection")
        self.assertEquals(len(self.osmosisPair.local.client().listLabels()), 1)
        label = 'solvent__producer__rootfs__%s__dirty' % self.producer.hash()
        self.assertEquals(self.osmosisPair.local.client().listLabels(),
                          [label])
        self.assertEquals(len(self.osmosisPair.official.client().listLabels()),
                          1)
Exemplo n.º 14
0
 def test_invalidInputForAddRequirementCommandLine(self):
     self.createBuildProduct()
     self.cleanLocalClonesDir()
     localClone1 = gitwrapper.LocalClone(self.project1)
     solventwrapper.runShouldFail(
         localClone1, "addrequirement --originURL=%s --hash=%s" %
         ("thisisnotagiturl", self.producer.hash()), "invalid")
     solventwrapper.runShouldFail(
         localClone1, "addrequirement --originURL=%s --hash=%s" %
         (self.producer.url(), self.producer.hash()[:-2]), "invalid")
     solventwrapper.runShouldFail(
         localClone1,
         "bring --repository=producer --product=theProductName --destination=%s"
         %
         (os.path.join(localClone1.directory(), "build", "theProductDir")),
         "requirement")
Exemplo n.º 15
0
 def noDirtyLabel():
     return solventwrapper.runShouldFail(
         localClone1,
         "printlabel --repositoryBasename=producer --product=theProductName",
         "requirement")
Exemplo n.º 16
0
 def test_SubmitBuildNotAllowedFromANonGitProject(self):
     localClone1 = gitwrapper.LocalClone(self.project1)
     self.osmosisPair.exit()
     solventwrapper.runShouldFail(localClone1, "submitbuild", "osmosis")
     self.osmosisPair = None
Exemplo n.º 17
0
 def noCleanLabel():
     return solventwrapper.runShouldFail(
         localClone1,
         "printlabel --repositoryBasename=producer --product=theProductName",
         "requirement",
         env=dict(SOLVENT_CLEAN="yes"))