@@ -302,7 +302,9 @@ def test_dependency(self):
302302 self .assertEqual (det_full_ec_version (first ), '1.1-GCC-4.6.3' )
303303 self .assertEqual (det_full_ec_version (second ), '2.2-GCC-4.6.3' )
304304
305+ self .assertEqual (eb .dependency_names (), {'first' , 'second' , 'foo' , 'bar' })
305306 # same tests for builddependencies
307+ self .assertEqual (eb .dependency_names (build_only = True ), {'first' , 'second' })
306308 first = eb .builddependencies ()[0 ]
307309 second = eb .builddependencies ()[1 ]
308310
@@ -355,6 +357,7 @@ def test_false_dep_version(self):
355357 self .assertEqual (len (deps ), 2 )
356358 self .assertEqual (deps [0 ]['name' ], 'second_build' )
357359 self .assertEqual (deps [1 ]['name' ], 'first' )
360+ self .assertEqual (eb .dependency_names (), {'first' , 'second_build' })
358361
359362 # more realistic example: only filter dep for POWER
360363 self .contents = '\n ' .join ([
@@ -378,12 +381,14 @@ def test_false_dep_version(self):
378381 deps = eb .dependencies ()
379382 self .assertEqual (len (deps ), 1 )
380383 self .assertEqual (deps [0 ]['name' ], 'not_on_power' )
384+ self .assertEqual (eb .dependency_names (), {'not_on_power' })
381385
382386 # only power, dependency gets filtered
383387 st .get_cpu_architecture = lambda : POWER
384388 eb = EasyConfig (self .eb_file )
385389 deps = eb .dependencies ()
386390 self .assertEqual (deps , [])
391+ self .assertEqual (eb .dependency_names (), set ())
387392
388393 def test_extra_options (self ):
389394 """ extra_options should allow other variables to be stored """
@@ -1350,6 +1355,34 @@ def test_start_dir_template(self):
13501355 self .assertIn ('start_dir in extension configure is %s &&' % ext_start_dir , logtxt )
13511356 self .assertIn ('start_dir in extension build is %s &&' % ext_start_dir , logtxt )
13521357
1358+ def test_sysroot_template (self ):
1359+ """Test the %(sysroot)s template"""
1360+
1361+ test_easyconfigs = os .path .join (os .path .abspath (os .path .dirname (__file__ )), 'easyconfigs' , 'test_ecs' )
1362+ toy_ec = os .path .join (test_easyconfigs , 't' , 'toy' , 'toy-0.0.eb' )
1363+
1364+ test_ec = os .path .join (self .test_prefix , 'test.eb' )
1365+ test_ec_txt = read_file (toy_ec )
1366+ test_ec_txt += '\n configopts = "--some-opt=%(sysroot)s/"'
1367+ test_ec_txt += '\n buildopts = "--some-opt=%(sysroot)s/"'
1368+ test_ec_txt += '\n installopts = "--some-opt=%(sysroot)s/"'
1369+ write_file (test_ec , test_ec_txt )
1370+
1371+ # Validate the value of the sysroot template if sysroot is unset (i.e. the build option is None)
1372+ ec = EasyConfig (test_ec )
1373+ self .assertEqual (ec ['configopts' ], "--some-opt=/" )
1374+ self .assertEqual (ec ['buildopts' ], "--some-opt=/" )
1375+ self .assertEqual (ec ['installopts' ], "--some-opt=/" )
1376+
1377+ # Validate the value of the sysroot template if sysroot is unset (i.e. the build option is None)
1378+ # As a test, we'll set the sysroot to self.test_prefix, as it has to be a directory that is guaranteed to exist
1379+ update_build_option ('sysroot' , self .test_prefix )
1380+
1381+ ec = EasyConfig (test_ec )
1382+ self .assertEqual (ec ['configopts' ], "--some-opt=%s/" % self .test_prefix )
1383+ self .assertEqual (ec ['buildopts' ], "--some-opt=%s/" % self .test_prefix )
1384+ self .assertEqual (ec ['installopts' ], "--some-opt=%s/" % self .test_prefix )
1385+
13531386 def test_constant_doc (self ):
13541387 """test constant documentation"""
13551388 doc = avail_easyconfig_constants ()
@@ -1602,18 +1635,15 @@ def test_filter_deps(self):
16021635 test_ecs_dir = os .path .join (os .path .abspath (os .path .dirname (__file__ )), 'easyconfigs' , 'test_ecs' )
16031636 ec_file = os .path .join (test_ecs_dir , 'f' , 'foss' , 'foss-2018a.eb' )
16041637 ec = EasyConfig (ec_file )
1605- deps = sorted ([dep ['name' ] for dep in ec .dependencies ()])
1606- self .assertEqual (deps , ['FFTW' , 'GCC' , 'OpenBLAS' , 'OpenMPI' , 'ScaLAPACK' ])
1638+ self .assertEqual (ec .dependency_names (), {'FFTW' , 'GCC' , 'OpenBLAS' , 'OpenMPI' , 'ScaLAPACK' })
16071639
16081640 # test filtering multiple deps
16091641 init_config (build_options = {'filter_deps' : ['FFTW' , 'ScaLAPACK' ]})
1610- deps = sorted ([dep ['name' ] for dep in ec .dependencies ()])
1611- self .assertEqual (deps , ['GCC' , 'OpenBLAS' , 'OpenMPI' ])
1642+ self .assertEqual (ec .dependency_names (), {'GCC' , 'OpenBLAS' , 'OpenMPI' })
16121643
16131644 # test filtering of non-existing dep
16141645 init_config (build_options = {'filter_deps' : ['zlib' ]})
1615- deps = sorted ([dep ['name' ] for dep in ec .dependencies ()])
1616- self .assertEqual (deps , ['FFTW' , 'GCC' , 'OpenBLAS' , 'OpenMPI' , 'ScaLAPACK' ])
1646+ self .assertEqual (ec .dependency_names (), {'FFTW' , 'GCC' , 'OpenBLAS' , 'OpenMPI' , 'ScaLAPACK' })
16171647
16181648 # test parsing of value passed to --filter-deps
16191649 opts = init_config (args = [])
@@ -1647,6 +1677,7 @@ def test_filter_deps(self):
16471677 init_config (build_options = build_options )
16481678 ec = EasyConfig (ec_file , validate = False )
16491679 self .assertEqual (ec .dependencies (), [])
1680+ self .assertEqual (ec .dependency_names (), set ())
16501681
16511682 def test_replaced_easyconfig_parameters (self ):
16521683 """Test handling of replaced easyconfig parameters."""
@@ -1835,6 +1866,9 @@ def test_external_dependencies(self):
18351866 }
18361867 self .assertEqual (deps [7 ]['external_module_metadata' ], cray_netcdf_metadata )
18371868
1869+ # External module names are omitted
1870+ self .assertEqual (ec .dependency_names (), {'intel' })
1871+
18381872 # provide file with partial metadata for some external modules;
18391873 # metadata obtained from probing modules should be added to it...
18401874 metadata = os .path .join (self .test_prefix , 'external_modules_metadata.cfg' )
@@ -1863,6 +1897,7 @@ def test_external_dependencies(self):
18631897 deps = ec .dependencies ()
18641898
18651899 self .assertEqual (len (deps ), 8 )
1900+ self .assertEqual (ec .dependency_names (), {'intel' })
18661901
18671902 for idx in [0 , 1 , 2 , 6 ]:
18681903 self .assertEqual (deps [idx ]['external_module_metadata' ], {})
@@ -3229,6 +3264,7 @@ def test_template_constant_dict(self):
32293264 'nameletter' : 'g' ,
32303265 'nameletterlower' : 'g' ,
32313266 'parallel' : None ,
3267+ 'sysroot' : '' ,
32323268 'toolchain_name' : 'foss' ,
32333269 'toolchain_version' : '2018a' ,
32343270 'version' : '1.5' ,
@@ -3311,6 +3347,7 @@ def test_template_constant_dict(self):
33113347 'pyminver' : '7' ,
33123348 'pyshortver' : '3.7' ,
33133349 'pyver' : '3.7.2' ,
3350+ 'sysroot' : '' ,
33143351 'version' : '0.01' ,
33153352 'version_major' : '0' ,
33163353 'version_major_minor' : '0.01' ,
@@ -3375,6 +3412,7 @@ def test_template_constant_dict(self):
33753412 'namelower' : 'foo' ,
33763413 'nameletter' : 'f' ,
33773414 'nameletterlower' : 'f' ,
3415+ 'sysroot' : '' ,
33783416 'version' : '1.2.3' ,
33793417 'version_major' : '1' ,
33803418 'version_major_minor' : '1.2' ,
0 commit comments