Skip to content

Commit 671d3dd

Browse files
committed
update test_github_get_source_tarball_from_git to properly test supported filenames and extensions in make_archive
1 parent 8918005 commit 671d3dd

File tree

1 file changed

+108
-100
lines changed

1 file changed

+108
-100
lines changed

test/framework/filetools.py

Lines changed: 108 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -2940,111 +2940,119 @@ def run_check():
29402940
'test_prefix': self.test_prefix,
29412941
}
29422942

2943-
expected = '\n'.join([
2944-
r' running shell command "git clone --depth 1 --branch tag_for_tests {git_repo}"',
2945-
r" \(in .*/tmp.*\)",
2946-
r"Archiving '.*/{repo_name}' into '{test_prefix}/target/test.tar.xz'...",
2947-
]).format(**string_args, repo_name='testrepository')
2948-
run_check()
2949-
2950-
git_config['clone_into'] = 'test123'
2951-
expected = '\n'.join([
2952-
r' running shell command "git clone --depth 1 --branch tag_for_tests {git_repo} test123"',
2953-
r" \(in .*/tmp.*\)",
2954-
r"Archiving '.*/{repo_name}' into '{test_prefix}/target/test.tar.xz'...",
2955-
]).format(**string_args, repo_name='test123')
2956-
run_check()
2957-
del git_config['clone_into']
2958-
2959-
git_config['recursive'] = True
2960-
expected = '\n'.join([
2961-
r' running shell command "git clone --depth 1 --branch tag_for_tests --recursive {git_repo}"',
2962-
r" \(in .*/tmp.*\)",
2963-
r"Archiving '.*/{repo_name}' into '{test_prefix}/target/test.tar.xz'...",
2964-
]).format(**string_args, repo_name='testrepository')
2965-
run_check()
2966-
2967-
git_config['recurse_submodules'] = ['!vcflib', '!sdsl-lite']
2968-
expected = '\n'.join([
2969-
' running shell command "git clone --depth 1 --branch tag_for_tests --recursive'
2970-
+ ' --recurse-submodules=\'!vcflib\' --recurse-submodules=\'!sdsl-lite\' {git_repo}"',
2971-
r" \(in .*/tmp.*\)",
2972-
r"Archiving '.*/{repo_name}' into '{test_prefix}/target/test.tar.xz'...",
2973-
]).format(**string_args, repo_name='testrepository')
2974-
run_check()
2975-
2976-
git_config['extra_config_params'] = [
2977-
'submodule."fastahack".active=false',
2978-
'submodule."sha1".active=false',
2979-
]
2980-
expected = '\n'.join([
2981-
' running shell command "git -c submodule."fastahack".active=false -c submodule."sha1".active=false'
2982-
+ ' clone --depth 1 --branch tag_for_tests --recursive'
2983-
+ ' --recurse-submodules=\'!vcflib\' --recurse-submodules=\'!sdsl-lite\' {git_repo}"',
2984-
r" \(in .*/tmp.*\)",
2985-
r"Archiving '.*/{repo_name}' into '{test_prefix}/target/test.tar.xz'...",
2986-
]).format(**string_args, repo_name='testrepository')
2987-
run_check()
2988-
del git_config['recurse_submodules']
2989-
del git_config['extra_config_params']
2990-
2991-
git_config['keep_git_dir'] = True
2992-
expected = '\n'.join([
2993-
r' running shell command "git clone --branch tag_for_tests --recursive {git_repo}"',
2994-
r" \(in .*/tmp.*\)",
2995-
r"Archiving '.*/{repo_name}' into '{test_prefix}/target/test.tar.xz'...",
2996-
]).format(**string_args, repo_name='testrepository')
2997-
run_check()
2998-
del git_config['keep_git_dir']
2999-
3000-
del git_config['tag']
3001-
git_config['commit'] = '8456f86'
3002-
expected = '\n'.join([
3003-
r' running shell command "git clone --no-checkout {git_repo}"',
3004-
r" \(in .*/tmp.*\)",
3005-
r' running shell command "git checkout 8456f86 && git submodule update --init --recursive"',
3006-
r" \(in .*/testrepository\)",
3007-
r"Archiving '.*/{repo_name}' into '{test_prefix}/target/test.tar.xz'...",
3008-
]).format(**string_args, repo_name='testrepository')
3009-
run_check()
3010-
3011-
git_config['recurse_submodules'] = ['!vcflib', '!sdsl-lite']
3012-
expected = '\n'.join([
3013-
r' running shell command "git clone --no-checkout {git_repo}"',
3014-
r" \(in .*/tmp.*\)",
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')
3020-
run_check()
3021-
3022-
del git_config['recursive']
3023-
del git_config['recurse_submodules']
3024-
expected = '\n'.join([
3025-
r' running shell command "git clone --no-checkout {git_repo}"',
3026-
r" \(in /.*\)",
3027-
r' running shell command "git checkout 8456f86"',
3028-
r" \(in /.*/testrepository\)",
3029-
r"Archiving '.*/{repo_name}' into '{test_prefix}/target/test.tar.xz'...",
3030-
]).format(**string_args, repo_name='testrepository')
3031-
run_check()
3032-
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:
2943+
# expected = '\n'.join([
2944+
# r' running shell command "git clone --depth 1 --branch tag_for_tests {git_repo}"',
2945+
# r" \(in .*/tmp.*\)",
2946+
# r"Archiving '.*/{repo_name}' into '{test_prefix}/target/test.tar.xz'...",
2947+
# ]).format(**string_args, repo_name='testrepository')
2948+
# run_check()
2949+
2950+
# git_config['clone_into'] = 'test123'
2951+
# expected = '\n'.join([
2952+
# r' running shell command "git clone --depth 1 --branch tag_for_tests {git_repo} test123"',
2953+
# r" \(in .*/tmp.*\)",
2954+
# r"Archiving '.*/{repo_name}' into '{test_prefix}/target/test.tar.xz'...",
2955+
# ]).format(**string_args, repo_name='test123')
2956+
# run_check()
2957+
# del git_config['clone_into']
2958+
2959+
# git_config['recursive'] = True
2960+
# expected = '\n'.join([
2961+
# r' running shell command "git clone --depth 1 --branch tag_for_tests --recursive {git_repo}"',
2962+
# r" \(in .*/tmp.*\)",
2963+
# r"Archiving '.*/{repo_name}' into '{test_prefix}/target/test.tar.xz'...",
2964+
# ]).format(**string_args, repo_name='testrepository')
2965+
# run_check()
2966+
2967+
# git_config['recurse_submodules'] = ['!vcflib', '!sdsl-lite']
2968+
# expected = '\n'.join([
2969+
# ' running shell command "git clone --depth 1 --branch tag_for_tests --recursive'
2970+
# + ' --recurse-submodules=\'!vcflib\' --recurse-submodules=\'!sdsl-lite\' {git_repo}"',
2971+
# r" \(in .*/tmp.*\)",
2972+
# r"Archiving '.*/{repo_name}' into '{test_prefix}/target/test.tar.xz'...",
2973+
# ]).format(**string_args, repo_name='testrepository')
2974+
# run_check()
2975+
2976+
# git_config['extra_config_params'] = [
2977+
# 'submodule."fastahack".active=false',
2978+
# 'submodule."sha1".active=false',
2979+
# ]
2980+
# expected = '\n'.join([
2981+
# ' running shell command "git -c submodule."fastahack".active=false -c submodule."sha1".active=false'
2982+
# + ' clone --depth 1 --branch tag_for_tests --recursive'
2983+
# + ' --recurse-submodules=\'!vcflib\' --recurse-submodules=\'!sdsl-lite\' {git_repo}"',
2984+
# r" \(in .*/tmp.*\)",
2985+
# r"Archiving '.*/{repo_name}' into '{test_prefix}/target/test.tar.xz'...",
2986+
# ]).format(**string_args, repo_name='testrepository')
2987+
# run_check()
2988+
# del git_config['recurse_submodules']
2989+
# del git_config['extra_config_params']
2990+
2991+
# git_config['keep_git_dir'] = True
2992+
# expected = '\n'.join([
2993+
# r' running shell command "git clone --branch tag_for_tests --recursive {git_repo}"',
2994+
# r" \(in .*/tmp.*\)",
2995+
# r"Archiving '.*/{repo_name}' into '{test_prefix}/target/test.tar.xz'...",
2996+
# ]).format(**string_args, repo_name='testrepository')
2997+
# run_check()
2998+
# del git_config['keep_git_dir']
2999+
3000+
# del git_config['tag']
3001+
# git_config['commit'] = '8456f86'
3002+
# expected = '\n'.join([
3003+
# r' running shell command "git clone --no-checkout {git_repo}"',
3004+
# r" \(in .*/tmp.*\)",
3005+
# r' running shell command "git checkout 8456f86 && git submodule update --init --recursive"',
3006+
# r" \(in .*/testrepository\)",
3007+
# r"Archiving '.*/{repo_name}' into '{test_prefix}/target/test.tar.xz'...",
3008+
# ]).format(**string_args, repo_name='testrepository')
3009+
# run_check()
3010+
3011+
# git_config['recurse_submodules'] = ['!vcflib', '!sdsl-lite']
3012+
# expected = '\n'.join([
3013+
# r' running shell command "git clone --no-checkout {git_repo}"',
3014+
# r" \(in .*/tmp.*\)",
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')
3020+
# run_check()
3021+
3022+
# del git_config['recursive']
3023+
# del git_config['recurse_submodules']
3024+
# expected = '\n'.join([
3025+
# r' running shell command "git clone --no-checkout {git_repo}"',
3026+
# r" \(in /.*\)",
3027+
# r' running shell command "git checkout 8456f86"',
3028+
# r" \(in /.*/testrepository\)",
3029+
# r"Archiving '.*/{repo_name}' into '{test_prefix}/target/test.tar.xz'...",
3030+
# ]).format(**string_args, repo_name='testrepository')
3031+
# run_check()
3032+
3033+
# tarball formats that are not reproducible
3034+
bad_filenames = ['test.tar.gz', 'test.tar.bz2']
3035+
# tarball formats that are reproducible
3036+
good_filenames = ['test.tar', 'test.tar.xz']
3037+
# extensionsless filenames get a default archive compression of XZ
3038+
noext_filename = ['test']
3039+
for test_filename in bad_filenames + good_filenames + noext_filename:
30383040
with self.mocked_stdout_stderr():
30393041
res = ft.get_source_tarball_from_git(test_filename, target_dir, git_config)
30403042
stderr = self.get_stderr()
3041-
regex = re.compile("Ignoring extension of filename.*set in git_config parameter")
3043+
3044+
regex = re.compile("Can not create reproducible archive.*")
30423045
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"))
3046+
self.assertTrue(regex.search(stderr), f"Pattern '{regex.pattern}' found in: {stderr}")
30453047
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+
self.assertFalse(regex.search(stderr), f"Pattern '{regex.pattern}' found in: {stderr}")
3049+
3050+
ref_filename = f"{test_filename}.tar.xz" if test_filename in noext_filename else test_filename
3051+
self.assertTrue(res.endswith(ref_filename))
3052+
3053+
# non-tarball formats are not supported
3054+
with self.mocked_stdout_stderr():
3055+
self.assertRaises(EasyBuildError, ft.get_source_tarball_from_git, 'test.zip', target_dir, git_config)
30483056

30493057
# Test with real data.
30503058
init_config()

0 commit comments

Comments
 (0)