def test_buildininstalldir(self): """Test specifying build in install dir.""" config.variables['buildpath'] = tempfile.mkdtemp() config.variables['installpath'] = tempfile.mkdtemp() self.contents = '\n'.join([ 'name = "pi"', 'version = "3.14"', 'homepage = "http://example.com"', 'description = "test easyconfig"', 'toolchain = {"name": "dummy", "version": "dummy"}', 'buildininstalldir = True', ]) self.prep() eb = EasyBlock(self.eb_file) eb.gen_builddir() eb.mod_name = det_full_module_name(eb.cfg) # required by gen_installdir() eb.gen_installdir() eb.make_builddir() eb.make_installdir() self.assertEqual(eb.builddir, eb.installdir) self.assertTrue(os.path.isdir(eb.builddir)) # cleanup shutil.rmtree(config.variables['buildpath']) shutil.rmtree(config.variables['installpath'])
def test_gen_dirs(self): """Test methods that generate/set build/install directory names.""" self.contents = '\n'.join([ "name = 'pi'", "version = '3.14'", "homepage = 'http://example.com'", "description = 'test easyconfig'", "toolchain = {'name': 'dummy', 'version': 'dummy'}", ]) self.writeEC() stdoutorig = sys.stdout sys.stdout = open("/dev/null", 'w') eb = EasyBlock(EasyConfig(self.eb_file)) resb = eb.gen_builddir() eb.mod_name = det_full_module_name( eb.cfg) # required by gen_installdir() resi = eb.gen_installdir() eb.make_builddir() eb.make_installdir() # doesn't return anything self.assertEqual(resb, None) self.assertEqual(resi, None) # directories are set, and exist self.assertTrue(os.path.isdir(eb.builddir)) self.assertTrue(os.path.isdir(eb.installdir)) # make sure cleaning up old build dir is default self.assertTrue(eb.cfg['cleanupoldbuild'] or eb.cfg.get('cleanupoldbuild', True)) builddir = eb.builddir eb.gen_builddir() self.assertEqual(builddir, eb.builddir) eb.cfg['cleanupoldbuild'] = True eb.gen_builddir() self.assertEqual(builddir, eb.builddir) # make sure build dir is unique eb.cfg['cleanupoldbuild'] = False builddir = eb.builddir for i in range(3): eb.gen_builddir() self.assertEqual(eb.builddir, "%s.%d" % (builddir, i)) eb.make_builddir() # cleanup sys.stdout.close() sys.stdout = stdoutorig eb.close_log()
def test_gen_dirs(self): """Test methods that generate/set build/install directory names.""" self.contents = "\n".join( [ "name = 'pi'", "version = '3.14'", "homepage = 'http://example.com'", "description = 'test easyconfig'", "toolchain = {'name': 'dummy', 'version': 'dummy'}", ] ) self.writeEC() stdoutorig = sys.stdout sys.stdout = open("/dev/null", "w") eb = EasyBlock(EasyConfig(self.eb_file)) resb = eb.gen_builddir() resi = eb.gen_installdir() eb.make_builddir() eb.make_installdir() # doesn't return anything self.assertEqual(resb, None) self.assertEqual(resi, None) # directories are set, and exist self.assertTrue(os.path.isdir(eb.builddir)) self.assertTrue(os.path.isdir(eb.installdir)) # make sure cleaning up old build dir is default self.assertTrue(eb.cfg["cleanupoldbuild"] or eb.cfg.get("cleanupoldbuild", True)) builddir = eb.builddir eb.gen_builddir() self.assertEqual(builddir, eb.builddir) eb.cfg["cleanupoldbuild"] = True eb.gen_builddir() self.assertEqual(builddir, eb.builddir) # make sure build dir is unique eb.cfg["cleanupoldbuild"] = False builddir = eb.builddir for i in range(3): eb.gen_builddir() self.assertEqual(eb.builddir, "%s.%d" % (builddir, i)) eb.make_builddir() # cleanup sys.stdout.close() sys.stdout = stdoutorig eb.close_log()
def test_make_module_dep_hmns(self): """Test for make_module_dep under HMNS""" test_ecs_path = os.path.join( os.path.dirname(os.path.abspath(__file__)), 'easyconfigs', 'test_ecs') all_stops = [x[0] for x in EasyBlock.get_steps()] build_options = { 'check_osdeps': False, 'robot_path': [test_ecs_path], 'valid_stops': all_stops, 'validate': False, } os.environ['EASYBUILD_MODULE_NAMING_SCHEME'] = 'HierarchicalMNS' init_config(build_options=build_options) self.setup_hierarchical_modules() self.contents = '\n'.join([ 'easyblock = "ConfigureMake"', 'name = "pi"', 'version = "3.14"', 'homepage = "http://example.com"', 'description = "test easyconfig"', "toolchain = {'name': 'gompi', 'version': '1.4.10'}", 'dependencies = [', " ('FFTW', '3.3.3'),", ']', ]) self.writeEC() eb = EasyBlock(EasyConfig(self.eb_file)) eb.installdir = os.path.join(config.install_path(), 'pi', '3.14') eb.check_readiness_step() eb.make_builddir() eb.prepare_step() # GCC, OpenMPI and hwloc modules should *not* be included in loads for dependencies mod_dep_txt = eb.make_module_dep() for mod in ['GCC/4.7.2', 'OpenMPI/1.6.4']: regex = re.compile('load.*%s' % mod) self.assertFalse( regex.search(mod_dep_txt), "Pattern '%s' found in: %s" % (regex.pattern, mod_dep_txt)) regex = re.compile('load.*FFTW/3.3.3') self.assertTrue( regex.search(mod_dep_txt), "Pattern '%s' found in: %s" % (regex.pattern, mod_dep_txt))
def test_buildininstalldir(self): """Test specifying build in install dir.""" self.contents = '\n'.join([ 'name = "pi"', 'version = "3.14"', 'homepage = "http://example.com"', 'description = "test easyconfig"', 'toolchain = {"name": "dummy", "version": "dummy"}', 'buildininstalldir = True', ]) self.prep() ec = EasyConfig(self.eb_file) eb = EasyBlock(ec) eb.gen_builddir() eb.gen_installdir() eb.make_builddir() eb.make_installdir() self.assertEqual(eb.builddir, eb.installdir) self.assertTrue(os.path.isdir(eb.builddir))
def test_make_module_dep_hmns(self): """Test for make_module_dep under HMNS""" test_ecs_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'easyconfigs', 'test_ecs') all_stops = [x[0] for x in EasyBlock.get_steps()] build_options = { 'check_osdeps': False, 'robot_path': [test_ecs_path], 'valid_stops': all_stops, 'validate': False, } os.environ['EASYBUILD_MODULE_NAMING_SCHEME'] = 'HierarchicalMNS' init_config(build_options=build_options) self.setup_hierarchical_modules() self.contents = '\n'.join([ 'easyblock = "ConfigureMake"', 'name = "pi"', 'version = "3.14"', 'homepage = "http://example.com"', 'description = "test easyconfig"', "toolchain = {'name': 'gompi', 'version': '1.4.10'}", 'dependencies = [', " ('FFTW', '3.3.3'),", ']', ]) self.writeEC() eb = EasyBlock(EasyConfig(self.eb_file)) eb.installdir = os.path.join(config.install_path(), 'pi', '3.14') eb.check_readiness_step() eb.make_builddir() eb.prepare_step() # GCC, OpenMPI and hwloc modules should *not* be included in loads for dependencies mod_dep_txt = eb.make_module_dep() for mod in ['GCC/4.7.2', 'OpenMPI/1.6.4']: regex = re.compile('load.*%s' % mod) self.assertFalse(regex.search(mod_dep_txt), "Pattern '%s' found in: %s" % (regex.pattern, mod_dep_txt)) regex = re.compile('load.*FFTW/3.3.3') self.assertTrue(regex.search(mod_dep_txt), "Pattern '%s' found in: %s" % (regex.pattern, mod_dep_txt))
def test_gen_dirs(self): """Test methods that generate/set build/install directory names.""" self.contents = '\n'.join([ "name = 'pi'", "version = '3.14'", "homepage = 'http://example.com'", "description = 'test easyconfig'", "toolchain = {'name': 'dummy', 'version': 'dummy'}", ]) self.writeEC() stdoutorig = sys.stdout sys.stdout = open("/dev/null", 'w') eb = EasyBlock(self.eb_file) resb = eb.gen_builddir() eb.mod_name = det_full_module_name(eb.cfg) # required by gen_installdir() resi = eb.gen_installdir() eb.make_builddir() eb.make_installdir() # doesn't return anything self.assertEqual(resb, None) self.assertEqual(resi, None) # directories are set, and exist self.assertTrue(os.path.isdir(eb.builddir)) self.assertTrue(os.path.isdir(eb.installdir)) # make sure build dir is unique builddir = eb.builddir for i in range(0,3): eb.gen_builddir() self.assertEqual(eb.builddir, "%s.%d" % (builddir, i)) eb.make_builddir() # cleanup sys.stdout.close() sys.stdout = stdoutorig eb.close_log()