Ejemplo n.º 1
0
        def __init__(self, test):
            self.project1 = gitwrapper.GitHub("project1")
            self.project2 = gitwrapper.GitHub("project2")
            self.requiringProject = gitwrapper.GitHub("requiringProject")

            self.localClone1 = gitwrapper.LocalClone(self.project1)
            self.localClone2 = gitwrapper.LocalClone(self.project2)
            self.localRequiringProject = gitwrapper.LocalClone(
                self.requiringProject)
            test.assertEquals(self.project1.hash('master'),
                              self.localClone1.hash())
            test.assertEquals(self.project2.hash('master'),
                              self.localClone2.hash())
            test.assertEquals(self.requiringProject.hash(),
                              self.localRequiringProject.hash())

            upsetowrapper.run(self.localRequiringProject,
                              "addRequirement project1")
            upsetowrapper.run(self.localRequiringProject,
                              "addRequirement project2")
            test.assertTrue(
                os.path.exists(self.localRequiringProject.manifestFilename()))
            self.localRequiringProject.addCommitPushManifest()

            self.manifest = upseto.manifest.Manifest.fromDir(
                self.localRequiringProject.directory())
            requirements = self.manifest.requirements()
            test.assertEquals(len(requirements), 2)
            test.assertEquals(requirements[0]['originURL'],
                              "file://" + self.project1.directory())
            test.assertEquals(requirements[0]['hash'], self.project1.hash())
            test.assertEquals(requirements[1]['originURL'],
                              "file://" + self.project2.directory())
            test.assertEquals(requirements[1]['hash'], self.project2.hash())
Ejemplo n.º 2
0
 def addFourthTier(self):
     self.fourthTierProject = gitwrapper.GitHub('forthTier')
     self.localFourthTierProject = gitwrapper.LocalClone(
         self.fourthTierProject)
     upsetowrapper.run(self.localFourthTierProject,
                       "addRequirement recursiveProject")
     self.localFourthTierProject.addCommitPushManifest()
Ejemplo n.º 3
0
 def addThirdTier(self):
     self.recursiveProject = gitwrapper.GitHub("recursiveProject")
     self.localRecursiveProject = gitwrapper.LocalClone(
         self.recursiveProject)
     upsetowrapper.run(self.localRecursiveProject,
                       "addRequirement requiringProject")
     self.localRecursiveProject.addCommitPushManifest()
Ejemplo n.º 4
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)
Ejemplo n.º 5
0
    def test_unsubmit_empty(self):
        self.producer = gitwrapper.GitHub("producer")
        localProducer = gitwrapper.LocalClone(self.producer)
        solventwrapper.run(localProducer, "unsubmit")

        self.assertEquals(len(self.osmosisPair.official.client().listLabels()),
                          0)
        self.assertEquals(len(self.osmosisPair.local.client().listLabels()), 0)
Ejemplo n.º 6
0
    def fixture(self):
        self.project1 = gitwrapper.GitHub("project1")
        self.project2 = gitwrapper.GitHub("project2")
        self.requiringProject = gitwrapper.GitHub("requiringProject")

        localClone1 = gitwrapper.LocalClone(self.project1)
        localClone2 = gitwrapper.LocalClone(self.project2)
        localRequiringProject = gitwrapper.LocalClone(self.requiringProject)
        self.assertEquals(self.project1.hash('master'), localClone1.hash())
        self.assertEquals(self.project2.hash('master'), localClone2.hash())
        self.assertEquals(self.requiringProject.hash(),
                          localRequiringProject.hash())

        solventwrapper.upseto(localRequiringProject, "addRequirement project1")
        solventwrapper.upseto(localRequiringProject, "addRequirement project2")
        localRequiringProject.addCommitPushManifest()

        self.recursiveProject = gitwrapper.GitHub("recursiveProject")
        localRecursiveProject = gitwrapper.LocalClone(self.recursiveProject)
        solventwrapper.upseto(localRecursiveProject,
                              "addRequirement requiringProject")
        localRecursiveProject.addCommitPushManifest()
Ejemplo n.º 7
0
 def createBuildProduct(self):
     self.producer = gitwrapper.GitHub("producer")
     localProducer = gitwrapper.LocalClone(self.producer)
     localProducer.writeFile("build/theDirectory/theProduct",
                             "the contents")
     solventwrapper.configureAsOfficial()
     solventwrapper.run(localProducer, "submitproduct theProductName build")
     self.assertEquals(len(self.osmosisPair.local.client().listLabels()), 1)
     label = 'solvent__producer__theProductName__%s__officialcandidate' % self.producer.hash(
     )
     self.assertEquals(self.osmosisPair.local.client().listLabels(),
                       [label])
     self.assertEquals(len(self.osmosisPair.official.client().listLabels()),
                       1)
     solventwrapper.run(localProducer, "approve --product=theProductName")
     return localProducer
