@@ -2488,71 +2488,8 @@ def test_diff_files(self):
24882488 def test_get_source_tarball_from_git (self ):
24892489 """Test get_source_tarball_from_git function."""
24902490
2491- git_config = {
2492- 'repo_name' : 'testrepository' ,
2493- 'url' : 'https://github.com/easybuilders' ,
2494- 'tag' : 'tag_for_tests' ,
2495- }
24962491 target_dir = os .path .join (self .test_prefix , 'target' )
24972492
2498- try :
2499- res = ft .get_source_tarball_from_git ('test.tar.gz' , target_dir , git_config )
2500- # (only) tarball is created in specified target dir
2501- test_file = os .path .join (target_dir , 'test.tar.gz' )
2502- self .assertEqual (res , test_file )
2503- self .assertTrue (os .path .isfile (test_file ))
2504- self .assertEqual (os .listdir (target_dir ), ['test.tar.gz' ])
2505-
2506- # Check that we indeed downloaded the tag and not a branch
2507- extracted_dir = tempfile .mkdtemp (prefix = 'extracted_dir' )
2508- target_dir = ft .extract_file (test_file , extracted_dir , change_into_dir = False )
2509- self .assertTrue (os .path .isfile (os .path .join (target_dir , 'this-is-a-tag.txt' )))
2510-
2511- del git_config ['tag' ]
2512- git_config ['commit' ] = '8456f86'
2513- res = ft .get_source_tarball_from_git ('test2.tar.gz' , target_dir , git_config )
2514- test_file = os .path .join (target_dir , 'test2.tar.gz' )
2515- self .assertEqual (res , test_file )
2516- self .assertTrue (os .path .isfile (test_file ))
2517- self .assertEqual (sorted (os .listdir (target_dir )), ['test.tar.gz' , 'test2.tar.gz' ])
2518-
2519- except EasyBuildError as err :
2520- if "Network is down" in str (err ):
2521- print ("Ignoring download error in test_get_source_tarball_from_git, working offline?" )
2522- else :
2523- raise err
2524-
2525- git_config = {
2526- 'repo_name' : 'testrepository' ,
2527- 'url' :
'[email protected] :easybuilders' ,
2528- 'tag' : 'tag_for_tests' ,
2529- }
2530- args = ['test.tar.gz' , self .test_prefix , git_config ]
2531-
2532- for key in ['repo_name' , 'url' , 'tag' ]:
2533- orig_value = git_config .pop (key )
2534- if key == 'tag' :
2535- error_pattern = "Neither tag nor commit found in git_config parameter"
2536- else :
2537- error_pattern = "%s not specified in git_config parameter" % key
2538- self .assertErrorRegex (EasyBuildError , error_pattern , ft .get_source_tarball_from_git , * args )
2539- git_config [key ] = orig_value
2540-
2541- git_config ['commit' ] = '8456f86'
2542- error_pattern = "Tag and commit are mutually exclusive in git_config parameter"
2543- self .assertErrorRegex (EasyBuildError , error_pattern , ft .get_source_tarball_from_git , * args )
2544- del git_config ['commit' ]
2545-
2546- git_config ['unknown' ] = 'foobar'
2547- error_pattern = "Found one or more unexpected keys in 'git_config' specification"
2548- self .assertErrorRegex (EasyBuildError , error_pattern , ft .get_source_tarball_from_git , * args )
2549- del git_config ['unknown' ]
2550-
2551- args [0 ] = 'test.txt'
2552- error_pattern = "git_config currently only supports filename ending in .tar.gz"
2553- self .assertErrorRegex (EasyBuildError , error_pattern , ft .get_source_tarball_from_git , * args )
2554- args [0 ] = 'test.tar.gz'
2555-
25562493 # only test in dry run mode, i.e. check which commands would be executed without actually running them
25572494 build_options = {
25582495 'extended_dry_run' : True ,
@@ -2628,6 +2565,73 @@ def run_check():
26282565 ])
26292566 run_check ()
26302567
2568+ # Test with real data
2569+ init_config ()
2570+ git_config = {
2571+ 'repo_name' : 'testrepository' ,
2572+ 'url' : 'https://github.com/easybuilders' ,
2573+ 'tag' : 'tag_for_tests' ,
2574+ }
2575+
2576+ try :
2577+ res = ft .get_source_tarball_from_git ('test.tar.gz' , target_dir , git_config )
2578+ # (only) tarball is created in specified target dir
2579+ test_file = os .path .join (target_dir , 'test.tar.gz' )
2580+ self .assertEqual (res , test_file )
2581+ self .assertTrue (os .path .isfile (test_file ))
2582+ self .assertEqual (os .listdir (target_dir ), ['test.tar.gz' ])
2583+
2584+ # Check that we indeed downloaded the tag and not a branch
2585+ extracted_dir = tempfile .mkdtemp (prefix = 'extracted_dir' )
2586+ target_dir = ft .extract_file (test_file , extracted_dir , change_into_dir = False )
2587+ self .assertTrue (os .path .isfile (os .path .join (target_dir , 'this-is-a-tag.txt' )))
2588+
2589+ del git_config ['tag' ]
2590+ git_config ['commit' ] = '8456f86'
2591+ res = ft .get_source_tarball_from_git ('test2.tar.gz' , target_dir , git_config )
2592+ test_file = os .path .join (target_dir , 'test2.tar.gz' )
2593+ self .assertEqual (res , test_file )
2594+ self .assertTrue (os .path .isfile (test_file ))
2595+ self .assertEqual (sorted (os .listdir (target_dir )), ['test.tar.gz' , 'test2.tar.gz' ])
2596+
2597+ except EasyBuildError as err :
2598+ if "Network is down" in str (err ):
2599+ print ("Ignoring download error in test_get_source_tarball_from_git, working offline?" )
2600+ else :
2601+ raise err
2602+
2603+ git_config = {
2604+ 'repo_name' : 'testrepository' ,
2605+ 'url' :
'[email protected] :easybuilders' ,
2606+ 'tag' : 'tag_for_tests' ,
2607+ }
2608+ args = ['test.tar.gz' , self .test_prefix , git_config ]
2609+
2610+ for key in ['repo_name' , 'url' , 'tag' ]:
2611+ orig_value = git_config .pop (key )
2612+ if key == 'tag' :
2613+ error_pattern = "Neither tag nor commit found in git_config parameter"
2614+ else :
2615+ error_pattern = "%s not specified in git_config parameter" % key
2616+ self .assertErrorRegex (EasyBuildError , error_pattern , ft .get_source_tarball_from_git , * args )
2617+ git_config [key ] = orig_value
2618+
2619+ git_config ['commit' ] = '8456f86'
2620+ error_pattern = "Tag and commit are mutually exclusive in git_config parameter"
2621+ self .assertErrorRegex (EasyBuildError , error_pattern , ft .get_source_tarball_from_git , * args )
2622+ del git_config ['commit' ]
2623+
2624+ git_config ['unknown' ] = 'foobar'
2625+ error_pattern = "Found one or more unexpected keys in 'git_config' specification"
2626+ self .assertErrorRegex (EasyBuildError , error_pattern , ft .get_source_tarball_from_git , * args )
2627+ del git_config ['unknown' ]
2628+
2629+ args [0 ] = 'test.txt'
2630+ error_pattern = "git_config currently only supports filename ending in .tar.gz"
2631+ self .assertErrorRegex (EasyBuildError , error_pattern , ft .get_source_tarball_from_git , * args )
2632+ args [0 ] = 'test.tar.gz'
2633+
2634+
26312635 def test_is_sha256_checksum (self ):
26322636 """Test for is_sha256_checksum function."""
26332637 a_sha256_checksum = '44332000aa33b99ad1e00cbd1a7da769220d74647060a10e807b916d73ea27bc'
0 commit comments