@@ -1946,6 +1946,51 @@ def test_try(self):
19461946 allargs = args + ['--software-version=1.2.3' , '--toolchain=gompi,2018a' ]
19471947 self .assertErrorRegex (EasyBuildError , "version .* not available" , self .eb_main , allargs , raise_error = True )
19481948
1949+ def test_try_with_copy (self ):
1950+ """Test whether --try options are taken into account."""
1951+ ecs_path = os .path .join (os .path .dirname (os .path .abspath (__file__ )), 'easyconfigs' , 'test_ecs' )
1952+ tweaked_toy_ec = os .path .join (self .test_buildpath , 'toy-0.0-tweaked.eb' )
1953+ copy_file (os .path .join (ecs_path , 't' , 'toy' , 'toy-0.0.eb' ), tweaked_toy_ec )
1954+ f = open (tweaked_toy_ec , 'a' )
1955+ f .write ("easyblock = 'ConfigureMake'" )
1956+ f .close ()
1957+
1958+ args = [
1959+ tweaked_toy_ec ,
1960+ '--sourcepath=%s' % self .test_sourcepath ,
1961+ '--buildpath=%s' % self .test_buildpath ,
1962+ '--installpath=%s' % self .test_installpath ,
1963+ '--dry-run' ,
1964+ '--robot=%s' % ecs_path ,
1965+ '--copy-ec' ,
1966+ ]
1967+ self .mock_stdout (True )
1968+ self .mock_stderr (True )
1969+ copied_ec = os .path .join (self .test_buildpath , 'my_eb.eb' )
1970+ self .eb_main (args + [copied_ec ], verbose = True , raise_error = True )
1971+ outtxt = self .get_stdout ()
1972+ errtxt = self .get_stderr ()
1973+ self .assertTrue (r'toy-0.0-tweaked.eb copied to ' + copied_ec in outtxt )
1974+ self .assertFalse (errtxt )
1975+ self .mock_stdout (False )
1976+ self .mock_stderr (False )
1977+ self .assertTrue (os .path .exists (copied_ec ))
1978+
1979+ self .mock_stdout (True )
1980+ self .mock_stderr (True )
1981+ tweaked_ecs_dir = os .path .join (self .test_buildpath , 'my_tweaked_ecs' )
1982+ self .eb_main (args + ['--try-software=foo,1.2.3' , '--try-toolchain=gompi,2018a' , tweaked_ecs_dir ],
1983+ verbose = True , raise_error = True )
1984+ outtxt = self .get_stdout ()
1985+ errtxt = self .get_stderr ()
1986+ self .assertTrue (r'1 file(s) copied to ' + tweaked_ecs_dir in outtxt )
1987+ self .assertFalse (errtxt )
1988+ self .mock_stdout (False )
1989+ self .mock_stderr (False )
1990+ self .assertTrue (
1991+ os .path .exists (os .path .join (self .test_buildpath , tweaked_ecs_dir , 'foo-1.2.3-GCC-6.4.0-2.28.eb' ))
1992+ )
1993+
19491994 def test_software_version_ordering (self ):
19501995 """Test whether software versions are correctly ordered when using --software."""
19511996 ecs_path = os .path .join (os .path .dirname (os .path .abspath (__file__ )), 'easyconfigs' , 'test_ecs' )
0 commit comments