Ejemplo n.º 8
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)
Ejemplo n.º 9
0
    def test_unsubmit_dirty(self):
        self.producer = gitwrapper.GitHub("producer")
        localProducer = gitwrapper.LocalClone(self.producer)
        localProducer.writeFile("build/theDirectory/theProduct",
                                "the contents")
        solventwrapper.run(localProducer, "submitbuild")
        solventwrapper.run(localProducer, "submitproduct theProductName build")
        self.assertEquals(len(self.osmosisPair.local.client().listLabels()), 2)
        self.assertEquals(len(self.osmosisPair.official.client().listLabels()),
                          2)
        label = 'solvent__producer__theProductName__%s__dirty' % self.producer.hash(
        )
        self.assertIn(label, self.osmosisPair.local.client().listLabels())
        label = 'solvent__producer__build__%s__dirty' % self.producer.hash()
        self.assertIn(label, self.osmosisPair.local.client().listLabels())

        solventwrapper.run(localProducer, "unsubmit")

        self.assertEquals(len(self.osmosisPair.official.client().listLabels()),
                          0)
        self.assertEquals(len(self.osmosisPair.local.client().listLabels()), 0)
Ejemplo n.º 10
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)
Ejemplo n.º 11
0
        case.addThirdTier()
        upsetowrapper.runShouldFail(case.localClone1, "checkRequirements", "manifest")
        upsetowrapper.runShouldFail(case.localClone2, "checkRequirements", "manifest")
        upsetowrapper.run(case.localRequiringProject, "checkRequirements")
        upsetowrapper.run(case.localRecursiveProject, "checkRequirements")

        upsetowrapper.run(case.localClone1, "checkRequirements --allowNoManifest")
        upsetowrapper.run(case.localClone2, "checkRequirements --allowNoManifest")
        upsetowrapper.run(case.localRequiringProject, "checkRequirements --allowNoManifest")
        upsetowrapper.run(case.localRecursiveProject, "checkRequirements --allowNoManifest")

    def test_Bugfix_reloadManifestAfterFulfillingRequirements_AlsoTestsDiamondAddRequirement(self):
        case = self.SimpleManifest_OneProjectDependsOnTwoOthers(self)
        case.addThirdTier()

        betweenProject = gitwrapper.GitHub("between")
        localBetweenProject = gitwrapper.LocalClone(betweenProject)
        upsetowrapper.run(localBetweenProject, "addRequirement requiringProject")
        localBetweenProject.addCommitPushManifest()
        upsetowrapper.run(case.localRecursiveProject, "addRequirement between")
        case.localRecursiveProject.addCommitPushManifest()
        previousHash = case.localRecursiveProject.hash()

        case.localClone1.createAddCommitPush("nextgeneration")
        upsetowrapper.run(case.localRequiringProject, "addRequirement project1")
        case.localRequiringProject.addCommitPushManifest()
        upsetowrapper.run(localBetweenProject, "addRequirement requiringProject")
        localBetweenProject.addCommitPushManifest()
        upsetowrapper.run(case.localRecursiveProject, "addRequirement requiringProject between")
        case.localRecursiveProject.addCommitPushManifest()
Ejemplo n.º 12
0
        upsetowrapper.run(case.localClone1,
                          "checkRequirements --allowNoManifest")
        upsetowrapper.run(case.localClone2,
                          "checkRequirements --allowNoManifest")
        upsetowrapper.run(case.localRequiringProject,
                          "checkRequirements --allowNoManifest")
        upsetowrapper.run(case.localRecursiveProject,
                          "checkRequirements --allowNoManifest")

    def test_Bugfix_reloadManifestAfterFulfillingRequirements_AlsoTestsDiamondAddRequirement(
            self):
        case = self.SimpleManifest_OneProjectDependsOnTwoOthers(self)
        case.addThirdTier()

        betweenProject = gitwrapper.GitHub("between")
        localBetweenProject = gitwrapper.LocalClone(betweenProject)
        upsetowrapper.run(localBetweenProject,
                          "addRequirement requiringProject")
        localBetweenProject.addCommitPushManifest()
        upsetowrapper.run(case.localRecursiveProject, "addRequirement between")
        case.localRecursiveProject.addCommitPushManifest()
        previousHash = case.localRecursiveProject.hash()

        case.localClone1.createAddCommitPush("nextgeneration")
        upsetowrapper.run(case.localRequiringProject,
                          "addRequirement project1")
        case.localRequiringProject.addCommitPushManifest()
        upsetowrapper.run(localBetweenProject,
                          "addRequirement requiringProject")
        localBetweenProject.addCommitPushManifest()