예제 #1
0
파일: toolkit.py 프로젝트: nudded/easybuild
    def setUp(self):
        """ set some toolkit objects, replace Modules class """
        # dynamically replace Modules class
        toolkit.Modules = MockModule
        modules.Modules = MockModule
        modules.get_software_root = MockModule().get_software_root
        toolkit.get_software_root = MockModule().get_software_root

        self.tk_32bit = Toolkit("icc", "4.0.3-32bit")
        self.tk_64bit = Toolkit("GCC", "4.6.3")
        self.dummy_tk = Toolkit("dummy", "1.0")
예제 #2
0
    def toolkit(self):
        """
        returns the Toolkit used
        """
        if self._toolkit:
            return self._toolkit

        tk = Toolkit(self.toolkit_name(), self.toolkit_version())
        if self["toolkitopts"]:
            tk.set_options(self["toolkitopts"])

        self._toolkit = tk
        return self._toolkit
예제 #3
0
파일: toolkit.py 프로젝트: nudded/easybuild
class ToolkitTest(TestCase):
    """ testcase for Toolkit """

    def setUp(self):
        """ set some toolkit objects, replace Modules class """
        # dynamically replace Modules class
        toolkit.Modules = MockModule
        modules.Modules = MockModule
        modules.get_software_root = MockModule().get_software_root
        toolkit.get_software_root = MockModule().get_software_root

        self.tk_32bit = Toolkit("icc", "4.0.3-32bit")
        self.tk_64bit = Toolkit("GCC", "4.6.3")
        self.dummy_tk = Toolkit("dummy", "1.0")

    def runTest(self):
        """ check parsing and interaction with Modules """
        self.assertEqual(self.tk_32bit.name, 'icc')
        # assert m32flag has been set
        self.assertEqual(self.tk_32bit.m32flag, ' -m32')
        # dummy toolkit always exists
        self.assertEqual(self.dummy_tk._toolkitExists(), True)
        self.assertEqual(self.tk_32bit._toolkitExists(), True)
        self.assertEqual(self.tk_64bit._toolkitExists(), False)


        # Test get_dependency_version
        dep = {"name": "depname", "version":"1.0"}
        dep2 = {"name": "gzip", "dummy":"dummy"}

        self.assertEqual("1.0-icc-4.0.3-32bit", self.tk_32bit.get_dependency_version(dep))
        self.assertEqual('1.4', self.dummy_tk.get_dependency_version(dep2))


        # test set_options
        self.dummy_tk.set_options({'static':True, 'non-existing':False})
        self.assertEqual(self.dummy_tk.opts['static'], True)
        self.assertRaises(KeyError, lambda: self.dummy_tk.opts['non-existing'])


        # test add_dependencies
        dep = {"name": 'gzip'}
        self.tk_32bit.add_dependencies([dep])
        self.assertEqual(len(self.tk_32bit.dependencies), 1)

        self.assertRaises(EasyBuildError, self.tk_32bit.add_dependencies, [{"name":"bzip"}])

        # Test prepare
        self.assertRaises(EasyBuildError, self.tk_64bit.prepare)

        # no dependencies should be added
        self.dummy_tk.prepare()
        self.assertEqual(MockModule.modules, [])

        os.environ["EBVERSIONICC"] = "2011"
        os.environ["EBROOTICC"] = "/tmp"

        self.tk_32bit.prepare()

        self.assertEqual(MockModule.modules, [(self.tk_32bit.name, self.tk_32bit.version), dep])
        MockModule.modules = []

    def tearDown(self):
        """ reset Modules to its original """
        modules.Modules = OrigModules