コード例 #1
0
    def testInit(self):
        self.assertEqual(len(self.eups.path), 2)
        self.assertEqual(self.eups.path[0], testEupsStack)
        self.assertEqual(self.eups.path[1], os.environ["EUPS_USERDATA"])
        self.assertEqual(self.eups.getUpsDB(testEupsStack), self.dbpath)
        self.assertEqual(len(self.eups.versions), 2)
        self.assertIn(testEupsStack, self.eups.versions)
        self.assert_(self.eups.versions[testEupsStack] is not None)

        flavors = self.eups.versions[testEupsStack].getFlavors()
        self.assertEqual(len(flavors), 3)
        for flav in "Linux64 Linux generic".split():
            self.assertIn(flav, flavors)

        tags = self.eups.tags.getTagNames()
        exptags = "latest setup stable current commandLine keep path type version versionExpr warn"
        for tag in exptags.split():
            self.assertIn(tag, tags)

        self.assertEqual(len(self.eups.preferredTags), 5)
        for tag in "version versionExpr stable current latest".split():
            self.assertIn(tag, self.eups.preferredTags)

        # There should have been some cache files created
        # flavors.append("generic")
        for flav in flavors:
            cache = os.path.join(self.eups._userStackCache(testEupsStack),
                                 ProductStack.persistFilename(flav))
            self.assert_(os.path.exists(cache),
                         "Cache file for %s not written" % flav)
コード例 #2
0
    def testSave(self):
        self.assert_(self.stack.saveNeeded())

        self.stack.clearCache("Linux Linux64 Darwin DarwinX86 generic".split())
        self.assertEquals(len(ProductStack.findCachedFlavors(self.dbpath)),0)

        cache = os.path.join(self.dbpath, 
                             ProductStack.persistFilename("Darwin"))
        self.assert_(not os.path.exists(cache))

        self.stack.save()
        self.assert_(not self.stack.saveNeeded())
        self.assert_(os.path.exists(cache))

        saved = ProductStack.findCachedFlavors(self.dbpath)
        self.assertEquals(len(saved), 1)
        self.assertEquals(saved[0], "Darwin")

        self.stack.reload("Darwin")
        self.assertEquals(len(self.stack.getProductNames("Darwin")), 1)
        p = self.stack.getProduct("fw", "1.2", "Darwin")
        self.assertEquals(p.name, "fw")
        self.assertEquals(p.version, "1.2")
        self.assertEquals(p.flavor, "Darwin")
        self.assertEquals(p.dir, "/opt/sw/Darwin/fw/1.2")
        self.assertEquals(p.tablefile, "none")
        self.assertEquals(p.db, self.dbpath)
        

        self.stack.clearCache()
        self.assertEquals(len(ProductStack.findCachedFlavors(self.dbpath)),0)
        self.assert_(not os.path.exists(cache))
コード例 #3
0
    def tearDown(self):
        flavors = self.eups.versions[testEupsStack].getFlavors()
        for flav in flavors:
            file = os.path.join(self.dbpath, ProductStack.persistFilename(flav))
            if os.path.exists(file):
                os.remove(file)

        usercachedir = os.path.join(testEupsStack,"_userdata_","_caches_")
        if os.path.exists(usercachedir):
            os.system('rm -rf "%s"' % usercachedir)

        if os.path.exists(self.betachain):  os.remove(self.betachain)

        newprod = os.path.join(self.dbpath,"newprod")
        if os.path.exists(newprod):
            for dir,subdirs,files in os.walk(newprod, False):
                for file in files:
                    os.remove(os.path.join(dir,file))
                for file in subdirs:
                    os.rmdir(os.path.join(dir,file))
            os.rmdir(newprod)

        pdir = os.path.join(testEupsStack, "Linux", "newprod")
        pdir20 = os.path.join(pdir, "2.0")
        if os.path.exists(pdir20):
            shutil.rmtree(pdir20)

        eups.hooks.config.Eups.userTags = []

        os.environ = self.environ0
コード例 #4
0
    def setUp(self):
        self.environ0 = os.environ.copy()

        os.environ["EUPS_PATH"] = testEupsStack
        os.environ["EUPS_FLAVOR"] = "Linux"
        os.environ["EUPS_USERDATA"] = os.path.join(testEupsStack,"_userdata_")
        self.dbpath = os.path.join(testEupsStack, "ups_db")
        self.cache = os.path.join(self.dbpath,
                                  ProductStack.persistFilename("Linux"))
        if os.path.exists(self.cache):
            os.remove(self.cache)

        self.betachain = os.path.join(self.dbpath, "python", "beta.chain")
コード例 #5
0
    def testAutoSave(self):
        self.assert_(self.stack.saveNeeded())

        cache = os.path.join(os.environ["PWD"],
                             ProductStack.persistFilename("Darwin"))
        if os.path.exists(cache):  os.remove(cache)

        stack = ProductStack(os.path.join(testEupsStack, "ups_db"), 
                             os.environ["PWD"], autosave=True)
        self.assert_(not stack.saveNeeded())
        stack.addProduct(Product("fw", "1.2", "Darwin", 
                                 "/opt/sw/Darwin/fw/1.2", "none"))
        self.assert_(not stack.saveNeeded())
        self.assert_(os.path.exists(cache))
        if os.path.exists(cache):  os.remove(cache)
コード例 #6
0
    def testSaveEmptyFlavor(self):
        self.stack.clearCache("Linux")
        cache = os.path.join(self.dbpath, 
                             ProductStack.persistFilename("Linux"))
        self.assert_(not os.path.exists(cache))

        try: 
            self.stack.save("Linux")
            self.assert_(os.path.exists(cache))
            self.stack.reload("Linux")
            flavors = self.stack.getFlavors()
            self.assertEquals(len(flavors), 2)
            expected = "Darwin Linux".split()
            for flav in expected:
                self.assert_(flav in flavors)
            self.assertEquals(len(self.stack.getProductNames("Linux")), 0)

        finally:
            if os.path.exists(cache):
                os.remove(cache)
コード例 #7
0
 def setUp(self):
     self.dbpath = os.path.join(testEupsStack, "ups_db")
     self.cache = os.path.join(self.dbpath, 
                               ProductStack.persistFilename("Linux"))
     if os.path.exists(self.cache):
         os.remove(self.cache)
コード例 #8
0
 def testMisc(self):
     self.assertEquals(ProductStack.persistFilename("Linux"),
                       "Linux.pickleDB1_3_0")
     self.assertEquals(self.stack.getDbPath(), 
                       os.path.join(testEupsStack, "ups_db"))