class EupsVersionTestCase(unittest.TestCase): """ Check that we can check the eups version """ def setUp(self): os.environ["EUPS_PATH"] = testEupsStack self.tablefile = os.path.join(testEupsStack, "eupsVersion.table") self.table = Table(self.tablefile) self.eups = Eups() def testVersionCheck(self): actions = self.table.actions("DarwinX86") for action in actions: action.execute(self.eups, 1) def testVersionCheck(self): actions = self.table.actions("DarwinX86") assert actions[0].cmd == "setupRequired" and actions[0].args[ 0] == 'eups', "First action sets up eups" assert " ".join(actions[0].args[1:]) == '[> 2.0.2]' actions[0].args[1:] = "[> 1000]".split() for action in actions: try: action.execute(self.eups, 1) except RuntimeError as e: self.assertTrue("doesn't satisfy condition" in str(e))
class EupsVersionTestCase(unittest.TestCase): """ Check that we can check the eups version """ def setUp(self): os.environ["EUPS_PATH"] = testEupsStack self.tablefile = os.path.join(testEupsStack, "eupsVersion.table") self.table = Table(self.tablefile) self.eups = Eups() def testVersionCheck(self): actions = self.table.actions("DarwinX86") for action in actions: action.execute(self.eups, 1) def testVersionCheck(self): actions = self.table.actions("DarwinX86") assert actions[0].cmd == "setupRequired" and actions[0].args[0] == 'eups', "First action sets up eups" assert " ".join(actions[0].args[1:]) == '[> 2.0.2]' actions[0].args[1:] = "[> 1000]".split() for action in actions: try: action.execute(self.eups, 1) except RuntimeError as e: self.assertTrue("doesn't satisfy condition" in str(e))
def setUp(self): self.environ0 = os.environ.copy() os.environ["EUPS_PATH"] = testEupsStack self.tablefile = os.path.join(testEupsStack, "tablesyntax.table") self.table = Table(self.tablefile) self.eups = Eups(flavor="Linux") for k in [ "EIGEN_DIR", ]: # we're going to assert that it isn't set try: del os.environ[k] except KeyError: pass
class TableTestCase1(unittest.TestCase): """test the Table class""" def setUp(self): os.environ["EUPS_PATH"] = testEupsStack self.tablefile = os.path.join(testEupsStack, "mwi.table") self.table = Table(self.tablefile) def testInit(self): self.assertEqual(self.table.file, self.tablefile) # Note: we add one to account for the default product self.assertEqual(len(self.table.actions("Darwin")), 14) self.assertEqual(len(self.table.actions("Linux")), 13) self.assertEqual(len(self.table.actions("Linux+2.1.2")), 14) self.assertEqual(len(self.table.actions("DarwinX86")), 14)
def setUp(self): self.environ0 = os.environ.copy() os.environ["EUPS_PATH"] = testEupsStack self.tablefile = os.path.join(testEupsStack, "tablesyntax.table") self.table = Table(self.tablefile) self.eups = Eups(flavor="Linux") for k in ["EIGEN_DIR",]: # we're going to assert that it isn't set try: del os.environ[k] except KeyError: pass
def getManifest(self, product, version, flavor, noaction=False): if noaction: return Manifest() if version is None: raise RuntimeError("Unspecified version for %s" % product) tablefile = self.getTableFile(product, version, flavor) table = Table(tablefile) deps = table.dependencies(self.Eups, recursive=True) deps.reverse() manifest = Manifest(product, version) for p, optional, depth in deps: if not optional or self.Eups.findProduct(p.name, p.version): manifest.addDependency(p.name, p.version, p.flavor, None, None, None, optional) distId = "build:%s-%s.build" % (product, version) tableName = "%s.table" % product manifest.addDependency(product, version, flavor, tableName, os.path.join(product, version), distId, False) return manifest
class EmptyTableTestCase(unittest.TestCase): """ test out an (effectively) empty table file """ def setUp(self): os.environ["EUPS_PATH"] = testEupsStack self.tablefile = os.path.join(testEupsStack, "empty.table") self.table = Table(self.tablefile) self.eups = Eups() def testEmptyBlock(self): actions = self.table.actions("Linux64") for action in actions: action.execute(self.eups, 1, True)
class ExternalProductsTestCase(unittest.TestCase): """ Check that we can check the eups version """ def setUp(self): os.environ["EUPS_PATH"] = testEupsStack self.tablefile = os.path.join(testEupsStack, "externalProducts.table") self.table = Table(self.tablefile) self.eups = Eups() def testFoo(self): import eups.hooks as hooks defaultProductName = hooks.config.Eups.defaultProduct["name"] for i, productName, led in [(0, defaultProductName, False), (0, "someExternalProduct", True), (1, "anotherExternalProduct", True), ]: self.assertEqual(self.table.dependencies(listExternalDependencies=led)[i][0].name, productName)
class IfElseTestCase(unittest.TestCase): """ Check that if ... else if ... else blocks work """ def setUp(self): os.environ["EUPS_PATH"] = testEupsStack self.tablefile = os.path.join(testEupsStack, "ifElse.table") self.table = Table(self.tablefile) self.eups = Eups() def testEmptyBlock(self): for t in ("sdss", "sst", ""): actions = self.table.actions(None, t) for action in actions: action.execute(self.eups, 1, True) if not t: t = "other" self.assertEqual(os.environ["FOO"].lower(), t)
class ExternalProductsTestCase(unittest.TestCase): """ Check that we can check the eups version """ def setUp(self): os.environ["EUPS_PATH"] = testEupsStack self.tablefile = os.path.join(testEupsStack, "externalProducts.table") self.table = Table(self.tablefile) self.eups = Eups() def testFoo(self): import eups.hooks as hooks defaultProductName = hooks.config.Eups.defaultProduct["name"] for i, productName, led in [ (0, defaultProductName, False), (0, "someExternalProduct", True), (1, "anotherExternalProduct", True), ]: self.assertEqual( self.table.dependencies( listExternalDependencies=led)[i][0].name, productName)
def loadTableFor(self, version, table=None): """ cache the parsed contents of the table file. If table is not None, it will be taken as the Table instance representing the already parsed contents; otherwise, the table will be loaded from the table file path. @param version the version of the product to load @param table an instance of Table to accept as the loaded contents """ try: verdata = self.versions[version] if not table: if not utils.isRealFilename(verdata[1]): return if not os.path.exists(verdata[1]): raise TableFileNotFound(verdata[1], self.name, version) prod = self.getProduct(version) table = Table(verdata[1]).expandEupsVariables(prod) self.versions[version] = (verdata[0], verdata[1], table) except KeyError: raise ProductNotFound(self.name, version)
def setUp(self): os.environ["EUPS_PATH"] = testEupsStack self.tablefile = os.path.join(testEupsStack, "mwi.table") self.table = Table(self.tablefile)
class TableTestCase2(unittest.TestCase): """test the Table class""" def setUp(self): self.environ0 = os.environ.copy() os.environ["EUPS_PATH"] = testEupsStack self.tablefile = os.path.join(testEupsStack, "tablesyntax.table") self.table = Table(self.tablefile) self.eups = Eups(flavor="Linux") for k in ["EIGEN_DIR",]: # we're going to assert that it isn't set try: del os.environ[k] except KeyError: pass def tearDown(self): os.environ = self.environ0 def testNoSetup(self): actions = self.table.actions("Linux") for action in actions: action.execute(self.eups, 1, True, True) self.assertIn("GOOBPATH", os.environ) self.assertEqual(os.environ["GOOBPATH"], "/home/user/goob:/usr/goob:/usr/local/goob") self.assertNotIn("FOO", os.environ) self.assertNotIn("BAR", os.environ) self.assertIn("longls", self.eups.aliases) self.assertEqual(self.eups.aliases["longls"], "ls -l") # undo for action in actions: action.execute(self.eups, 1, False, True) self.assertNotIn("FOO", os.environ) self.assertNotIn("BAR", os.environ) self.assertIn("GOOBPATH", os.environ) self.assertEqual(os.environ["GOOBPATH"], '') def testIfFlavor(self): actions = self.table.actions("DarwinX86") for action in actions: action.execute(self.eups, 1, True, True) self.assertIn("GOOBPATH", os.environ) self.assertIn("FOO", os.environ) self.assertEqual(os.environ["FOO"], "1") self.assertNotIn("BAR", os.environ) # undo for action in actions: action.execute(self.eups, 1, False, True) self.assertNotIn("FOO", os.environ) self.assertNotIn("BAR", os.environ) self.assertIn("GOOBPATH", os.environ) self.assertEqual(os.environ["GOOBPATH"], '') def testIfType(self): actions = self.table.actions("DarwinX86", "build") for action in actions: action.execute(self.eups, 1, True, True) self.assertIn("GOOBPATH", os.environ) self.assertIn("FOO", os.environ) self.assertEqual(os.environ["FOO"], "1") self.assertIn("BAR", os.environ) # undo for action in actions: action.execute(self.eups, 1, False, True) self.assertNotIn("FOO", os.environ) self.assertIn("GOOBPATH", os.environ) self.assertIn("BAR", os.environ) self.assertEqual(os.environ["GOOBPATH"], '') self.assertEqual(os.environ["BAR"], '') def testSetup(self): actions = self.table.actions("Linux") for action in actions: action.execute(self.eups, 1, True) self.assertIn("GOOBPATH", os.environ) self.assertIn("SETUP_PYTHON", os.environ) self.assertIn("PYTHON_DIR", os.environ) self.assertIn("CFITSIO_DIR", os.environ) self.assertNotIn("EIGEN_DIR", os.environ) def testEmptyBlock(self): actions = self.table.actions("Linux64") for action in actions: action.execute(self.eups, 1, True) self.assertIn("GOOBPATH", os.environ) self.assertNotIn("FOO", os.environ) self.assertNotIn("BAR", os.environ) def testEnvSetWithForce(self): """ensure use of force does not cause failure""" actions = self.table.actions("Linux") self.eups.force = True # the following will fail if bug referred to in [11454] exists for action in actions: action.execute(self.eups, 1, True)
def setUp(self): os.environ["EUPS_PATH"] = testEupsStack self.tablefile = os.path.join(testEupsStack, "externalProducts.table") self.table = Table(self.tablefile) self.eups = Eups()
def setUp(self): os.environ["EUPS_PATH"] = testEupsStack self.tablefile = os.path.join(testEupsStack, "eupsVersion.table") self.table = Table(self.tablefile) self.eups = Eups()
class TableTestCase2(unittest.TestCase): """test the Table class""" def setUp(self): self.environ0 = os.environ.copy() os.environ["EUPS_PATH"] = testEupsStack self.tablefile = os.path.join(testEupsStack, "tablesyntax.table") self.table = Table(self.tablefile) self.eups = Eups(flavor="Linux") for k in [ "EIGEN_DIR", ]: # we're going to assert that it isn't set try: del os.environ[k] except KeyError: pass def tearDown(self): os.environ = self.environ0 def testNoSetup(self): actions = self.table.actions("Linux") for action in actions: action.execute(self.eups, 1, True, True) self.assertIn("GOOBPATH", os.environ) self.assertEqual(os.environ["GOOBPATH"], "/home/user/goob:/usr/goob:/usr/local/goob") self.assertNotIn("FOO", os.environ) self.assertNotIn("BAR", os.environ) self.assertIn("longls", self.eups.aliases) self.assertEqual(self.eups.aliases["longls"], "ls -l") # undo for action in actions: action.execute(self.eups, 1, False, True) self.assertNotIn("FOO", os.environ) self.assertNotIn("BAR", os.environ) self.assertIn("GOOBPATH", os.environ) self.assertEqual(os.environ["GOOBPATH"], '') def testIfFlavor(self): actions = self.table.actions("DarwinX86") for action in actions: action.execute(self.eups, 1, True, True) self.assertIn("GOOBPATH", os.environ) self.assertIn("FOO", os.environ) self.assertEqual(os.environ["FOO"], "1") self.assertNotIn("BAR", os.environ) # undo for action in actions: action.execute(self.eups, 1, False, True) self.assertNotIn("FOO", os.environ) self.assertNotIn("BAR", os.environ) self.assertIn("GOOBPATH", os.environ) self.assertEqual(os.environ["GOOBPATH"], '') def testIfType(self): actions = self.table.actions("DarwinX86", "build") for action in actions: action.execute(self.eups, 1, True, True) self.assertIn("GOOBPATH", os.environ) self.assertIn("FOO", os.environ) self.assertEqual(os.environ["FOO"], "1") self.assertIn("BAR", os.environ) # undo for action in actions: action.execute(self.eups, 1, False, True) self.assertNotIn("FOO", os.environ) self.assertIn("GOOBPATH", os.environ) self.assertIn("BAR", os.environ) self.assertEqual(os.environ["GOOBPATH"], '') self.assertEqual(os.environ["BAR"], '') def testSetup(self): actions = self.table.actions("Linux") for action in actions: action.execute(self.eups, 1, True) self.assertIn("GOOBPATH", os.environ) self.assertIn("SETUP_PYTHON", os.environ) self.assertIn("PYTHON_DIR", os.environ) self.assertIn("CFITSIO_DIR", os.environ) self.assertNotIn("EIGEN_DIR", os.environ) def testEmptyBlock(self): actions = self.table.actions("Linux64") for action in actions: action.execute(self.eups, 1, True) self.assertIn("GOOBPATH", os.environ) self.assertNotIn("FOO", os.environ) self.assertNotIn("BAR", os.environ) def testEnvSetWithForce(self): """ensure use of force does not cause failure""" actions = self.table.actions("Linux") self.eups.force = True # the following will fail if bug referred to in [11454] exists for action in actions: action.execute(self.eups, 1, True)