Skip to content

Commit 4ee8053

Browse files
committed
Attempt to extract tar on Mac as bytes #688
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
1 parent 0ed7c87 commit 4ee8053

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

tests/scancode/test_cli.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
# from click.testing import CliRunner
3737

3838
from commoncode import fileutils
39+
from commoncode.fileutils import path_to_bytes
3940
from commoncode.testcase import FileDrivenTesting
4041
from commoncode.system import on_linux
4142
from commoncode.system import on_mac
@@ -47,8 +48,6 @@
4748
from scancode.cli_test_utils import run_scan_plain
4849

4950
from scancode import cli
50-
from commoncode.fileutils import path_to_bytes
51-
from commoncode.fileutils import path_to_unicode
5251

5352

5453
test_env = FileDrivenTesting()
@@ -207,23 +206,23 @@ def test_scan_mark_source_without_info(monkeypatch):
207206
result_file = test_env.get_temp_file('json')
208207
expected_file = test_env.get_test_loc('mark_source/without_info.expected.json')
209208

210-
result = run_scan_click(['--mark-source', test_dir, result_file], monkeypatch)
209+
_result = run_scan_click(['--mark-source', test_dir, result_file], monkeypatch)
211210
check_json_scan(expected_file, result_file)
212211

213212
def test_scan_mark_source_with_info(monkeypatch):
214213
test_dir = test_env.extract_test_tar('mark_source/JGroups.tgz')
215214
result_file = test_env.get_temp_file('json')
216215
expected_file = test_env.get_test_loc('mark_source/with_info.expected.json')
217216

218-
result = run_scan_click(['--info', '--mark-source', test_dir, result_file], monkeypatch)
217+
_result = run_scan_click(['--info', '--mark-source', test_dir, result_file], monkeypatch)
219218
check_json_scan(expected_file, result_file)
220219

221220
def test_scan_only_findings(monkeypatch):
222221
test_dir = test_env.extract_test_tar('info/basic.tgz')
223222
result_file = test_env.get_temp_file('json')
224223
expected_file = test_env.get_test_loc('only_findings/expected.json')
225224

226-
result = run_scan_click(['--only-findings', test_dir, result_file], monkeypatch)
225+
_result = run_scan_click(['--only-findings', test_dir, result_file], monkeypatch)
227226
check_json_scan(expected_file, result_file)
228227

229228

@@ -452,13 +451,17 @@ def test_scan_does_not_fail_when_scanning_unicode_files_and_paths():
452451
check_json_scan(test_env.get_test_loc(expected), result_file, strip_dates=True, regen=False)
453452

454453

455-
@skipIf(on_windows, 'Tar cannot extract some files on Windows')
454+
@skipIf(on_windows, 'Python tar cannot extract these files on Windows')
456455
def test_scan_does_not_fail_when_scanning_unicode_test_files_from_express():
457-
if on_linux:
458-
test_dir = test_env.extract_test_tar_raw(b'unicode_fixtures.tar.gz')
459-
test_dir = path_to_bytes(test_dir)
460-
else:
461-
test_dir = test_env.extract_test_tar_unicode('unicode_fixtures.tar.gz')
456+
457+
# On Windows, Python tar cannot extract these files. Other
458+
# extractors either fail or change the file name, making the test
459+
# moot. Git cannot check these files. So for now it makes no sense
460+
# to test this on Windows at all. Extractcode works fine, but does
461+
# rename the problematic files.
462+
463+
test_dir = test_env.extract_test_tar_raw(b'unicode_fixtures.tar.gz')
464+
test_dir = path_to_bytes(test_dir)
462465

463466
args = ['-n0', '--info', '--license', '--copyright',
464467
'--package', '--email', '--url', '--strip-root',

0 commit comments

Comments
 (0)