@@ -3124,10 +3124,33 @@ def run_check():
31243124 self .assertErrorRegex (EasyBuildError , error_pattern , ft .get_source_tarball_from_git , * args )
31253125 del git_config ['unknown' ]
31263126
3127- args [0 ] = 'test.txt'
3128- error_pattern = "git_config currently only supports filename ending in .tar.gz"
3129- self .assertErrorRegex (EasyBuildError , error_pattern , ft .get_source_tarball_from_git , * args )
3130- args [0 ] = 'test.tar.gz'
3127+ def test_make_archive (self ):
3128+ """Test for make_archive method"""
3129+ # create fake directories and files to be archived
3130+ tmpdir = tempfile .mkdtemp ()
3131+ tardir = os .path .join (tmpdir , "test_archive" )
3132+ os .mkdir (tardir )
3133+ for path in ('bin' , 'lib' , 'include' ):
3134+ os .mkdir (os .path .join (tardir , path ))
3135+ ft .write_file (os .path .join (tardir , 'README' ), 'Dummy readme' )
3136+ ft .write_file (os .path .join (tardir , 'bin' , 'executable' ), 'Dummy binary' )
3137+ ft .write_file (os .path .join (tardir , 'lib' , 'lib.so' ), 'Dummy library' )
3138+ ft .write_file (os .path .join (tardir , 'include' , 'header.h' ), 'Dummy header' )
3139+
3140+ reference_checksum = "ec0f91a462c2743b19b428f4c177d7109d2ccc018dcdedc12570d9d735d6fb1b"
3141+
3142+ test_tar = ft .make_archive (tardir , reproducible = False )
3143+ self .assertEqual (test_tar , "test_archive.tar.xz" )
3144+ self .assertNotEqual (ft .compute_checksum (test_tar , checksum_type = "sha256" ), reference_checksum )
3145+ test_tar = ft .make_archive (tardir , reproducible = True )
3146+ self .assertEqual (test_tar , "test_archive.tar.xz" )
3147+ self .assertEqual (ft .compute_checksum (test_tar , checksum_type = "sha256" ), reference_checksum )
3148+ test_tar = ft .make_archive (tardir , archive_name = "custom_name" , reproducible = True )
3149+ self .assertEqual (test_tar , "custom_name.tar.xz" )
3150+ self .assertEqual (ft .compute_checksum (test_tar , checksum_type = "sha256" ), reference_checksum )
3151+ test_tar = ft .make_archive (tardir , archive_name = "custom_name" , archive_dir = tmpdir , reproducible = True )
3152+ self .assertEqual (test_tar , os .path .join (tmpdir , "custom_name.tar.xz" ))
3153+ self .assertEqual (ft .compute_checksum (test_tar , checksum_type = "sha256" ), reference_checksum )
31313154
31323155 def test_is_sha256_checksum (self ):
31333156 """Test for is_sha256_checksum function."""
0 commit comments