コード例 #1
0
    def testUses(self):
        cmd = eups.cmd.EupsCmd(args="uses tcltk".split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEquals(self.err.getvalue(), "")
        pyuser = re.compile(r"python\s+2.5.2\s+8.5a4")
        lines = self.out.getvalue().split("\n")
        self.assertEquals(len(lines), 2)
        self.assertTrue([l for l in lines if pyuser.match(l)])

        self._resetOut()
        cmd = eups.cmd.EupsCmd(args="uses tcltk -t latest".split(),
                               toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEquals(self.err.getvalue(), "")
        pyuser = re.compile(r"python\s+2.5.2\s+8.5a4")
        lines = self.out.getvalue().split("\n")
        self.assertEquals(len(lines), 2)
        self.assertTrue([l for l in lines if pyuser.match(l)])

        self._resetOut()
        cmd = eups.cmd.EupsCmd(args="uses python".split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEquals(self.err.getvalue(), "")
        lines = self.out.getvalue().split("\n")
        self.assertEquals(len(lines), 1)

        self._resetOut()
        cmd = eups.cmd.EupsCmd(args="uses".split(), toolname=prog)
        self.assertNotEqual(cmd.run(), 0)
        self.assertTrue(self.err.getvalue().find("Please specify a product name"))
コード例 #2
0
ファイル: testCmd.py プロジェクト: mwittgen/eups
    def testUses(self):
        cmd = eups.cmd.EupsCmd(args="uses tcltk".split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEqual(self.err.getvalue(), "")
        pyuser = re.compile(r"python\s+2.5.2\s+8.5a4")
        lines = self.out.getvalue().split("\n")
        self.assertEqual(len(lines), 2)
        self.assertTrue([l for l in lines if pyuser.match(l)])

        self._resetOut()
        cmd = eups.cmd.EupsCmd(args="uses tcltk -t latest".split(),
                               toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEqual(self.err.getvalue(), "")
        pyuser = re.compile(r"python\s+2.5.2\s+8.5a4")
        lines = self.out.getvalue().split("\n")
        self.assertEqual(len(lines), 2)
        self.assertTrue([l for l in lines if pyuser.match(l)])

        self._resetOut()
        cmd = eups.cmd.EupsCmd(args="uses python".split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEqual(self.err.getvalue(), "")
        lines = self.out.getvalue().split("\n")
        self.assertEqual(len(lines), 1)

        self._resetOut()
        cmd = eups.cmd.EupsCmd(args="uses".split(), toolname=prog)
        self.assertNotEqual(cmd.run(), 0)
        self.assertTrue(
            self.err.getvalue().find("Please specify a product name"))
コード例 #3
0
    def testFlavor(self):
        cmd = eups.cmd.EupsCmd(args="flavor".split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEquals(self.err.getvalue(), "")
        self.assertTrue(len(self.out.getvalue()) > 0)

        self._resetOut()
        cmd = eups.cmd.EupsCmd(args="flavor -f Linux".split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEquals(self.err.getvalue(), "")
        self.assertEquals(self.out.getvalue(), "Linux")
コード例 #4
0
ファイル: testCmd.py プロジェクト: mwittgen/eups
    def testFlavor(self):
        cmd = eups.cmd.EupsCmd(args="flavor".split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEqual(self.err.getvalue(), "")
        self.assertTrue(len(self.out.getvalue()) > 0)

        self._resetOut()
        cmd = eups.cmd.EupsCmd(args="flavor -f Linux".split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEqual(self.err.getvalue(), "")
        self.assertEqual(self.out.getvalue(), "Linux")
コード例 #5
0
    def testHelp(self):
        cmd = eups.cmd.EupsCmd(args="-h".split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEquals(self.out.getvalue(), "")
        self.assert_(re.match(r'^[Uu]sage: ' + prog, self.err.getvalue()),
                     "Output starts with: '%s....'" % self.err.getvalue()[:16])

        self._resetOut()
        cmd = eups.cmd.EupsCmd(args="flavor -h".split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEquals(self.out.getvalue(), "")
        self.assert_(
            re.match(r'^[Uu]sage: ' + prog + ' flavor', self.err.getvalue()),
            "Output starts with: '%s....'" % self.err.getvalue()[:16])
コード例 #6
0
    def testHelp(self):
        cmd = eups.cmd.EupsCmd(args="-h".split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEquals(self.out.getvalue(), "")
        self.assertTrue(re.match(r'^[Uu]sage: '+prog, self.err.getvalue()),
                     msg="Output starts with: '%s....'" % self.err.getvalue()[:16])

        self._resetOut()
        cmd = eups.cmd.EupsCmd(args="flavor -h".split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEquals(self.out.getvalue(), "")
        self.assertTrue(re.match(r'^[Uu]sage: '+prog+' flavor',
                              self.err.getvalue()),
                     msg="Output starts with: '%s....'" % self.err.getvalue()[:16])
コード例 #7
0
ファイル: testCmd.py プロジェクト: mwittgen/eups
 def testVersion(self):
     cmd = eups.cmd.EupsCmd(args="-V".split(), toolname=prog)
     self.assertEqual(cmd.run(), 0)
     self.assertEqual(self.err.getvalue(), "")
     self.assertTrue(self.out.getvalue().startswith("EUPS Version:"),
                     msg="Output starts with: '%s....'" %
                     self.out.getvalue()[:16])
コード例 #8
0
    def testDistribList(self):
        cmd = eups.cmd.EupsCmd(args="distrib list".split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEquals(self.err.getvalue(), "")
        out = self.out.getvalue()
        self.assertTrue(len(out) > 0)
        self.assertTrue(out.find("No matching products") < 0)
        self.assertTrue(out.find("doxygen") >= 0)

        self._resetOut()
        cmd = eups.cmd.EupsCmd(args="distrib list -f Linux".split(),
                               toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEquals(self.err.getvalue(), "")
        out = self.out.getvalue()
        self.assertTrue(len(out) > 0)
        self.assertTrue(out.find("No matching products") >= 0)
コード例 #9
0
    def testNoTable(self):
        pdir = os.path.join(testEupsStack, "Linux", "newprod")
        pdir11 = os.path.join(pdir, "1.1")

        cmdargs = ["-r", pdir11, "newprod"]
        hooks.config.Eups.defaultTags = dict(pre=[], post=[]) # disable any defined in the startup.py file
        cmd = eups.setupcmd.EupsSetup(args=cmdargs, toolname=prog)
        self.assertEqual(cmd.run(), 0)
コード例 #10
0
ファイル: testCmd.py プロジェクト: mwittgen/eups
    def testDistribList(self):
        cmd = eups.cmd.EupsCmd(args="distrib list".split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEqual(self.err.getvalue(), "")
        out = self.out.getvalue()
        self.assertTrue(len(out) > 0)
        self.assertTrue(out.find("No matching products") < 0)
        self.assertTrue(out.find("doxygen") >= 0)

        self._resetOut()
        cmd = eups.cmd.EupsCmd(args="distrib list -f Linux".split(),
                               toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEqual(self.err.getvalue(), "")
        out = self.out.getvalue()
        self.assertTrue(len(out) > 0)
        self.assertTrue(out.find("No matching products") >= 0)
コード例 #11
0
ファイル: testServerLSST.py プロジェクト: mwittgen/eups
    def testInstall(self):
        prod = Eups().findProduct("lssteups")
        self.assert_(prod is None)

        cmd = "distrib install lssteups 1.1 -q -r " + self.lsstroot
        cmd = eups.cmd.EupsCmd(args=cmd.split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)

        prod = Eups().findProduct("lssteups")
        self.assert_(prod is not None)
        self.assertEqual(prod.version, "1.1")
        self.assert_(prod.dir.endswith("lssteups/1.1"))
        self.assert_(os.path.exists(prod.dir))
        pdir = prod.dir

        cmd = "remove lssteups 1.1"
        cmd = eups.cmd.EupsCmd(args=cmd.split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)

        prod = Eups().findProduct("lssteups")
        self.assert_(prod is None)

        cmd = "distrib install lssteups 1.1 --noclean -q -r " + self.lsstroot
        cmd = eups.cmd.EupsCmd(args=cmd.split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)

        prod = Eups().findProduct("lssteups")
        self.assert_(prod is not None)
        bdir = os.path.join(testEupsStack, "EupsBuildDir", self.flavor,
                            "lssteups-1.1")
        self.assert_(os.path.exists(bdir), "%s does not exist" % bdir)

        cmd = "distrib clean lssteups 1.1 -r " + self.lsstroot
        cmd = eups.cmd.EupsCmd(args=cmd.split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assert_(not os.path.exists(bdir), "%s still exists" % bdir)

        cmd = "distrib clean lssteups 1.1 -q -R -r " + self.lsstroot
        cmd = eups.cmd.EupsCmd(args=cmd.split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assert_(not os.path.exists(bdir), "%s still exists" % bdir)

        prod = Eups().findProduct("lssteups")
        self.assert_(prod is None)
        self.assert_(not os.path.exists(pdir))
コード例 #12
0
ファイル: testCmd.py プロジェクト: mwittgen/eups
    def testNoTable(self):
        pdir = os.path.join(testEupsStack, "Linux", "newprod")
        pdir11 = os.path.join(pdir, "1.1")

        cmdargs = ["-r", pdir11, "newprod"]
        hooks.config.Eups.defaultTags = dict(
            pre=[], post=[])  # disable any defined in the startup.py file
        cmd = eups.setupcmd.EupsSetup(args=cmdargs, toolname=prog)
        self.assertEqual(cmd.run(), 0)
コード例 #13
0
ファイル: testServerLSST.py プロジェクト: CraigLoomis/eups
    def testInstall(self):
        prod = Eups().findProduct("lssteups")
        self.assert_(prod is None)

        cmd = "distrib install lssteups 1.1 -q -r " + self.lsstroot
        cmd = eups.cmd.EupsCmd(args=cmd.split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)

        prod = Eups().findProduct("lssteups")
        self.assert_(prod is not None)
        self.assertEquals(prod.version, "1.1")
        self.assert_(prod.dir.endswith("lssteups/1.1"))
        self.assert_(os.path.exists(prod.dir))
        pdir = prod.dir

        cmd = "remove lssteups 1.1"
        cmd = eups.cmd.EupsCmd(args=cmd.split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)

        prod = Eups().findProduct("lssteups")
        self.assert_(prod is None)
        
        cmd = "distrib install lssteups 1.1 --noclean -q -r " + self.lsstroot
        cmd = eups.cmd.EupsCmd(args=cmd.split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)

        prod = Eups().findProduct("lssteups")
        self.assert_(prod is not None)
        bdir = os.path.join(testEupsStack,"EupsBuildDir",self.flavor,"lssteups-1.1")
        self.assert_(os.path.exists(bdir), "%s does not exist" % bdir)

        cmd = "distrib clean lssteups 1.1 -r " + self.lsstroot
        cmd = eups.cmd.EupsCmd(args=cmd.split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assert_(not os.path.exists(bdir), "%s still exists" % bdir)

        cmd = "distrib clean lssteups 1.1 -q -R -r " + self.lsstroot
        cmd = eups.cmd.EupsCmd(args=cmd.split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assert_(not os.path.exists(bdir), "%s still exists" % bdir)

        prod = Eups().findProduct("lssteups")
        self.assert_(prod is None)
        self.assert_(not os.path.exists(pdir))
コード例 #14
0
ファイル: testCmd.py プロジェクト: CraigLoomis/eups
    def testRemove(self):
        pdir = os.path.join(testEupsStack, "Linux", "newprod")
        pdir10 = os.path.join(pdir, "1.0")
        pdir20 = os.path.join(pdir, "2.0")
        shutil.copytree(pdir10, pdir20)
        self.assert_(os.path.isdir(pdir20))

        eups.Eups().declare("newprod", "2.0", pdir20)
        self.assert_(os.path.exists(os.path.join(self.dbpath,"newprod","2.0.version")))
        
        cmd = eups.cmd.EupsCmd(args="remove newprod 2.0".split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEquals(self.err.getvalue(), "")
        self.assertEquals(self.out.getvalue(), "")
        prod = eups.Eups().findProduct("newprod", "2.0")
        self.assert_(prod is None)
        self.assert_(not os.path.isdir(pdir20))
コード例 #15
0
    def testRemove(self):
        pdir = os.path.join(testEupsStack, "Linux", "newprod")
        pdir10 = os.path.join(pdir, "1.0")
        pdir20 = os.path.join(pdir, "2.0")
        shutil.copytree(pdir10, pdir20)
        self.assert_(os.path.isdir(pdir20))

        eups.Eups().declare("newprod", "2.0", pdir20)
        self.assert_(
            os.path.exists(os.path.join(self.dbpath, "newprod",
                                        "2.0.version")))

        cmd = eups.cmd.EupsCmd(args="remove newprod 2.0".split(),
                               toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEquals(self.err.getvalue(), "")
        self.assertEquals(self.out.getvalue(), "")
        prod = eups.Eups().findProduct("newprod", "2.0")
        self.assert_(prod is None)
        self.assert_(not os.path.isdir(pdir20))
コード例 #16
0
ファイル: testCmd.py プロジェクト: mwittgen/eups
 def testPath2(self):
     cmd = eups.cmd.EupsCmd(args="pkgroot".split(), toolname=prog)
     self.assertEqual(cmd.run(), 0)
     self.assertEqual(self.err.getvalue(), "")
     self.assertEqual(self.out.getvalue(), os.environ["EUPS_PKGROOT"])
コード例 #17
0
    def testDeclare(self):
        pdir = os.path.join(testEupsStack, "Linux", "newprod")
        pdir10 = os.path.join(pdir, "1.0")
        table = os.path.join(pdir10, "ups", "newprod.table")
        newprod = os.path.join(self.dbpath,"newprod")

        cmdargs = ["declare", "newprod", "1.0", "-r", pdir10, "-m", table]
        cmd = eups.cmd.EupsCmd(args=cmdargs, toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEquals(self.err.getvalue(), "")
        self.assertEquals(self.out.getvalue(), "")
        
        myeups = eups.Eups()
        prod = myeups.findProduct("newprod")
        self.assertIsNotNone(prod, msg="Failed to declare product")
        self.assertEquals(prod.name,    "newprod")
        self.assertEquals(prod.version, "1.0")
        self.assertEquals(len(prod.tags), 1)   # current is tagged by default
        self.assertIn("current", prod.tags)
        self.assertTrue(os.path.isdir(newprod))

        # make sure user cannot set a server tag
        self._resetOut()
        cmd = "declare newprod 1.0 -t latest"
        cmd = eups.cmd.EupsCmd(args=cmd.split(), toolname=prog)
        self.assertNotEqual(cmd.run(), 0)
        self.assertNotEqual(self.err.getvalue(), "")
        self.assertEquals(self.out.getvalue(), "")
        
        self._resetOut()
        cmd = "declare -F newprod 1.0 -t current"
        cmd = eups.cmd.EupsCmd(args=cmd.split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEquals(self.err.getvalue(), "")
        self.assertEquals(self.out.getvalue(), "")
        
        myeups = eups.Eups()
        prod = myeups.findProduct("newprod")
        self.assertIsNotNone(prod, msg="product went missing after tagging")
        self.assertIn("current", prod.tags)
        
        self._resetOut()
        cmd = "undeclare newprod 1.0"
        cmd = eups.cmd.EupsCmd(args=cmd.split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEquals(self.err.getvalue(), "")
        self.assertEquals(self.out.getvalue(), "")

        myeups = eups.Eups()
        prod = myeups.findProduct("newprod")
        self.assertIsNone(prod, "Failed to undeclare product")
        self.assertFalse(os.path.isdir(newprod))

        self._resetOut()
        cmdargs = ["declare", "newprod", "1.0", "-F", "-r", pdir10, "-m", table, "-t", "current"]
        cmd = eups.cmd.EupsCmd(args=cmdargs, toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEquals(self.err.getvalue(), "")
        self.assertEquals(self.out.getvalue(), "")
        
        myeups = eups.Eups()
        prod = myeups.findProduct("newprod")
        self.assertIsNotNone(prod, msg="Failed to declare product")
        self.assertEquals(prod.name,    "newprod")
        self.assertEquals(prod.version, "1.0")
        self.assertEquals(len(prod.tags), 1)
        self.assertIn("current", prod.tags)
        self.assertTrue(os.path.isdir(newprod))
        
        self._resetOut()
        cmd = "undeclare newprod 1.0"
        cmd = eups.cmd.EupsCmd(args=cmd.split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEquals(self.err.getvalue(), "")
        self.assertEquals(self.out.getvalue(), "")

        myeups = eups.Eups()
        prod = myeups.findProduct("newprod", Tag("current"))
        self.assertIsNone(prod, msg="Failed to undeclare product")
コード例 #18
0
ファイル: testCmd.py プロジェクト: mwittgen/eups
 def testFlags(self):
     cmd = eups.cmd.EupsCmd(args="flags".split(), toolname=prog)
     self.assertEqual(cmd.run(), 0)
     self.assertEqual(self.err.getvalue(), "")
     self.assertEqual(self.out.getvalue(), "You have no EUPS_FLAGS set")
コード例 #19
0
    def testList(self):
        outall = """
cfitsio               3006.2     \tcurrent
doxygen               1.5.7.1    \tcurrent
eigen                 2.0.0      \tcurrent
mpich2                1.0.5p4    \tcurrent
python                2.5.2      \tcurrent
python                2.6        """ """
tcltk                 8.5a4      \tcurrent
""".strip()
        outpy = """
   2.5.2      \tcurrent
   2.6
""".strip()
        outcurr = "\n".join(l for l in outpy.split("\n") if l.find('current') >= 0).strip()
        outnews = "\n".join(l for l in outpy.split("\n") if l.find('2.6') >= 0).strip()

        cmd = eups.cmd.EupsCmd(args="list".split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEquals(self.err.getvalue(), "")
        self.assertEquals(self.out.getvalue(), outall)
                          
        self._resetOut()
        cmd = eups.cmd.EupsCmd(args="list python".split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEquals(self.err.getvalue(), "")
        self.assertEquals(self.out.getvalue(), outpy)

        self._resetOut()
        cmd = eups.cmd.EupsCmd(args="list -t current python".split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEquals(self.err.getvalue(), "")
        self.assertEquals(self.out.getvalue(), outcurr)

        self._resetOut()
        cmd = eups.cmd.EupsCmd(args="list -t latest python".split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEquals(self.err.getvalue(), "")
        self.assertEquals(self.out.getvalue(), outnews)

        # test the printing of the helpful message
        self._resetOut()
        cmd = eups.cmd.EupsCmd(args="list goober".split(), toolname=prog)
        self.assertEqual(cmd.run(), 1)
        self.assertEquals(self.out.getvalue(), "")
        self.assertEquals(self.err.getvalue(), prog + ' list: Unable to find product goober\n')

        self._resetOut()
        cmd = eups.cmd.EupsCmd(args="list distrib goober".split(), toolname=prog)
        self.assertEqual(cmd.run(), 1)
        self.assertEquals(self.out.getvalue(), "")
        self.assertEquals(self.err.getvalue(), prog + ' list: Unable to find product distrib goober; Maybe you meant "eups distrib list"?\n')

        self._resetOut()
        cmd = eups.cmd.EupsCmd(args="list -q goober".split(), toolname=prog)
        self.assertEqual(cmd.run(), 1)
        self.assertEquals(self.out.getvalue(), "")
        self.assertEquals(self.err.getvalue(), "")

        # test listing of LOCAL products
        self._resetOut()
        productRoot = os.path.join(testEupsStack, "Linux",
                                   "python", "2.5.2")
        eups.setup("python", productRoot=productRoot)
        outwlocal = """
   2.5.2      \tcurrent
   2.6        """ """
   LOCAL:%s \tsetup
""".strip() % encodePath(productRoot)
        cmd = eups.cmd.EupsCmd(args="list python".split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEquals(self.out.getvalue(), outwlocal)
        self.assertEquals(self.err.getvalue(), "")
        eups.unsetup("python")
コード例 #20
0
 def testFlags(self):
     cmd = eups.cmd.EupsCmd(args="flags".split(), toolname=prog)
     self.assertEqual(cmd.run(), 0)
     self.assertEquals(self.err.getvalue(), "")
     self.assertEquals(self.out.getvalue(), "You have no EUPS_FLAGS set")
コード例 #21
0
ファイル: eups_impl.py プロジェクト: CraigLoomis/eups
verbosity = cmd.opts.verbose
if cmd.opts.quiet:
    verbosity = -1
eups.hooks.loadCustomization(verbosity, path=eups.Eups.setEupsPath(path=cmd.opts.path, dbz=cmd.opts.dbz))

# run the command
try:
    # N.b. calling sys.exit here raises SystemExit which is caught...
    if eups.Eups.profile:
        try:
            import cProfile as profile
        except ImportError:
            import profile
        profile.run("status = cmd.run()", eups.Eups.profile)
        if verbosity > 0:
            print >> utils.stdinfo, \
                "You can use \"python -m pstats %s\" to examine this profile" % eups.Eups.profile
    else:
        status = cmd.run() 
except Exception, e:
    if eups.Eups.allowRaise:
        raise

    cmd.err(str(e))
    if hasattr(e, "status"):
        status = e.status
    else:
        status = 9

sys.exit(status)
コード例 #22
0
    def testDeclare(self):
        pdir = os.path.join(testEupsStack, "Linux", "newprod")
        pdir10 = os.path.join(pdir, "1.0")
        pdir11 = os.path.join(pdir, "1.1")
        table = os.path.join(pdir10, "ups", "newprod.table")
        newprod = os.path.join(self.dbpath, "newprod")

        cmd = "declare newprod 1.0 -r %s -m %s" % (pdir10, table)
        cmd = eups.cmd.EupsCmd(args=cmd.split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEquals(self.err.getvalue(), "")
        self.assertEquals(self.out.getvalue(), "")

        myeups = eups.Eups()
        prod = myeups.findProduct("newprod")
        self.assert_(prod is not None, "Failed to declare product")
        self.assertEquals(prod.name, "newprod")
        self.assertEquals(prod.version, "1.0")
        self.assertEquals(len(prod.tags), 1)  # current is tagged by default
        self.assert_("current" in prod.tags)
        self.assert_(os.path.isdir(newprod))

        # make sure user cannot set a server tag
        self._resetOut()
        cmd = "declare newprod 1.0 -t newest"
        cmd = eups.cmd.EupsCmd(args=cmd.split(), toolname=prog)
        self.assertNotEqual(cmd.run(), 0)
        self.assertNotEqual(self.err.getvalue(), "")
        self.assertEquals(self.out.getvalue(), "")

        self._resetOut()
        cmd = "declare -F newprod 1.0 -t current"
        cmd = eups.cmd.EupsCmd(args=cmd.split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEquals(self.err.getvalue(), "")
        self.assertEquals(self.out.getvalue(), "")

        myeups = eups.Eups()
        prod = myeups.findProduct("newprod")
        self.assert_(prod is not None, "product went missing after tagging")
        self.assert_("current" in prod.tags)

        self._resetOut()
        cmd = "undeclare newprod 1.0"
        cmd = eups.cmd.EupsCmd(args=cmd.split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEquals(self.err.getvalue(), "")
        self.assertEquals(self.out.getvalue(), "")

        myeups = eups.Eups()
        prod = myeups.findProduct("newprod")
        self.assert_(prod is None, "Failed to undeclare product")
        self.assert_(not os.path.isdir(newprod))

        self._resetOut()
        cmd = "declare newprod 1.0 -F -r %s -m %s -t current" % (pdir10, table)
        cmd = eups.cmd.EupsCmd(args=cmd.split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEquals(self.err.getvalue(), "")
        self.assertEquals(self.out.getvalue(), "")

        myeups = eups.Eups()
        prod = myeups.findProduct("newprod")
        self.assert_(prod is not None, "Failed to declare product")
        self.assertEquals(prod.name, "newprod")
        self.assertEquals(prod.version, "1.0")
        self.assertEquals(len(prod.tags), 1)
        self.assert_("current" in prod.tags)
        self.assert_(os.path.isdir(newprod))

        self._resetOut()
        cmd = "undeclare newprod 1.0"
        cmd = eups.cmd.EupsCmd(args=cmd.split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEquals(self.err.getvalue(), "")
        self.assertEquals(self.out.getvalue(), "")

        myeups = eups.Eups()
        prod = myeups.findProduct("newprod", Tag("current"))
        self.assert_(prod is None, "Failed to undeclare product")
コード例 #23
0
ファイル: testCmd.py プロジェクト: mwittgen/eups
    def testList(self):
        outall = """
cfitsio               3006.2     \tcurrent
doxygen               1.5.7.1    \tcurrent
eigen                 2.0.0      \tcurrent
mpich2                1.0.5p4    \tcurrent
python                2.5.2      \tcurrent
python                2.6        """ """
tcltk                 8.5a4      \tcurrent
""".strip()
        outpy = """
   2.5.2      \tcurrent
   2.6
""".strip()
        outcurr = "\n".join(l for l in outpy.split("\n")
                            if l.find('current') >= 0).strip()
        outnews = "\n".join(l for l in outpy.split("\n")
                            if l.find('2.6') >= 0).strip()

        cmd = eups.cmd.EupsCmd(args="list".split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEqual(self.err.getvalue(), "")
        self.assertEqual(self.out.getvalue(), outall)

        self._resetOut()
        cmd = eups.cmd.EupsCmd(args="list python".split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEqual(self.err.getvalue(), "")
        self.assertEqual(self.out.getvalue(), outpy)

        self._resetOut()
        cmd = eups.cmd.EupsCmd(args="list -t current python".split(),
                               toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEqual(self.err.getvalue(), "")
        self.assertEqual(self.out.getvalue(), outcurr)

        self._resetOut()
        cmd = eups.cmd.EupsCmd(args="list -t latest python".split(),
                               toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEqual(self.err.getvalue(), "")
        self.assertEqual(self.out.getvalue(), outnews)

        # test the printing of the helpful message
        self._resetOut()
        cmd = eups.cmd.EupsCmd(args="list goober".split(), toolname=prog)
        try:
            self.assertEqual(cmd.run(), 1)
        except ProductNotFound as e:
            self.assertEqual(str(e), 'Unable to find product goober')

        self._resetOut()
        cmd = eups.cmd.EupsCmd(args="list distrib goober".split(),
                               toolname=prog)
        try:
            self.assertEqual(cmd.run(), 1)
        except ProductNotFound as e:
            self.assertEqual(
                str(e),
                'Unable to find product distrib goober; Maybe you meant "eups distrib list"?'
            )

        # test listing of LOCAL products
        self._resetOut()
        productRoot = os.path.join(testEupsStack, "Linux", "python", "2.5.2")
        eups.setup("python", productRoot=productRoot)
        outwlocal = """
   2.5.2      \tcurrent
   2.6        """ """
   LOCAL:%s \tsetup
""".strip() % encodePath(productRoot)
        cmd = eups.cmd.EupsCmd(args="list python".split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEqual(self.out.getvalue(), outwlocal)
        self.assertEqual(self.err.getvalue(), "")
        eups.unsetup("python")
コード例 #24
0
ファイル: testCmd.py プロジェクト: mwittgen/eups
    def testDeclare(self):
        pdir = os.path.join(testEupsStack, "Linux", "newprod")
        pdir10 = os.path.join(pdir, "1.0")
        table = os.path.join(pdir10, "ups", "newprod.table")
        newprod = os.path.join(self.dbpath, "newprod")

        cmdargs = ["declare", "newprod", "1.0", "-r", pdir10, "-m", table]
        cmd = eups.cmd.EupsCmd(args=cmdargs, toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEqual(self.err.getvalue(), "")
        self.assertEqual(self.out.getvalue(), "")

        myeups = eups.Eups()
        prod = myeups.findProduct("newprod")
        self.assertIsNotNone(prod, msg="Failed to declare product")
        self.assertEqual(prod.name, "newprod")
        self.assertEqual(prod.version, "1.0")
        self.assertEqual(len(prod.tags), 1)  # current is tagged by default
        self.assertIn("current", prod.tags)
        self.assertTrue(os.path.isdir(newprod))

        # make sure user cannot set a server tag
        self._resetOut()
        cmd = "declare newprod 1.0 -t latest"
        cmd = eups.cmd.EupsCmd(args=cmd.split(), toolname=prog)
        self.assertNotEqual(cmd.run(), 0)
        self.assertNotEqual(self.err.getvalue(), "")
        self.assertEqual(self.out.getvalue(), "")

        self._resetOut()
        cmd = "declare -F newprod 1.0 -t current"
        cmd = eups.cmd.EupsCmd(args=cmd.split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEqual(self.err.getvalue(), "")
        self.assertEqual(self.out.getvalue(), "")

        myeups = eups.Eups()
        prod = myeups.findProduct("newprod")
        self.assertIsNotNone(prod, msg="product went missing after tagging")
        self.assertIn("current", prod.tags)

        self._resetOut()
        cmd = "undeclare newprod 1.0"
        cmd = eups.cmd.EupsCmd(args=cmd.split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEqual(self.err.getvalue(), "")
        self.assertEqual(self.out.getvalue(), "")

        myeups = eups.Eups()
        prod = myeups.findProduct("newprod")
        self.assertIsNone(prod, "Failed to undeclare product")
        self.assertFalse(os.path.isdir(newprod))

        self._resetOut()
        cmdargs = [
            "declare", "newprod", "1.0", "-F", "-r", pdir10, "-m", table, "-t",
            "current"
        ]
        cmd = eups.cmd.EupsCmd(args=cmdargs, toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEqual(self.err.getvalue(), "")
        self.assertEqual(self.out.getvalue(), "")

        myeups = eups.Eups()
        prod = myeups.findProduct("newprod")
        self.assertIsNotNone(prod, msg="Failed to declare product")
        self.assertEqual(prod.name, "newprod")
        self.assertEqual(prod.version, "1.0")
        self.assertEqual(len(prod.tags), 1)
        self.assertIn("current", prod.tags)
        self.assertTrue(os.path.isdir(newprod))

        self._resetOut()
        cmd = "undeclare newprod 1.0"
        cmd = eups.cmd.EupsCmd(args=cmd.split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEqual(self.err.getvalue(), "")
        self.assertEqual(self.out.getvalue(), "")

        myeups = eups.Eups()
        prod = myeups.findProduct("newprod", Tag("current"))
        self.assertIsNone(prod, msg="Failed to undeclare product")
コード例 #25
0
ファイル: testCmd.py プロジェクト: mwittgen/eups
 def testQuiet(self):
     cmd = eups.cmd.EupsCmd(args="-q".split(), toolname=prog)
     self.assertNotEqual(cmd.run(), 0)
     self.assertEqual(self.err.getvalue(), "")
コード例 #26
0
ファイル: testCmd.py プロジェクト: mwittgen/eups
 def testPath(self):
     cmd = eups.cmd.EupsCmd(args="path".split(), toolname=prog)
     self.assertEqual(cmd.run(), 0)
     self.assertEqual(self.err.getvalue(), "")
     self.assertEqual(self.out.getvalue(), testEupsStack)
コード例 #27
0
 def testPath(self):
     cmd = eups.cmd.EupsCmd(args="path".split(), toolname=prog)
     self.assertEqual(cmd.run(), 0)
     self.assertEquals(self.err.getvalue(), "")
     self.assertEquals(self.out.getvalue(), testEupsStack)
コード例 #28
0
 def testQuiet(self):
     cmd = eups.cmd.EupsCmd(args="-q".split(), toolname=prog)
     self.assertNotEqual(cmd.run(), 0)
     self.assertEquals(self.err.getvalue(), "")
コード例 #29
0
 def testPath2(self):
     cmd = eups.cmd.EupsCmd(args="pkgroot".split(), toolname=prog)
     self.assertEqual(cmd.run(), 0)
     self.assertEquals(self.err.getvalue(), "")
     self.assertEquals(self.out.getvalue(), os.environ["EUPS_PKGROOT"])
コード例 #30
0
 def testVersion(self):
     cmd = eups.cmd.EupsCmd(args="-V".split(), toolname=prog)
     self.assertEqual(cmd.run(), 0)
     self.assertEquals(self.err.getvalue(), "")
     self.assertTrue(self.out.getvalue().startswith("EUPS Version:"),
                  msg="Output starts with: '%s....'" % self.out.getvalue()[:16])
コード例 #31
0
ファイル: testCmd.py プロジェクト: mwittgen/eups
 def testDistrib(self):
     cmd = eups.cmd.EupsCmd(args="distrib".split(), toolname=prog)
     self.assertNotEqual(cmd.run(), 0)
     self.assertNotEquals(self.err.getvalue(), "")
コード例 #32
0
ファイル: testCmd.py プロジェクト: CraigLoomis/eups
    def testDeclare(self):
        pdir = os.path.join(testEupsStack, "Linux", "newprod")
        pdir10 = os.path.join(pdir, "1.0")
        pdir11 = os.path.join(pdir, "1.1")
        table = os.path.join(pdir10, "ups", "newprod.table")
        newprod = os.path.join(self.dbpath,"newprod")

        cmd = "declare newprod 1.0 -r %s -m %s" % (pdir10, table)
        cmd = eups.cmd.EupsCmd(args=cmd.split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEquals(self.err.getvalue(), "")
        self.assertEquals(self.out.getvalue(), "")
        
        myeups = eups.Eups()
        prod = myeups.findProduct("newprod")
        self.assert_(prod is not None, "Failed to declare product")
        self.assertEquals(prod.name,    "newprod")
        self.assertEquals(prod.version, "1.0")
        self.assertEquals(len(prod.tags), 1)   # current is tagged by default
        self.assert_("current" in prod.tags)
        self.assert_(os.path.isdir(newprod))

        # make sure user cannot set a server tag
        self._resetOut()
        cmd = "declare newprod 1.0 -t newest"
        cmd = eups.cmd.EupsCmd(args=cmd.split(), toolname=prog)
        self.assertNotEqual(cmd.run(), 0)
        self.assertNotEqual(self.err.getvalue(), "")
        self.assertEquals(self.out.getvalue(), "")
        
        self._resetOut()
        cmd = "declare -F newprod 1.0 -t current"
        cmd = eups.cmd.EupsCmd(args=cmd.split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEquals(self.err.getvalue(), "")
        self.assertEquals(self.out.getvalue(), "")
        
        myeups = eups.Eups()
        prod = myeups.findProduct("newprod")
        self.assert_(prod is not None, "product went missing after tagging")
        self.assert_("current" in prod.tags)
        
        self._resetOut()
        cmd = "undeclare newprod 1.0"
        cmd = eups.cmd.EupsCmd(args=cmd.split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEquals(self.err.getvalue(), "")
        self.assertEquals(self.out.getvalue(), "")

        myeups = eups.Eups()
        prod = myeups.findProduct("newprod")
        self.assert_(prod is None, "Failed to undeclare product")
        self.assert_(not os.path.isdir(newprod))

        self._resetOut()
        cmd = "declare newprod 1.0 -F -r %s -m %s -t current" % (pdir10, table)
        cmd = eups.cmd.EupsCmd(args=cmd.split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEquals(self.err.getvalue(), "")
        self.assertEquals(self.out.getvalue(), "")
        
        myeups = eups.Eups()
        prod = myeups.findProduct("newprod")
        self.assert_(prod is not None, "Failed to declare product")
        self.assertEquals(prod.name,    "newprod")
        self.assertEquals(prod.version, "1.0")
        self.assertEquals(len(prod.tags), 1)
        self.assert_("current" in prod.tags)
        self.assert_(os.path.isdir(newprod))
        
        self._resetOut()
        cmd = "undeclare newprod 1.0"
        cmd = eups.cmd.EupsCmd(args=cmd.split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEquals(self.err.getvalue(), "")
        self.assertEquals(self.out.getvalue(), "")

        myeups = eups.Eups()
        prod = myeups.findProduct("newprod", Tag("current"))
        self.assert_(prod is None, "Failed to undeclare product")
コード例 #33
0
    def testList(self):
        outall = """
cfitsio               3006.2     \tcurrent
doxygen               1.5.7.1    \tcurrent
eigen                 2.0.0      \tcurrent
mpich2                1.0.5p4    \tcurrent
python                2.5.2      \tcurrent
python                2.6        
tcltk                 8.5a4      \tcurrent
""".strip()
        outpy = """
   2.5.2      \tcurrent
   2.6        
""".strip()
        outcurr = "\n".join(
            filter(lambda l: l.find('current') >= 0,
                   outpy.split("\n"))).strip()
        outnews = "\n".join(
            filter(lambda l: l.find('2.6') >= 0, outpy.split("\n"))).strip()

        cmd = eups.cmd.EupsCmd(args="list".split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEquals(self.err.getvalue(), "")
        self.assertEquals(self.out.getvalue(), outall)

        self._resetOut()
        cmd = eups.cmd.EupsCmd(args="list python".split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEquals(self.err.getvalue(), "")
        self.assertEquals(self.out.getvalue(), outpy)

        self._resetOut()
        cmd = eups.cmd.EupsCmd(args="list -t current python".split(),
                               toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEquals(self.err.getvalue(), "")
        self.assertEquals(self.out.getvalue(), outcurr)

        self._resetOut()
        cmd = eups.cmd.EupsCmd(args="list -t newest python".split(),
                               toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEquals(self.err.getvalue(), "")
        self.assertEquals(self.out.getvalue(), outnews)

        # test the printing of the helpful message
        self._resetOut()
        cmd = eups.cmd.EupsCmd(args="list goober".split(), toolname=prog)
        self.assertEqual(cmd.run(), 1)
        self.assertEquals(self.out.getvalue(), "")
        self.assertEquals(self.err.getvalue(),
                          prog + ' list: Unable to find product goober\n')

        self._resetOut()
        cmd = eups.cmd.EupsCmd(args="list distrib goober".split(),
                               toolname=prog)
        self.assertEqual(cmd.run(), 1)
        self.assertEquals(self.out.getvalue(), "")
        self.assertEquals(
            self.err.getvalue(), prog +
            ' list: Unable to find product distrib goober; Maybe you meant "eups distrib list"?\n'
        )

        self._resetOut()
        cmd = eups.cmd.EupsCmd(args="list -q goober".split(), toolname=prog)
        self.assertEqual(cmd.run(), 1)
        self.assertEquals(self.out.getvalue(), "")
        self.assertEquals(self.err.getvalue(), "")

        # test listing of LOCAL products
        self._resetOut()
        eups.setup("python",
                   productRoot=os.path.join(testEupsStack, "Linux", "python",
                                            "2.5.2"))
        outwlocal = """
   2.5.2      \tcurrent
   2.6        
   LOCAL:%s/Linux/python/2.5.2 \tsetup
""".strip() % testEupsStack
        cmd = eups.cmd.EupsCmd(args="list python".split(), toolname=prog)
        self.assertEqual(cmd.run(), 0)
        self.assertEquals(self.out.getvalue(), outwlocal)
        self.assertEquals(self.err.getvalue(), "")
        eups.unsetup("python")