@@ -2920,15 +2920,15 @@ def test_github_get_source_tarball_from_git(self):
29202920 def run_check ():
29212921 """Helper function to run get_source_tarball_from_git & check dry run output"""
29222922 with self .mocked_stdout_stderr ():
2923- res = ft .get_source_tarball_from_git ('test.tar.gz ' , target_dir , git_config )
2923+ res = ft .get_source_tarball_from_git ('test' , target_dir , git_config )
29242924 stdout = self .get_stdout ()
29252925 stderr = self .get_stderr ()
29262926 self .assertEqual (stderr , '' )
29272927 regex = re .compile (expected )
29282928 self .assertTrue (regex .search (stdout ), "Pattern '%s' found in: %s" % (regex .pattern , stdout ))
29292929
29302930 self .assertEqual (os .path .dirname (res ), target_dir )
2931- self .assertEqual (os .path .basename (res ), 'test.tar.gz ' )
2931+ self .assertEqual (os .path .basename (res ), 'test.tar.xz ' )
29322932
29332933 git_config = {
29342934 'repo_name' : 'testrepository' ,
@@ -2941,40 +2941,36 @@ def run_check():
29412941 }
29422942
29432943 expected = '\n ' .join ([
2944- r' running shell command "git clone --depth 1 --branch tag_for_tests %( git_repo)s "' ,
2944+ r' running shell command "git clone --depth 1 --branch tag_for_tests { git_repo} "' ,
29452945 r" \(in .*/tmp.*\)" ,
2946- ft .reproducible_archive_cmd ("testrepository" , "%(test_prefix)s/target/test.tar.gz" ),
2947- r" \(in .*/tmp.*\)" ,
2948- ]) % string_args
2946+ r"Archiving '.*/{repo_name}' into '{test_prefix}/target/test.tar.xz'..." ,
2947+ ]).format (** string_args , repo_name = 'testrepository' )
29492948 run_check ()
29502949
29512950 git_config ['clone_into' ] = 'test123'
29522951 expected = '\n ' .join ([
2953- r' running shell command "git clone --depth 1 --branch tag_for_tests %(git_repo)s test123"' ,
2954- r" \(in .*/tmp.*\)" ,
2955- ft .reproducible_archive_cmd ("test123" , "%(test_prefix)s/target/test.tar.gz" ),
2952+ r' running shell command "git clone --depth 1 --branch tag_for_tests {git_repo} test123"' ,
29562953 r" \(in .*/tmp.*\)" ,
2957- ]) % string_args
2954+ r"Archiving '.*/{repo_name}' into '{test_prefix}/target/test.tar.xz'..." ,
2955+ ]).format (** string_args , repo_name = 'test123' )
29582956 run_check ()
29592957 del git_config ['clone_into' ]
29602958
29612959 git_config ['recursive' ] = True
29622960 expected = '\n ' .join ([
2963- r' running shell command "git clone --depth 1 --branch tag_for_tests --recursive %( git_repo)s "' ,
2961+ r' running shell command "git clone --depth 1 --branch tag_for_tests --recursive { git_repo} "' ,
29642962 r" \(in .*/tmp.*\)" ,
2965- ft .reproducible_archive_cmd ("testrepository" , "%(test_prefix)s/target/test.tar.gz" ),
2966- r" \(in .*/tmp.*\)" ,
2967- ]) % string_args
2963+ r"Archiving '.*/{repo_name}' into '{test_prefix}/target/test.tar.xz'..." ,
2964+ ]).format (** string_args , repo_name = 'testrepository' )
29682965 run_check ()
29692966
29702967 git_config ['recurse_submodules' ] = ['!vcflib' , '!sdsl-lite' ]
29712968 expected = '\n ' .join ([
29722969 ' running shell command "git clone --depth 1 --branch tag_for_tests --recursive'
2973- + ' --recurse-submodules=\' !vcflib\' --recurse-submodules=\' !sdsl-lite\' %(git_repo)s"' ,
2974- r" \(in .*/tmp.*\)" ,
2975- ft .reproducible_archive_cmd ("testrepository" , "%(test_prefix)s/target/test.tar.gz" ),
2970+ + ' --recurse-submodules=\' !vcflib\' --recurse-submodules=\' !sdsl-lite\' {git_repo}"' ,
29762971 r" \(in .*/tmp.*\)" ,
2977- ]) % string_args
2972+ r"Archiving '.*/{repo_name}' into '{test_prefix}/target/test.tar.xz'..." ,
2973+ ]).format (** string_args , repo_name = 'testrepository' )
29782974 run_check ()
29792975
29802976 git_config ['extra_config_params' ] = [
@@ -2984,60 +2980,72 @@ def run_check():
29842980 expected = '\n ' .join ([
29852981 ' running shell command "git -c submodule."fastahack".active=false -c submodule."sha1".active=false'
29862982 + ' clone --depth 1 --branch tag_for_tests --recursive'
2987- + ' --recurse-submodules=\' !vcflib\' --recurse-submodules=\' !sdsl-lite\' %( git_repo)s "' ,
2983+ + ' --recurse-submodules=\' !vcflib\' --recurse-submodules=\' !sdsl-lite\' { git_repo} "' ,
29882984 r" \(in .*/tmp.*\)" ,
2989- ft .reproducible_archive_cmd ("testrepository" , "%(test_prefix)s/target/test.tar.gz" ),
2990- r" \(in .*/tmp.*\)" ,
2991- ]) % string_args
2985+ r"Archiving '.*/{repo_name}' into '{test_prefix}/target/test.tar.xz'..." ,
2986+ ]).format (** string_args , repo_name = 'testrepository' )
29922987 run_check ()
29932988 del git_config ['recurse_submodules' ]
29942989 del git_config ['extra_config_params' ]
29952990
29962991 git_config ['keep_git_dir' ] = True
29972992 expected = '\n ' .join ([
2998- r' running shell command "git clone --branch tag_for_tests --recursive %(git_repo)s"' ,
2999- r" \(in .*/tmp.*\)" ,
3000- r' running shell command "tar cfvz .*/target/test.tar.gz testrepository"' ,
2993+ r' running shell command "git clone --branch tag_for_tests --recursive {git_repo}"' ,
30012994 r" \(in .*/tmp.*\)" ,
3002- ]) % string_args
2995+ r"Archiving '.*/{repo_name}' into '{test_prefix}/target/test.tar.xz'..." ,
2996+ ]).format (** string_args , repo_name = 'testrepository' )
30032997 run_check ()
30042998 del git_config ['keep_git_dir' ]
30052999
30063000 del git_config ['tag' ]
30073001 git_config ['commit' ] = '8456f86'
30083002 expected = '\n ' .join ([
3009- r' running shell command "git clone --no-checkout %( git_repo)s "' ,
3003+ r' running shell command "git clone --no-checkout { git_repo} "' ,
30103004 r" \(in .*/tmp.*\)" ,
30113005 r' running shell command "git checkout 8456f86 && git submodule update --init --recursive"' ,
3012- r" \(in testrepository\)" ,
3013- ft .reproducible_archive_cmd ("testrepository" , "%(test_prefix)s/target/test.tar.gz" ),
3014- r" \(in .*/tmp.*\)" ,
3015- ]) % string_args
3006+ r" \(in .*/testrepository\)" ,
3007+ r"Archiving '.*/{repo_name}' into '{test_prefix}/target/test.tar.xz'..." ,
3008+ ]).format (** string_args , repo_name = 'testrepository' )
30163009 run_check ()
30173010
30183011 git_config ['recurse_submodules' ] = ['!vcflib' , '!sdsl-lite' ]
30193012 expected = '\n ' .join ([
3020- r' running shell command "git clone --no-checkout %( git_repo)s "' ,
3013+ r' running shell command "git clone --no-checkout { git_repo} "' ,
30213014 r" \(in .*/tmp.*\)" ,
3022- r' running shell command "git checkout 8456f86"' ,
3023- r" \(in testrepository\) " ,
3024- ft . reproducible_archive_cmd ( "testrepository" , "%(test_prefix)s/target/test.tar.gz" ) ,
3025- r" \(in .*/tmp.*\) " ,
3026- ]) % string_args
3015+ r' running shell command "git checkout 8456f86 && git submodule update --init '
3016+ r"--recursive --recurse-submodules='!vcflib' --recurse-submodules='!sdsl-lite'\" " ,
3017+ r" \(in .*/testrepository\)" ,
3018+ r"Archiving ' .*/{repo_name}' into '{test_prefix}/target/test.tar.xz'... " ,
3019+ ]). format ( ** string_args , repo_name = 'testrepository' )
30273020 run_check ()
30283021
30293022 del git_config ['recursive' ]
30303023 del git_config ['recurse_submodules' ]
30313024 expected = '\n ' .join ([
3032- r' running shell command "git clone --no-checkout %( git_repo)s "' ,
3025+ r' running shell command "git clone --no-checkout { git_repo} "' ,
30333026 r" \(in /.*\)" ,
30343027 r' running shell command "git checkout 8456f86"' ,
30353028 r" \(in /.*/testrepository\)" ,
3036- ft .reproducible_archive_cmd ("testrepository" , "%(test_prefix)s/target/test.tar.gz" ),
3037- r" \(in /.*\)" ,
3038- ]) % string_args
3029+ r"Archiving '.*/{repo_name}' into '{test_prefix}/target/test.tar.xz'..." ,
3030+ ]).format (** string_args , repo_name = 'testrepository' )
30393031 run_check ()
30403032
3033+ # files with a recognizable extension have those extensions automatically removed with a warning
3034+ bad_filenames = ['test.tar' , 'test.tar.gz' , 'test.tar.xz' , 'test.zip' ]
3035+ # files with arbitrary extensions are taken as is and get extra 'tar.xz' extension appended
3036+ good_filenames = ['test' , 'test-1.2.3' , 'test.txt' , 'test-1.2.3.txt' ]
3037+ for test_filename in bad_filenames + good_filenames :
3038+ with self .mocked_stdout_stderr ():
3039+ res = ft .get_source_tarball_from_git (test_filename , target_dir , git_config )
3040+ stderr = self .get_stderr ()
3041+ regex = re .compile ("Ignoring extension of filename.*set in git_config parameter" )
3042+ if test_filename in bad_filenames :
3043+ self .assertTrue (regex .search (stderr ), "Pattern '%s' found in: %s" % (regex .pattern , stderr ))
3044+ self .assertTrue (res .endswith ("test.tar.xz" ))
3045+ else :
3046+ self .assertFalse (regex .search (stderr ), "Pattern '%s' found in: %s" % (regex .pattern , stderr ))
3047+ self .assertTrue (res .endswith (test_filename + ".tar.xz" ))
3048+
30413049 # Test with real data.
30423050 init_config ()
30433051 git_config = {
@@ -3047,13 +3055,13 @@ def run_check():
30473055 }
30483056
30493057 try :
3050- res = ft .get_source_tarball_from_git ('test.tar.gz ' , target_dir , git_config )
3058+ res = ft .get_source_tarball_from_git ('test' , target_dir , git_config )
30513059 # (only) tarball is created in specified target dir
3052- test_file = os .path .join (target_dir , 'test.tar.gz ' )
3060+ test_file = os .path .join (target_dir , 'test.tar.xz ' )
30533061 self .assertEqual (res , test_file )
30543062 self .assertTrue (os .path .isfile (test_file ))
3055- test_tar_gzs = [os .path .basename (test_file )]
3056- self .assertEqual (os .listdir (target_dir ), ['test.tar.gz ' ])
3063+ test_tar_files = [os .path .basename (test_file )]
3064+ self .assertEqual (os .listdir (target_dir ), ['test.tar.xz ' ])
30573065 # Check that we indeed downloaded the right tag
30583066 extracted_dir = tempfile .mkdtemp (prefix = 'extracted_dir' )
30593067 with self .mocked_stdout_stderr ():
@@ -3064,7 +3072,7 @@ def run_check():
30643072 # use a tag that clashes with a branch name and make sure this is handled correctly
30653073 git_config ['tag' ] = 'tag_for_tests'
30663074 with self .mocked_stdout_stderr ():
3067- res = ft .get_source_tarball_from_git ('test.tar.gz ' , target_dir , git_config )
3075+ res = ft .get_source_tarball_from_git ('test' , target_dir , git_config )
30683076 stderr = self .get_stderr ()
30693077 self .assertIn ('Tag tag_for_tests was not downloaded in the first try' , stderr )
30703078 self .assertEqual (res , test_file )
@@ -3077,20 +3085,20 @@ def run_check():
30773085
30783086 del git_config ['tag' ]
30793087 git_config ['commit' ] = '90366ea'
3080- res = ft .get_source_tarball_from_git ('test2.tar.gz ' , target_dir , git_config )
3081- test_file = os .path .join (target_dir , 'test2.tar.gz ' )
3088+ res = ft .get_source_tarball_from_git ('test2' , target_dir , git_config )
3089+ test_file = os .path .join (target_dir , 'test2.tar.xz ' )
30823090 self .assertEqual (res , test_file )
30833091 self .assertTrue (os .path .isfile (test_file ))
3084- test_tar_gzs .append (os .path .basename (test_file ))
3085- self .assertEqual (sorted (os .listdir (target_dir )), test_tar_gzs )
3092+ test_tar_files .append (os .path .basename (test_file ))
3093+ self .assertEqual (sorted (os .listdir (target_dir )), test_tar_files )
30863094
30873095 git_config ['keep_git_dir' ] = True
3088- res = ft .get_source_tarball_from_git ('test3.tar.gz ' , target_dir , git_config )
3089- test_file = os .path .join (target_dir , 'test3.tar.gz ' )
3096+ res = ft .get_source_tarball_from_git ('test3' , target_dir , git_config )
3097+ test_file = os .path .join (target_dir , 'test3.tar.xz ' )
30903098 self .assertEqual (res , test_file )
30913099 self .assertTrue (os .path .isfile (test_file ))
3092- test_tar_gzs .append (os .path .basename (test_file ))
3093- self .assertEqual (sorted (os .listdir (target_dir )), test_tar_gzs )
3100+ test_tar_files .append (os .path .basename (test_file ))
3101+ self .assertEqual (sorted (os .listdir (target_dir )), test_tar_files )
30943102
30953103 except EasyBuildError as err :
30963104 if "Network is down" in str (err ):
@@ -3103,7 +3111,7 @@ def run_check():
31033111 'url' :
'[email protected] :easybuilders' ,
31043112 'tag' : 'tag_for_tests' ,
31053113 }
3106- args = ['test.tar.gz ' , self .test_prefix , git_config ]
3114+ args = ['test' , self .test_prefix , git_config ]
31073115
31083116 for key in ['repo_name' , 'url' , 'tag' ]:
31093117 orig_value = git_config .pop (key )
0 commit comments