From 2a00b47311fbb9d3db6a42249982380990071e4e Mon Sep 17 00:00:00 2001 From: Ayan Sinha Mahapatra Date: Mon, 30 Aug 2021 01:02:38 +0530 Subject: [PATCH 01/10] Introduce output data format versioning #2653 Add output data format version numbers to the headers and version help text. Introduce new command line option to switch to the new experimental data format. Signed-off-by: Ayan Sinha Mahapatra --- src/scancode/cli.py | 13 +++++++++++++ src/scancode_config.py | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/src/scancode/cli.py b/src/scancode/cli.py index c6fdd7e2b1f..2ce49298b24 100644 --- a/src/scancode/cli.py +++ b/src/scancode/cli.py @@ -94,6 +94,7 @@ def print_version(ctx, param, value): if not value or ctx.resilient_parsing: return click.echo('ScanCode version ' + scancode_config.__version__) + click.echo('ScanCode Data-format version ' + scancode_config.__output_format_version__) ctx.exit() @@ -249,6 +250,13 @@ def validate_depth(ctx, param, value): 'the starting directory. Use 0 for no scan depth limit.', help_group=cliutils.CORE_GROUP, sort_order=301, cls=PluggableCommandLineOption) +@click.option('--next-data-format', + is_flag=True, + help='Output the next experimental data format, for JSON and YAML output.' + 'See CHANGELOG for more details on the changes in this experimental data format.', + help_group=cliutils.OUTPUT_GROUP, sort_order=28, cls=PluggableCommandLineOption) + + @click.help_option('-h', '--help', help_group=cliutils.DOC_GROUP, sort_order=10, cls=PluggableCommandLineOption) @@ -337,6 +345,7 @@ def scancode( verbose, max_depth, from_json, + next_data_format, timing, max_in_memory, test_mode, @@ -439,6 +448,7 @@ def scancode( quiet=quiet, verbose=verbose, max_depth=max_depth, + next_data_format=next_data_format, timing=timing, max_in_memory=max_in_memory, test_mode=test_mode, @@ -474,6 +484,7 @@ def scancode( def run_scan( input, # NOQA from_json=False, + next_data_format=False, strip_root=False, full_root=False, max_in_memory=10000, @@ -580,6 +591,7 @@ def echo_func(*_args, **_kwargs): quiet=quiet, verbose=verbose, from_json=from_json, + next_data_format=next_data_format, timing=timing, max_in_memory=max_in_memory, test_mode=test_mode, @@ -828,6 +840,7 @@ def echo_func(*_args, **_kwargs): cle.start_timestamp = start_timestamp cle.tool_name = 'scancode-toolkit' cle.tool_version = scancode_config.__version__ + cle.output_format_version = scancode_config.__output_format_version__ cle.notice = notice cle.options = pretty_params or {} diff --git a/src/scancode_config.py b/src/scancode_config.py index e560e1e18f3..02ba5a60f58 100644 --- a/src/scancode_config.py +++ b/src/scancode_config.py @@ -75,6 +75,11 @@ def _create_dir(location): # in case package is not installed or we do not have setutools/pkg_resources # on hand fall back to this version __version__ = '21.8.4' + +# See https://github.com/nexB/scancode-toolkit/issues/2653 for more information +# on the data format version +__output_format_version__ = '1.1' + try: from pkg_resources import get_distribution, DistributionNotFound try: From e332074159db7a77d5d7b1a44bf8c9b77bc42bfa Mon Sep 17 00:00:00 2001 From: Ayan Sinha Mahapatra Date: Tue, 31 Aug 2021 02:55:54 +0530 Subject: [PATCH 02/10] Modify tests to ignore headers Modifies tests to ignore addition of output data format in headers. Signed-off-by: Ayan Sinha Mahapatra --- tests/cluecode/test_plugin_email_url.py | 8 +-- .../cluecode/test_plugin_ignore_copyrights.py | 4 +- tests/formattedcode/test_output_json.py | 8 +-- tests/formattedcode/test_output_jsonlines.py | 2 +- tests/licensedcode/test_plugin_license.py | 16 +++--- .../licensedcode/test_plugin_license_text.py | 2 +- tests/packagedcode/test_build.py | 4 +- tests/packagedcode/test_plugin.py | 52 +++++++++---------- tests/scancode/test_cli.py | 28 +++++----- 9 files changed, 62 insertions(+), 62 deletions(-) diff --git a/tests/cluecode/test_plugin_email_url.py b/tests/cluecode/test_plugin_email_url.py index 750acfaeda6..d5994597349 100644 --- a/tests/cluecode/test_plugin_email_url.py +++ b/tests/cluecode/test_plugin_email_url.py @@ -25,7 +25,7 @@ def test_scan_email(): result_file = test_env.get_temp_file('json') args = ['--email', '--strip-root', test_dir, '--json', result_file] run_scan_click(args) - check_json_scan(test_env.get_test_loc('plugin_email_url/emails.expected.json'), result_file) + check_json_scan(test_env.get_test_loc('plugin_email_url/emails.expected.json'), result_file, ignore_headers=True) def test_scan_email_with_threshold(): @@ -33,7 +33,7 @@ def test_scan_email_with_threshold(): result_file = test_env.get_temp_file('json') args = ['--email', '--strip-root', '--max-email', '2', test_dir, '--json', result_file] run_scan_click(args) - check_json_scan(test_env.get_test_loc('plugin_email_url/emails-threshold.expected.json'), result_file) + check_json_scan(test_env.get_test_loc('plugin_email_url/emails-threshold.expected.json'), result_file, ignore_headers=True) def test_scan_url(): @@ -41,7 +41,7 @@ def test_scan_url(): result_file = test_env.get_temp_file('json') args = ['--url', '--strip-root', test_dir, '--json', result_file] run_scan_click(args) - check_json_scan(test_env.get_test_loc('plugin_email_url/urls.expected.json'), result_file) + check_json_scan(test_env.get_test_loc('plugin_email_url/urls.expected.json'), result_file, ignore_headers=True) def test_scan_url_with_threshold(): @@ -49,4 +49,4 @@ def test_scan_url_with_threshold(): result_file = test_env.get_temp_file('json') args = ['--url', '--strip-root', '--max-url', '2', test_dir, '--json', result_file] run_scan_click(args) - check_json_scan(test_env.get_test_loc('plugin_email_url/urls-threshold.expected.json'), result_file) + check_json_scan(test_env.get_test_loc('plugin_email_url/urls-threshold.expected.json'), result_file, ignore_headers=True) diff --git a/tests/cluecode/test_plugin_ignore_copyrights.py b/tests/cluecode/test_plugin_ignore_copyrights.py index 1902a0df9b9..f247b232186 100644 --- a/tests/cluecode/test_plugin_ignore_copyrights.py +++ b/tests/cluecode/test_plugin_ignore_copyrights.py @@ -37,11 +37,11 @@ def test_ignore_holders(self): result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin_ignore_copyrights/holders.expected.json') run_scan_click(['-c', '--ignore-copyright-holder', 'Regents', '--json-pp', result_file, test_dir]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) def test_ignore_authors(self): test_dir = self.extract_test_tar('plugin_ignore_copyrights/basic.tgz') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin_ignore_copyrights/authors.expected.json') run_scan_click(['-c', '--ignore-author', 'Berkeley', '--json-pp', result_file, test_dir]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) diff --git a/tests/formattedcode/test_output_json.py b/tests/formattedcode/test_output_json.py index 815eca3a65f..91bf46592ca 100644 --- a/tests/formattedcode/test_output_json.py +++ b/tests/formattedcode/test_output_json.py @@ -27,7 +27,7 @@ def test_json_pretty_print(): args = ['-clip', test_dir, '--json-pp', result_file] run_scan_click(args) expected = test_env.get_test_loc('json/simple-expected.jsonpp') - check_json_scan(expected, result_file, remove_file_date=True, regen=False) + check_json_scan(expected, result_file, remove_file_date=True, regen=False, ignore_headers=True) def test_json_compact(): @@ -37,7 +37,7 @@ def test_json_compact(): with open(result_file, 'rb') as res: assert len(res.read().splitlines()) == 1 expected = test_env.get_test_loc('json/simple-expected.json') - check_json_scan(expected, result_file, remove_file_date=True, regen=False) + check_json_scan(expected, result_file, remove_file_date=True, regen=False, ignore_headers=True) @pytest.mark.scanslow @@ -46,7 +46,7 @@ def test_scan_output_does_not_truncate_copyright_json(): result_file = test_env.get_temp_file('test.json') run_scan_click(['-clip', '--strip-root', test_dir, '--json-pp', result_file]) expected = test_env.get_test_loc('json/tree/expected.json') - check_json_scan(expected, result_file, remove_file_date=True, regen=False) + check_json_scan(expected, result_file, remove_file_date=True, regen=False, ignore_headers=True) @pytest.mark.scanslow @@ -56,7 +56,7 @@ def test_scan_output_does_not_truncate_copyright_with_json_to_stdout(): args = ['-clip', '--strip-root', test_dir, '--json-pp', result_file] run_scan_click(args) expected = test_env.get_test_loc('json/tree/expected.json') - check_json_scan(expected, result_file, remove_file_date=True, regen=False) + check_json_scan(expected, result_file, remove_file_date=True, regen=False, ignore_headers=True) @pytest.mark.scanslow diff --git a/tests/formattedcode/test_output_jsonlines.py b/tests/formattedcode/test_output_jsonlines.py index 657ab23461b..926722feeea 100644 --- a/tests/formattedcode/test_output_jsonlines.py +++ b/tests/formattedcode/test_output_jsonlines.py @@ -28,7 +28,7 @@ def test_jsonlines(): expected = test_env.get_test_loc('json/simple-expected.jsonlines') check_jsonlines_scan( test_env.get_test_loc(expected), result_file, - remove_file_date=True, regen=False) + remove_file_date=True, regen=False, ignore_headers=True) def test_jsonlines_with_timing(): diff --git a/tests/licensedcode/test_plugin_license.py b/tests/licensedcode/test_plugin_license.py index 53dbf37cee0..d5fd0425e6c 100644 --- a/tests/licensedcode/test_plugin_license.py +++ b/tests/licensedcode/test_plugin_license.py @@ -29,7 +29,7 @@ def test_license_option_reports_license_expressions(): args = ['--license', '--strip-root', test_dir, '--json', result_file, '--verbose'] run_scan_click(args) test_loc = test_env.get_test_loc('plugin_license/license-expression/scan.expected.json') - check_json_scan(test_loc, result_file, regen=False) + check_json_scan(test_loc, result_file, regen=False, ignore_headers=True) def test_license_option_reports_license_texts(): @@ -38,7 +38,7 @@ def test_license_option_reports_license_texts(): args = ['--license', '--license-text', '--strip-root', test_dir, '--json', result_file, '--verbose'] run_scan_click(args) test_loc = test_env.get_test_loc('plugin_license/text/scan.expected.json') - check_json_scan(test_loc, result_file, regen=False) + check_json_scan(test_loc, result_file, regen=False, ignore_headers=True) def test_license_option_reports_license_texts_diag(): @@ -47,7 +47,7 @@ def test_license_option_reports_license_texts_diag(): args = ['--license', '--license-text', '--license-text-diagnostics', '--strip-root', test_dir, '--json', result_file, '--verbose'] run_scan_click(args) test_loc = test_env.get_test_loc('plugin_license/text/scan-diag.expected.json') - check_json_scan(test_loc, result_file, regen=False) + check_json_scan(test_loc, result_file, regen=False, ignore_headers=True) def test_license_option_reports_license_texts_long_lines(): @@ -56,7 +56,7 @@ def test_license_option_reports_license_texts_long_lines(): args = ['--license', '--license-text', '--strip-root', test_dir, '--json', result_file, '--verbose'] run_scan_click(args) test_loc = test_env.get_test_loc('plugin_license/text_long_lines/scan.expected.json') - check_json_scan(test_loc, result_file, regen=False) + check_json_scan(test_loc, result_file, regen=False, ignore_headers=True) def test_license_option_reports_license_texts_diag_long_lines(): @@ -65,7 +65,7 @@ def test_license_option_reports_license_texts_diag_long_lines(): args = ['--license', '--license-text', '--license-text-diagnostics', '--strip-root', test_dir, '--json', result_file, '--verbose'] run_scan_click(args) test_loc = test_env.get_test_loc('plugin_license/text_long_lines/scan-diag.expected.json') - check_json_scan(test_loc, result_file, regen=False) + check_json_scan(test_loc, result_file, regen=False, ignore_headers=True) def test_reindex_licenses_works(): @@ -81,7 +81,7 @@ def test_scan_license_with_url_template(): test_dir, '--json-pp', result_file] test_loc = test_env.get_test_loc('plugin_license/license_url.expected.json') run_scan_click(args) - check_json_scan(test_loc, result_file) + check_json_scan(test_loc, result_file, ignore_headers=True) @pytest.mark.scanslow @@ -91,7 +91,7 @@ def test_detection_does_not_timeout_on_sqlite3_amalgamation(): expected_file = test_env.get_test_loc('plugin_license/sqlite/sqlite.expected.json') # we use the default 120 seconds timeout run_scan_click(['-l', '--license-text', '--json-pp', result_file, test_dir]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) @pytest.mark.scanslow @@ -100,4 +100,4 @@ def test_detection_is_correct_in_legacy_npm_package_json(): result_file = test_env.get_temp_file('json') expected_file = test_env.get_test_loc('plugin_license/package/package.expected.json') run_scan_click(['-lp', '--json-pp', result_file, test_dir]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) diff --git a/tests/licensedcode/test_plugin_license_text.py b/tests/licensedcode/test_plugin_license_text.py index 1040421c7f4..3709a5b1c5d 100644 --- a/tests/licensedcode/test_plugin_license_text.py +++ b/tests/licensedcode/test_plugin_license_text.py @@ -33,4 +33,4 @@ def test_is_licensing_works(): test_dir, '--json-pp', result_file, '--verbose'] run_scan_click(args) check_json_scan(test_env.get_test_loc('plugin_license_text/scan.expected.json'), - result_file, remove_file_date=True, regen=False) + result_file, remove_file_date=True, regen=False, ignore_headers=True) diff --git a/tests/packagedcode/test_build.py b/tests/packagedcode/test_build.py index ad0a0cafdef..d158a347b11 100644 --- a/tests/packagedcode/test_build.py +++ b/tests/packagedcode/test_build.py @@ -25,14 +25,14 @@ def test_end2end_scan_can_detect_bazel(self): expected_file = self.get_test_loc('bazel/end2end-expected.json') result_file = self.get_temp_file('results.json') run_scan_click(['--package', test_file, '--json-pp', result_file]) - check_json_scan(expected_file, result_file, regen=False) + check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) def test_end2end_scan_can_detect_buck(self): test_file = self.get_test_loc('buck/end2end') expected_file = self.get_test_loc('buck/end2end-expected.json') result_file = self.get_temp_file('results.json') run_scan_click(['--package', test_file, '--json-pp', result_file]) - check_json_scan(expected_file, result_file, regen=False) + check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) def test_build_get_package_resources(self): test_loc = self.get_test_loc('get_package_resources') diff --git a/tests/packagedcode/test_plugin.py b/tests/packagedcode/test_plugin.py index 7a23a9e7a96..848acd3726a 100644 --- a/tests/packagedcode/test_plugin.py +++ b/tests/packagedcode/test_plugin.py @@ -33,179 +33,179 @@ def test_package_command_scan_python(self): result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/python-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False) + check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) def test_package_command_scan_maven(self): test_dir = self.get_test_loc('maven2') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/maven-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False) + check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) def test_package_command_scan_about(self): test_dir = self.get_test_loc('about') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/about-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False) + check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) def test_package_command_scan_bower(self): test_dir = self.get_test_loc('bower/package') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/bower-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False) + check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) def test_package_command_scan_cargo(self): test_dir = self.get_test_loc('cargo/package') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/cargo-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False) + check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) def test_package_command_scan_chef(self): test_dir = self.get_test_loc('chef/package') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/chef-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False) + check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) def test_package_command_scan_conda(self): test_dir = self.get_test_loc('conda/package') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/conda-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False) + check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) def test_package_command_scan_freebsd(self): test_dir = self.get_test_loc('freebsd/package') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/freebsd-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False) + check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) def test_package_command_scan_haxe(self): test_dir = self.get_test_loc('haxe/package') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/haxe-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False) + check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) def test_package_command_scan_npm(self): test_dir = self.get_test_loc('npm/package') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/npm-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False) + check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) def test_package_command_scan_nuget(self): test_dir = self.get_test_loc('nuget/package') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/nuget-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False) + check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) def test_package_command_scan_opam(self): test_dir = self.get_test_loc('opam/package') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/opam-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False) + check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) def test_package_command_scan_phpcomposer(self): test_dir = self.get_test_loc('phpcomposer/package') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/phpcomposer-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False) + check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) def test_package_command_scan_rubygems(self): test_dir = self.get_test_loc('rubygems/package') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/rubygems-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False) + check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) def test_package_command_scan_rpm(self): test_dir = self.get_test_loc('rpm/package') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/rpm-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False) + check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) def test_package_command_scan_cran_r_package(self): test_dir = self.get_test_loc('cran/package') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/cran-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False) + check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) def test_package_command_scan_win_pe(self): test_dir = self.get_test_loc('win_pe/file.exe') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/win_pe-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False) + check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) def test_package_command_scan_mum(self): test_dir = self.get_test_loc('windows/mum/test.mum') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/mum-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False) + check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) def test_package_command_scan_pubspec_package(self): test_dir = self.get_test_loc('pubspec/specs/authors-pubspec.yaml') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/pubspec-expected.json', must_exist=False) run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False) + check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) def test_package_command_scan_pubspec_lock_package(self): test_dir = self.get_test_loc('pubspec/locks/dart-pubspec.lock') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/pubspec-lock-expected.json', must_exist=False) run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False) + check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) def test_package_command_scan_mui(self): test_dir = self.get_test_loc('win_pe/clfs.sys.mui') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/mui-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False) + check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) def test_package_command_scan_mun(self): test_dir = self.get_test_loc('win_pe/crypt32.dll.mun') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/mun-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False) + check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) def test_package_command_scan_com(self): test_dir = self.get_test_loc('win_pe/chcp.com') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/com-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False) + check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) def test_package_command_scan_tlb(self): test_dir = self.get_test_loc('win_pe/stdole2.tlb') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/tlb-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False) + check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) def test_package_command_scan_sys(self): test_dir = self.get_test_loc('win_pe/tbs.sys') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/sys-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False) + check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) def test_package_command_scan_winmd(self): test_dir = self.get_test_loc('win_pe/Windows.AI.winmd') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/winmd-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False) + check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) diff --git a/tests/scancode/test_cli.py b/tests/scancode/test_cli.py index 394ae2f5acd..8225294bdbd 100644 --- a/tests/scancode/test_cli.py +++ b/tests/scancode/test_cli.py @@ -134,7 +134,7 @@ def test_scan_info_does_collect_info(): args = ['--info', '--strip-root', test_dir, '--json', result_file] run_scan_click(args) expected = test_env.get_test_loc('info/basic.expected.json') - check_json_scan(expected, result_file, regen=False) + check_json_scan(expected, result_file, regen=False, ignore_headers=True) def test_scan_info_does_collect_info_with_root(): @@ -142,7 +142,7 @@ def test_scan_info_does_collect_info_with_root(): result_file = test_env.get_temp_file('json') run_scan_click(['--info', test_dir, '--json', result_file]) expected = test_env.get_test_loc('info/basic.rooted.expected.json') - check_json_scan(expected, result_file, regen=False) + check_json_scan(expected, result_file, regen=False, ignore_headers=True) def test_scan_info_returns_full_root(): @@ -177,7 +177,7 @@ def test_scan_info_returns_does_not_strip_root_with_single_file(): args = ['--info', '--strip-root', test_file, '--json', result_file] run_scan_click(args) expected = test_env.get_test_loc('single/iproute.expected.json') - check_json_scan(expected, result_file, remove_file_date=True, regen=False) + check_json_scan(expected, result_file, remove_file_date=True, regen=False, ignore_headers=True) @pytest.mark.scanslow @@ -186,7 +186,7 @@ def test_scan_info_license_copyrights(): result_file = test_env.get_temp_file('json') args = ['--info', '--license', '--copyright', '--strip-root', test_dir, '--json', result_file] run_scan_click(args) - check_json_scan(test_env.get_test_loc('info/all.expected.json'), result_file, regen=False) + check_json_scan(test_env.get_test_loc('info/all.expected.json'), result_file, regen=False, ignore_headers=True) def test_scan_noinfo_license_copyrights_with_root(): @@ -195,7 +195,7 @@ def test_scan_noinfo_license_copyrights_with_root(): args = ['--email', '--url', '--license', '--copyright', test_dir, '--json', result_file] run_scan_click(args) expected = test_env.get_test_loc('info/all.rooted.expected.json') - check_json_scan(expected, result_file, regen=False) + check_json_scan(expected, result_file, regen=False, ignore_headers=True) def test_scan_email_url_info(): @@ -204,7 +204,7 @@ def test_scan_email_url_info(): args = ['--email', '--url', '--info', '--strip-root', test_dir, '--json', result_file] run_scan_click(args) expected = test_env.get_test_loc('info/email_url_info.expected.json') - check_json_scan(expected, result_file, regen=False) + check_json_scan(expected, result_file, regen=False, ignore_headers=True) def test_scan_should_not_fail_on_faulty_pdf_or_pdfminer_bug_but_instead_keep_trucking_with_json(): @@ -213,7 +213,7 @@ def test_scan_should_not_fail_on_faulty_pdf_or_pdfminer_bug_but_instead_keep_tru args = ['--copyright', '--strip-root', test_file, '--json', result_file] result = run_scan_click(args, expected_rc=0) expected = test_env.get_test_loc('failing/patchelf.expected.json') - check_json_scan(expected, result_file, regen=False) + check_json_scan(expected, result_file, regen=False, ignore_headers=True) assert 'Some files failed to scan' not in result.output assert 'patchelf.pdf' not in result.output @@ -393,7 +393,7 @@ def check_scan_does_not_fail_when_scanning_unicode_files_and_paths(verbosity): elif on_windows: expected = 'unicodepath/unicodepath.expected-win.json' + verbosity - check_json_scan(test_env.get_test_loc(expected), result_file, remove_file_date=True, regen=False) + check_json_scan(test_env.get_test_loc(expected), result_file, remove_file_date=True, regen=False, ignore_headers=True) return results @@ -477,7 +477,7 @@ def test_scan_can_return_matched_license_text(): result_file = test_env.get_temp_file('json') args = ['--license', '--license-text', '--strip-root', test_file, '--json', result_file] run_scan_click(args) - check_json_scan(test_env.get_test_loc(expected_file), result_file, regen=False) + check_json_scan(test_env.get_test_loc(expected_file), result_file, regen=False, ignore_headers=True) @pytest.mark.skipif(on_windows, reason='This test cannot run on windows as these are not legal file names.') @@ -491,7 +491,7 @@ def test_scan_can_handle_weird_file_names(): # Some info vary on each OS # See https://github.com/nexB/scancode-toolkit/issues/438 for details expected = 'weird_file_name/expected-posix.json' - check_json_scan(test_env.get_test_loc(expected), result_file, regen=False) + check_json_scan(test_env.get_test_loc(expected), result_file, regen=False, ignore_headers=True) @pytest.mark.skipif(on_macos_14_or_higher or on_windows, @@ -516,7 +516,7 @@ def test_scan_can_handle_non_utf8_file_names_on_posix(): elif on_windows: expected = 'non_utf8/expected-win.json' - check_json_scan(test_env.get_test_loc(expected), result_file, regen=False) + check_json_scan(test_env.get_test_loc(expected), result_file, regen=False, ignore_headers=True) def test_scan_can_run_from_other_directory(): @@ -526,7 +526,7 @@ def test_scan_can_run_from_other_directory(): work_dir = os.path.dirname(result_file) args = ['-ci', '--strip-root', test_file, '--json', result_file] run_scan_plain(args, cwd=work_dir) - check_json_scan(test_env.get_test_loc(expected_file), result_file, remove_file_date=True, regen=False) + check_json_scan(test_env.get_test_loc(expected_file), result_file, remove_file_date=True, regen=False, ignore_headers=True) def test_scan_logs_errors_messages_not_verbosely_on_stderr(): @@ -640,7 +640,7 @@ def test_scan_does_scan_php_composer(): expected_file = test_env.get_test_loc('composer/composer.expected.json') result_file = test_env.get_temp_file('results.json') run_scan_click(['--package', test_file, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False) + check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) def test_scan_does_scan_rpm(): @@ -648,7 +648,7 @@ def test_scan_does_scan_rpm(): expected_file = test_env.get_test_loc('rpm/fping-2.4-0.b2.rhfc1.dag.i386.rpm.expected.json') result_file = test_env.get_temp_file('results.json') run_scan_click(['--package', test_file, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False) + check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) def test_scan_cli_help(regen=False): From 12578cfbf5978d0e66d93189d3d1612ad9dc8fc6 Mon Sep 17 00:00:00 2001 From: Ayan Sinha Mahapatra Date: Wed, 1 Sep 2021 19:53:42 +0530 Subject: [PATCH 03/10] Bump commoncode to have header changes Signed-off-by: Ayan Sinha Mahapatra --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index c6aae019a27..af22067aad8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,7 +9,7 @@ cffi==1.14.5 chardet==4.0.0 click==8.0.1 colorama==0.4.4 -commoncode==21.7.23 +commoncode==21.8.31 construct==2.10.67 cryptography==3.4.7 debian-inspector==21.5.25 From 9bd8bc5b8ebe2f3861c9ded439d642031fa32c44 Mon Sep 17 00:00:00 2001 From: Ayan Sinha Mahapatra Date: Wed, 1 Sep 2021 21:06:19 +0530 Subject: [PATCH 04/10] Rename flag name to --future-format Renames flag to --future-format and updates help text test. Adds future format version. Signed-off-by: Ayan Sinha Mahapatra --- src/scancode/cli.py | 15 ++++++++------- src/scancode_config.py | 2 ++ tests/scancode/data/help/help.txt | 11 +++++++---- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/scancode/cli.py b/src/scancode/cli.py index e13ad87794a..56e7926f620 100644 --- a/src/scancode/cli.py +++ b/src/scancode/cli.py @@ -94,7 +94,8 @@ def print_version(ctx, param, value): if not value or ctx.resilient_parsing: return click.echo('ScanCode version ' + scancode_config.__version__) - click.echo('ScanCode Data-format version ' + scancode_config.__output_format_version__) + click.echo('Output Format version ' + scancode_config.__output_format_version__) + click.echo('Future Output Format version ' + scancode_config.__future_output_format_version__) ctx.exit() @@ -250,11 +251,11 @@ def validate_depth(ctx, param, value): 'the starting directory. Use 0 for no scan depth limit.', help_group=cliutils.CORE_GROUP, sort_order=301, cls=PluggableCommandLineOption) -@click.option('--next-data-format', +@click.option('--future-format', is_flag=True, help='Output the next experimental data format, for JSON and YAML output.' 'See CHANGELOG for more details on the changes in this experimental data format.', - help_group=cliutils.OUTPUT_GROUP, sort_order=28, cls=PluggableCommandLineOption) + help_group=cliutils.OUTPUT_CONTROL_GROUP, sort_order=28, cls=PluggableCommandLineOption) @click.help_option('-h', '--help', @@ -353,7 +354,7 @@ def scancode( verbose, max_depth, from_json, - next_data_format, + future_format, timing, max_in_memory, test_mode, @@ -457,7 +458,7 @@ def scancode( quiet=quiet, verbose=verbose, max_depth=max_depth, - next_data_format=next_data_format, + future_format=future_format, timing=timing, max_in_memory=max_in_memory, test_mode=test_mode, @@ -494,7 +495,7 @@ def scancode( def run_scan( input, # NOQA from_json=False, - next_data_format=False, + future_format=False, strip_root=False, full_root=False, max_in_memory=10000, @@ -601,7 +602,7 @@ def echo_func(*_args, **_kwargs): quiet=quiet, verbose=verbose, from_json=from_json, - next_data_format=next_data_format, + future_format=future_format, timing=timing, max_in_memory=max_in_memory, test_mode=test_mode, diff --git a/src/scancode_config.py b/src/scancode_config.py index 02ba5a60f58..a32cfdfa5aa 100644 --- a/src/scancode_config.py +++ b/src/scancode_config.py @@ -79,6 +79,8 @@ def _create_dir(location): # See https://github.com/nexB/scancode-toolkit/issues/2653 for more information # on the data format version __output_format_version__ = '1.1' +__future_output_format_version__ = '1.1' + try: from pkg_resources import get_distribution, DistributionNotFound diff --git a/tests/scancode/data/help/help.txt b/tests/scancode/data/help/help.txt index ece0573792d..17bbea58733 100644 --- a/tests/scancode/data/help/help.txt +++ b/tests/scancode/data/help/help.txt @@ -70,10 +70,13 @@ Options: is not treated as findings). output control: - --full-root Report full, absolute paths. - --strip-root Strip the root directory segment of all paths. The default is to - always include the last directory segment of the scanned path - such that all paths have a common root directory. + --future-format Output the next experimental data format, for JSON and YAML + output.See CHANGELOG for more details on the changes in this + experimental data format. + --full-root Report full, absolute paths. + --strip-root Strip the root directory segment of all paths. The default is to + always include the last directory segment of the scanned path + such that all paths have a common root directory. pre-scan: --ignore Ignore files matching . From 588ac9d72297e61924f2191835fafd6f95211865 Mon Sep 17 00:00:00 2001 From: Ayan Sinha Mahapatra Date: Wed, 1 Sep 2021 22:03:18 +0530 Subject: [PATCH 05/10] Update more tests to ignore headers Signed-off-by: Ayan Sinha Mahapatra --- src/scancode/cli_test_utils.py | 5 ++++ tests/licensedcode/test_plugin_license.py | 4 ++-- tests/scancode/test_plugin_mark_source.py | 2 +- tests/scancode/test_plugin_only_findings.py | 6 ++--- tests/summarycode/test_classify.py | 2 +- tests/summarycode/test_facet.py | 2 +- tests/summarycode/test_generated.py | 2 +- tests/summarycode/test_plugin_consolidate.py | 10 ++++---- tests/summarycode/test_score.py | 4 +++- tests/summarycode/test_summarizer.py | 24 ++++++++++---------- 10 files changed, 34 insertions(+), 27 deletions(-) diff --git a/src/scancode/cli_test_utils.py b/src/scancode/cli_test_utils.py index 604cc468b4e..584a28435f0 100644 --- a/src/scancode/cli_test_utils.py +++ b/src/scancode/cli_test_utils.py @@ -289,6 +289,7 @@ def check_jsonlines_scan( result_file, regen=False, remove_file_date=False, + ignore_headers=False, ): """ Check the scan result_file JSON Lines results against the expected_file @@ -311,6 +312,10 @@ def check_jsonlines_scan( expected = json.load(res) streamline_jsonlines_scan(expected, remove_file_date) + + if ignore_headers: + results[0].pop('headers', None) + expected[0].pop('headers', None) expected = json.dumps(expected, indent=2, separators=(',', ': ')) results = json.dumps(results, indent=2, separators=(',', ': ')) diff --git a/tests/licensedcode/test_plugin_license.py b/tests/licensedcode/test_plugin_license.py index 4e3ae0bbb35..acbc868d1f8 100644 --- a/tests/licensedcode/test_plugin_license.py +++ b/tests/licensedcode/test_plugin_license.py @@ -78,7 +78,7 @@ def test_license_match_reference(): args = ['--license', '--license-text', '--license-text-diagnostics', '--strip-root', test_dir, '--json', result_file, '--verbose'] run_scan_click(args) test_loc = test_env.get_test_loc('plugin_license/license_reference/scan-ref.expected.json') - check_json_scan(test_loc, result_file, regen=False) + check_json_scan(test_loc, result_file, regen=False, ignore_headers=True) def test_license_match_without_reference(): @@ -87,7 +87,7 @@ def test_license_match_without_reference(): args = ['--license', '--license-text', '--license-text-diagnostics', '--strip-root', test_dir, '--json', result_file, '--verbose'] run_scan_click(args) test_loc = test_env.get_test_loc('plugin_license/license_reference/scan-wref.expected.json') - check_json_scan(test_loc, result_file, regen=False) + check_json_scan(test_loc, result_file, regen=False, ignore_headers=True) def test_get_referenced_filenames(): diff --git a/tests/scancode/test_plugin_mark_source.py b/tests/scancode/test_plugin_mark_source.py index d30b19c3c05..ad842f9095a 100644 --- a/tests/scancode/test_plugin_mark_source.py +++ b/tests/scancode/test_plugin_mark_source.py @@ -42,4 +42,4 @@ def test_scan_mark_source_with_info(self): result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin_mark_source/with_info.expected.json') run_scan_click(['--info', '--mark-source', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False) + check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) diff --git a/tests/scancode/test_plugin_only_findings.py b/tests/scancode/test_plugin_only_findings.py index 5fe2678b310..c506024511b 100644 --- a/tests/scancode/test_plugin_only_findings.py +++ b/tests/scancode/test_plugin_only_findings.py @@ -27,7 +27,7 @@ def test_scan_only_findings(self): result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin_only_findings/basic.expected.json') run_scan_click(['-clip', '--only-findings', '--json', result_file, test_dir]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) def test_scan_only_findings_with_errors(self): test_file = self.get_test_loc('plugin_only_findings/errors.json') @@ -35,11 +35,11 @@ def test_scan_only_findings_with_errors(self): expected_file = self.get_test_loc('plugin_only_findings/errors.expected.json') run_scan_click(['--from-json', test_file, '--only-findings', '--json-pp', result_file]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) def test_scan_only_findings_with_only_info(self): test_dir = self.extract_test_tar('plugin_only_findings/basic.tgz') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin_only_findings/info.expected.json') run_scan_click(['--info', '--only-findings', '--json', result_file, test_dir]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) diff --git a/tests/summarycode/test_classify.py b/tests/summarycode/test_classify.py index caef5f40011..0b68cf335b6 100644 --- a/tests/summarycode/test_classify.py +++ b/tests/summarycode/test_classify.py @@ -67,4 +67,4 @@ def test_classify_cli_option(self): result_file = self.get_temp_file('json') expected_file = self.get_test_loc('classify/cli.expected.json') run_scan_click(['--info', '--classify', '--json-pp', result_file, test_dir]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) diff --git a/tests/summarycode/test_facet.py b/tests/summarycode/test_facet.py index e30ded0d55e..14bf33bffac 100644 --- a/tests/summarycode/test_facet.py +++ b/tests/summarycode/test_facet.py @@ -29,4 +29,4 @@ def test_facet_cli_option(self): '--facet', 'data=*.json', '--facet', 'docs=*/docs/*', '--json-pp', result_file, test_dir]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) diff --git a/tests/summarycode/test_generated.py b/tests/summarycode/test_generated.py index 84fd336605e..bd57c474691 100644 --- a/tests/summarycode/test_generated.py +++ b/tests/summarycode/test_generated.py @@ -86,5 +86,5 @@ def test_generated_cli_option(self): result_file = self.get_temp_file('json') expected_file = self.get_test_loc('generated/cli.expected.json') run_scan_click(['--generated', '--json-pp', result_file, test_dir]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) diff --git a/tests/summarycode/test_plugin_consolidate.py b/tests/summarycode/test_plugin_consolidate.py index e8760acfa3c..bb7612847a5 100644 --- a/tests/summarycode/test_plugin_consolidate.py +++ b/tests/summarycode/test_plugin_consolidate.py @@ -28,7 +28,7 @@ def test_consolidate_package(self): result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin_consolidate/package-fileset-expected.json') run_scan_click(['-clip', scan_loc, '--consolidate', '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, remove_file_date=True) + check_json_scan(expected_file, result_file, regen=False, remove_file_date=True, ignore_headers=True) def test_consolidate_package_files_should_not_be_considered_in_license_holder_consolidated_component(self): scan_loc = self.get_test_loc('plugin_consolidate/package-files-not-counted-in-license-holders') @@ -38,7 +38,7 @@ def test_consolidate_package_files_should_not_be_considered_in_license_holder_co # expression and holder expected_file = self.get_test_loc('plugin_consolidate/package-files-not-counted-in-license-holders-expected.json') run_scan_click(['-clip', scan_loc, '--consolidate', '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, remove_file_date=True) + check_json_scan(expected_file, result_file, regen=False, remove_file_date=True, ignore_headers=True) def test_consolidate_component_package_from_json_can_run_twice(self): scan_file = self.get_scan('plugin_consolidate/component-package', cli_options='-clip') @@ -65,7 +65,7 @@ def test_consolidate_package_always_include_own_manifest_file(self): result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin_consolidate/package-manifest-expected.json') run_scan_click(['-clip', scan_loc, '--consolidate', '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, remove_file_date=True) + check_json_scan(expected_file, result_file, regen=False, remove_file_date=True, ignore_headers=True) def test_get_package_resources_on_nested_packages_should_include_manifest(self): from packagedcode import get_package_instance @@ -92,7 +92,7 @@ def test_consolidate_origin_summary_license_holder_rollup(self): run_scan_click(['-clip', scan_loc, '--consolidate', '--json', result_file]) # There should be two consolidated components for things under # no-majority and one consolidated component for clear-majority - check_json_scan(expected_file, result_file, regen=False, remove_file_date=True) + check_json_scan(expected_file, result_file, regen=False, remove_file_date=True, ignore_headers=True) def test_consolidate_return_nested_local_majority(self): scan_loc = self.get_test_loc('plugin_consolidate/return-nested-local-majority') @@ -101,7 +101,7 @@ def test_consolidate_return_nested_local_majority(self): run_scan_click(['-clip', scan_loc, '--consolidate', '--json', result_file]) # The nested majority is just 1 file, but has a different origin than the rest of the files above it # and should be reported as a separate consolidated component - check_json_scan(expected_file, result_file, regen=False, remove_file_date=True) + check_json_scan(expected_file, result_file, regen=False, remove_file_date=True, ignore_headers=True) def test_consolidate_component_package_build_from_live_scan(self): scan_loc = self.get_test_loc('plugin_consolidate/component-package-build') diff --git a/tests/summarycode/test_score.py b/tests/summarycode/test_score.py index 5f06f116f0f..74e88f074f2 100644 --- a/tests/summarycode/test_score.py +++ b/tests/summarycode/test_score.py @@ -52,7 +52,9 @@ def closure_test_function(*args, **kwargs): test_env.get_test_loc(expected_file), result_file, remove_file_date=True, - regen=regen) + regen=regen, + ignore_headers=True, + ) test_name = 'test_license_clarity_score_%(test_name)s' % locals() test_name = python_safe_name(test_name) diff --git a/tests/summarycode/test_summarizer.py b/tests/summarycode/test_summarizer.py index 7072eb046ec..ac8541e40d0 100644 --- a/tests/summarycode/test_summarizer.py +++ b/tests/summarycode/test_summarizer.py @@ -29,42 +29,42 @@ def test_copyright_summary_base(self): result_file = self.get_temp_file('json') expected_file = self.get_test_loc('copyright_summary/summary.expected.json') run_scan_click(['-c', '--summary', '--json-pp', result_file, test_dir]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) def test_copyright_summary_with_details(self): test_dir = self.get_test_loc('copyright_summary/scan') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('copyright_summary/summary_details.expected.json') run_scan_click(['-c', '--summary-with-details', '--json-pp', result_file, test_dir]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) def test_copyright_summary_with_details_plain_json(self): test_dir = self.get_test_loc('copyright_summary/scan') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('copyright_summary/summary_details.expected2.json') run_scan_click(['-c', '--summary-with-details', '--json', result_file, test_dir]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) def test_copyright_summary_does_not_crash(self): test_dir = self.get_test_loc('copyright_summary/scan2') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('copyright_summary/summary2.expected.json') run_scan_click(['-c', '--summary', '--json-pp', result_file, test_dir]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) def test_full_summary_base(self): test_dir = self.get_test_loc('full_summary/scan') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('full_summary/summary.expected.json') run_scan_click(['-clip', '--summary', '--json-pp', result_file, test_dir]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) def test_full_summary_with_details(self): test_dir = self.get_test_loc('full_summary/scan') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('full_summary/summary_details.expected.json') run_scan_click(['-clip', '--summary-with-details', '--json-pp', result_file, test_dir]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) def test_copyright_summary_key_files(self): test_dir = self.get_test_loc('copyright_summary/scan') @@ -74,7 +74,7 @@ def test_copyright_summary_key_files(self): ['-c', '-i', '--classify', '--summary', '--summary-key-files', '--json-pp', result_file, test_dir]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) def test_full_summary_key_files(self): test_dir = self.get_test_loc('full_summary/scan') @@ -83,7 +83,7 @@ def test_full_summary_key_files(self): run_scan_click( ['-cli', '--classify', '--summary', '--summary-key-files', '--json-pp', result_file, test_dir]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) def test_full_summary_key_files_json_lines(self): test_dir = self.get_test_loc('full_summary/scan') @@ -92,7 +92,7 @@ def test_full_summary_key_files_json_lines(self): run_scan_click( ['-cli', '--classify', '--summary', '--summary-key-files', '--json-lines', result_file, test_dir]) - check_jsonlines_scan(expected_file, result_file, remove_file_date=True, regen=False) + check_jsonlines_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) def test_full_summary_by_facet(self): test_dir = self.get_test_loc('full_summary/scan') @@ -110,7 +110,7 @@ def test_full_summary_by_facet(self): '--summary-by-facet', '--json-pp', result_file, test_dir ]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) def test_end2end_summary_and_classify_works_with_empty_dir_and_empty_values(self): test_dir = self.extract_test_tar('end-2-end/bug-1141.tar.gz') @@ -124,7 +124,7 @@ def test_end2end_summary_and_classify_works_with_empty_dir_and_empty_values(self '--summary-key-files', '--json-pp', result_file, test_dir ]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) def test_summary_with_packages_reports_packages_with_files(self): test_dir = self.get_test_loc('packages/scan') @@ -135,4 +135,4 @@ def test_summary_with_packages_reports_packages_with_files(self): '--summary', '--json-pp', result_file, test_dir ]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) From edbc8a6b4a69d83ad048abd57ae9172a53fcd624 Mon Sep 17 00:00:00 2001 From: Ayan Sinha Mahapatra Date: Fri, 3 Sep 2021 17:50:20 +0530 Subject: [PATCH 06/10] Bump commoncode in setup.cfg Signed-off-by: Ayan Sinha Mahapatra --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index cd5206feee2..5f10f30ae79 100644 --- a/setup.cfg +++ b/setup.cfg @@ -59,7 +59,7 @@ install_requires = chardet >= 3.0.0 click >= 6.7, !=7.0 colorama >= 0.3.9 - commoncode >= 21.8.27 + commoncode >= 21.8.31 debian-inspector >= 21.5.25 dparse >= 0.5.1 fasteners From 57377b82ad16cf767e6665c97db7b0db01458006 Mon Sep 17 00:00:00 2001 From: Ayan Sinha Mahapatra Date: Mon, 6 Sep 2021 18:10:29 +0530 Subject: [PATCH 07/10] Update Output Version to proper SemVer Signed-off-by: Ayan Sinha Mahapatra --- src/scancode/cli.py | 6 +++--- src/scancode_config.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/scancode/cli.py b/src/scancode/cli.py index 56e7926f620..9b4c30674e6 100644 --- a/src/scancode/cli.py +++ b/src/scancode/cli.py @@ -253,9 +253,9 @@ def validate_depth(ctx, param, value): @click.option('--future-format', is_flag=True, - help='Output the next experimental data format, for JSON and YAML output.' - 'See CHANGELOG for more details on the changes in this experimental data format.', - help_group=cliutils.OUTPUT_CONTROL_GROUP, sort_order=28, cls=PluggableCommandLineOption) + help='Output the future data format, for JSON and YAML output. ' + 'See CHANGELOG for more details on the changes in this future data format.', + help_group=cliutils.OUTPUT_CONTROL_GROUP, cls=PluggableCommandLineOption) @click.help_option('-h', '--help', diff --git a/src/scancode_config.py b/src/scancode_config.py index a32cfdfa5aa..9500fffc792 100644 --- a/src/scancode_config.py +++ b/src/scancode_config.py @@ -78,8 +78,8 @@ def _create_dir(location): # See https://github.com/nexB/scancode-toolkit/issues/2653 for more information # on the data format version -__output_format_version__ = '1.1' -__future_output_format_version__ = '1.1' +__output_format_version__ = '1.0.0' +__future_output_format_version__ = '1.0.0' try: From 3519edce7e97779cee469750579080dabd0dc5f1 Mon Sep 17 00:00:00 2001 From: Ayan Sinha Mahapatra Date: Mon, 6 Sep 2021 18:11:12 +0530 Subject: [PATCH 08/10] Replace ignore_header with check_header attribute Replaces ignore_header with check_header attribute with default False, to minimise diff and ignore headers by default. Signed-off-by: Ayan Sinha Mahapatra --- src/scancode/cli_test_utils.py | 10 ++-- tests/cluecode/test_plugin_email_url.py | 8 +-- tests/cluecode/test_plugin_filter_clues.py | 6 +-- .../cluecode/test_plugin_ignore_copyrights.py | 4 +- tests/formattedcode/test_output_json.py | 8 +-- tests/formattedcode/test_output_jsonlines.py | 2 +- tests/licensedcode/test_plugin_license.py | 20 +++---- .../licensedcode/test_plugin_license_text.py | 2 +- tests/packagedcode/test_build.py | 4 +- tests/packagedcode/test_plugin.py | 52 +++++++++---------- tests/scancode/data/help/help.txt | 14 ++--- tests/scancode/test_cli.py | 28 +++++----- tests/scancode/test_plugin_mark_source.py | 2 +- tests/scancode/test_plugin_only_findings.py | 6 +-- tests/summarycode/test_classify.py | 2 +- tests/summarycode/test_facet.py | 2 +- tests/summarycode/test_generated.py | 2 +- tests/summarycode/test_plugin_consolidate.py | 26 +++++----- tests/summarycode/test_score.py | 1 - tests/summarycode/test_summarizer.py | 24 ++++----- 20 files changed, 111 insertions(+), 112 deletions(-) diff --git a/src/scancode/cli_test_utils.py b/src/scancode/cli_test_utils.py index 584a28435f0..3ca7ea70506 100644 --- a/src/scancode/cli_test_utils.py +++ b/src/scancode/cli_test_utils.py @@ -168,7 +168,7 @@ def check_json_scan( result_file, regen=False, remove_file_date=False, - ignore_headers=False + check_headers=False, ): """ Check the scan `result_file` JSON results against the `expected_file` @@ -179,7 +179,7 @@ def check_json_scan( expectations. But use with caution. If `remove_file_date` is True, the file.date attribute is removed. - If `ignore_headers` is True, the scan headers attribute is removed. + If `check_headers` is True, the scan headers attribute is not removed. """ results = load_json_result(result_file, remove_file_date) if regen: @@ -188,7 +188,7 @@ def check_json_scan( expected = load_json_result(expected_file, remove_file_date) - if ignore_headers: + if not check_headers: results.pop('headers', None) expected.pop('headers', None) @@ -289,7 +289,7 @@ def check_jsonlines_scan( result_file, regen=False, remove_file_date=False, - ignore_headers=False, + check_headers=False, ): """ Check the scan result_file JSON Lines results against the expected_file @@ -313,7 +313,7 @@ def check_jsonlines_scan( streamline_jsonlines_scan(expected, remove_file_date) - if ignore_headers: + if not check_headers: results[0].pop('headers', None) expected[0].pop('headers', None) diff --git a/tests/cluecode/test_plugin_email_url.py b/tests/cluecode/test_plugin_email_url.py index d5994597349..750acfaeda6 100644 --- a/tests/cluecode/test_plugin_email_url.py +++ b/tests/cluecode/test_plugin_email_url.py @@ -25,7 +25,7 @@ def test_scan_email(): result_file = test_env.get_temp_file('json') args = ['--email', '--strip-root', test_dir, '--json', result_file] run_scan_click(args) - check_json_scan(test_env.get_test_loc('plugin_email_url/emails.expected.json'), result_file, ignore_headers=True) + check_json_scan(test_env.get_test_loc('plugin_email_url/emails.expected.json'), result_file) def test_scan_email_with_threshold(): @@ -33,7 +33,7 @@ def test_scan_email_with_threshold(): result_file = test_env.get_temp_file('json') args = ['--email', '--strip-root', '--max-email', '2', test_dir, '--json', result_file] run_scan_click(args) - check_json_scan(test_env.get_test_loc('plugin_email_url/emails-threshold.expected.json'), result_file, ignore_headers=True) + check_json_scan(test_env.get_test_loc('plugin_email_url/emails-threshold.expected.json'), result_file) def test_scan_url(): @@ -41,7 +41,7 @@ def test_scan_url(): result_file = test_env.get_temp_file('json') args = ['--url', '--strip-root', test_dir, '--json', result_file] run_scan_click(args) - check_json_scan(test_env.get_test_loc('plugin_email_url/urls.expected.json'), result_file, ignore_headers=True) + check_json_scan(test_env.get_test_loc('plugin_email_url/urls.expected.json'), result_file) def test_scan_url_with_threshold(): @@ -49,4 +49,4 @@ def test_scan_url_with_threshold(): result_file = test_env.get_temp_file('json') args = ['--url', '--strip-root', '--max-url', '2', test_dir, '--json', result_file] run_scan_click(args) - check_json_scan(test_env.get_test_loc('plugin_email_url/urls-threshold.expected.json'), result_file, ignore_headers=True) + check_json_scan(test_env.get_test_loc('plugin_email_url/urls-threshold.expected.json'), result_file) diff --git a/tests/cluecode/test_plugin_filter_clues.py b/tests/cluecode/test_plugin_filter_clues.py index 1588c98dbad..a873cebf6f6 100644 --- a/tests/cluecode/test_plugin_filter_clues.py +++ b/tests/cluecode/test_plugin_filter_clues.py @@ -41,7 +41,7 @@ def test_scan_plugin_filter_clues_for_rule(): args = ['-clieu', '--filter-clues', test_dir, '--json', result_file] run_scan_click(args) expected = test_env.get_test_loc('plugin_filter_clues/filtered-expected.json') - check_json_scan(expected, result_file, remove_file_date=True, ignore_headers=True, regen=False) + check_json_scan(expected, result_file, remove_file_date=True, regen=False) def test_scan_plugin_filter_clues_does_not_filter_incorrectly(): @@ -53,7 +53,7 @@ def test_scan_plugin_filter_clues_does_not_filter_incorrectly(): args = ['-clieu', '--filter-clues', test_dir, '--json', result_file] run_scan_click(args) expected = test_env.get_test_loc('plugin_filter_clues/filtered-expected2.json') - check_json_scan(expected, result_file, remove_file_date=True, ignore_headers=True, regen=False) + check_json_scan(expected, result_file, remove_file_date=True, regen=False) # Regression on types tracked in https://github.com/nexB/typecode/issues/21 @@ -66,4 +66,4 @@ def test_scan_plugin_filter_clues_for_license(): args = ['-clieu', '--filter-clues', test_dir, '--json', result_file] run_scan_click(args) expected = test_env.get_test_loc('plugin_filter_clues/filtered-expected3.json') - check_json_scan(expected, result_file, remove_file_date=True, ignore_headers=True, regen=False) + check_json_scan(expected, result_file, remove_file_date=True, regen=False) diff --git a/tests/cluecode/test_plugin_ignore_copyrights.py b/tests/cluecode/test_plugin_ignore_copyrights.py index f247b232186..1902a0df9b9 100644 --- a/tests/cluecode/test_plugin_ignore_copyrights.py +++ b/tests/cluecode/test_plugin_ignore_copyrights.py @@ -37,11 +37,11 @@ def test_ignore_holders(self): result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin_ignore_copyrights/holders.expected.json') run_scan_click(['-c', '--ignore-copyright-holder', 'Regents', '--json-pp', result_file, test_dir]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) def test_ignore_authors(self): test_dir = self.extract_test_tar('plugin_ignore_copyrights/basic.tgz') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin_ignore_copyrights/authors.expected.json') run_scan_click(['-c', '--ignore-author', 'Berkeley', '--json-pp', result_file, test_dir]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) diff --git a/tests/formattedcode/test_output_json.py b/tests/formattedcode/test_output_json.py index 91bf46592ca..815eca3a65f 100644 --- a/tests/formattedcode/test_output_json.py +++ b/tests/formattedcode/test_output_json.py @@ -27,7 +27,7 @@ def test_json_pretty_print(): args = ['-clip', test_dir, '--json-pp', result_file] run_scan_click(args) expected = test_env.get_test_loc('json/simple-expected.jsonpp') - check_json_scan(expected, result_file, remove_file_date=True, regen=False, ignore_headers=True) + check_json_scan(expected, result_file, remove_file_date=True, regen=False) def test_json_compact(): @@ -37,7 +37,7 @@ def test_json_compact(): with open(result_file, 'rb') as res: assert len(res.read().splitlines()) == 1 expected = test_env.get_test_loc('json/simple-expected.json') - check_json_scan(expected, result_file, remove_file_date=True, regen=False, ignore_headers=True) + check_json_scan(expected, result_file, remove_file_date=True, regen=False) @pytest.mark.scanslow @@ -46,7 +46,7 @@ def test_scan_output_does_not_truncate_copyright_json(): result_file = test_env.get_temp_file('test.json') run_scan_click(['-clip', '--strip-root', test_dir, '--json-pp', result_file]) expected = test_env.get_test_loc('json/tree/expected.json') - check_json_scan(expected, result_file, remove_file_date=True, regen=False, ignore_headers=True) + check_json_scan(expected, result_file, remove_file_date=True, regen=False) @pytest.mark.scanslow @@ -56,7 +56,7 @@ def test_scan_output_does_not_truncate_copyright_with_json_to_stdout(): args = ['-clip', '--strip-root', test_dir, '--json-pp', result_file] run_scan_click(args) expected = test_env.get_test_loc('json/tree/expected.json') - check_json_scan(expected, result_file, remove_file_date=True, regen=False, ignore_headers=True) + check_json_scan(expected, result_file, remove_file_date=True, regen=False) @pytest.mark.scanslow diff --git a/tests/formattedcode/test_output_jsonlines.py b/tests/formattedcode/test_output_jsonlines.py index 926722feeea..657ab23461b 100644 --- a/tests/formattedcode/test_output_jsonlines.py +++ b/tests/formattedcode/test_output_jsonlines.py @@ -28,7 +28,7 @@ def test_jsonlines(): expected = test_env.get_test_loc('json/simple-expected.jsonlines') check_jsonlines_scan( test_env.get_test_loc(expected), result_file, - remove_file_date=True, regen=False, ignore_headers=True) + remove_file_date=True, regen=False) def test_jsonlines_with_timing(): diff --git a/tests/licensedcode/test_plugin_license.py b/tests/licensedcode/test_plugin_license.py index acbc868d1f8..56fdea9c74f 100644 --- a/tests/licensedcode/test_plugin_license.py +++ b/tests/licensedcode/test_plugin_license.py @@ -33,7 +33,7 @@ def test_license_option_reports_license_expressions(): args = ['--license', '--strip-root', test_dir, '--json', result_file, '--verbose'] run_scan_click(args) test_loc = test_env.get_test_loc('plugin_license/license-expression/scan.expected.json') - check_json_scan(test_loc, result_file, regen=False, ignore_headers=True) + check_json_scan(test_loc, result_file, regen=False) def test_license_option_reports_license_texts(): @@ -42,7 +42,7 @@ def test_license_option_reports_license_texts(): args = ['--license', '--license-text', '--strip-root', test_dir, '--json', result_file, '--verbose'] run_scan_click(args) test_loc = test_env.get_test_loc('plugin_license/text/scan.expected.json') - check_json_scan(test_loc, result_file, regen=False, ignore_headers=True) + check_json_scan(test_loc, result_file, regen=False) def test_license_option_reports_license_texts_diag(): @@ -51,7 +51,7 @@ def test_license_option_reports_license_texts_diag(): args = ['--license', '--license-text', '--license-text-diagnostics', '--strip-root', test_dir, '--json', result_file, '--verbose'] run_scan_click(args) test_loc = test_env.get_test_loc('plugin_license/text/scan-diag.expected.json') - check_json_scan(test_loc, result_file, regen=False, ignore_headers=True) + check_json_scan(test_loc, result_file, regen=False) def test_license_option_reports_license_texts_long_lines(): @@ -60,7 +60,7 @@ def test_license_option_reports_license_texts_long_lines(): args = ['--license', '--license-text', '--strip-root', test_dir, '--json', result_file, '--verbose'] run_scan_click(args) test_loc = test_env.get_test_loc('plugin_license/text_long_lines/scan.expected.json') - check_json_scan(test_loc, result_file, regen=False, ignore_headers=True) + check_json_scan(test_loc, result_file, regen=False) def test_license_option_reports_license_texts_diag_long_lines(): @@ -69,7 +69,7 @@ def test_license_option_reports_license_texts_diag_long_lines(): args = ['--license', '--license-text', '--license-text-diagnostics', '--strip-root', test_dir, '--json', result_file, '--verbose'] run_scan_click(args) test_loc = test_env.get_test_loc('plugin_license/text_long_lines/scan-diag.expected.json') - check_json_scan(test_loc, result_file, regen=False, ignore_headers=True) + check_json_scan(test_loc, result_file, regen=False) def test_license_match_reference(): @@ -78,7 +78,7 @@ def test_license_match_reference(): args = ['--license', '--license-text', '--license-text-diagnostics', '--strip-root', test_dir, '--json', result_file, '--verbose'] run_scan_click(args) test_loc = test_env.get_test_loc('plugin_license/license_reference/scan-ref.expected.json') - check_json_scan(test_loc, result_file, regen=False, ignore_headers=True) + check_json_scan(test_loc, result_file, regen=False) def test_license_match_without_reference(): @@ -87,7 +87,7 @@ def test_license_match_without_reference(): args = ['--license', '--license-text', '--license-text-diagnostics', '--strip-root', test_dir, '--json', result_file, '--verbose'] run_scan_click(args) test_loc = test_env.get_test_loc('plugin_license/license_reference/scan-wref.expected.json') - check_json_scan(test_loc, result_file, regen=False, ignore_headers=True) + check_json_scan(test_loc, result_file, regen=False) def test_get_referenced_filenames(): @@ -145,7 +145,7 @@ def test_scan_license_with_url_template(): test_dir, '--json-pp', result_file] test_loc = test_env.get_test_loc('plugin_license/license_url.expected.json') run_scan_click(args) - check_json_scan(test_loc, result_file, ignore_headers=True) + check_json_scan(test_loc, result_file) @pytest.mark.scanslow @@ -155,7 +155,7 @@ def test_detection_does_not_timeout_on_sqlite3_amalgamation(): expected_file = test_env.get_test_loc('plugin_license/sqlite/sqlite.expected.json') # we use the default 120 seconds timeout run_scan_click(['-l', '--license-text', '--json-pp', result_file, test_dir]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) @pytest.mark.scanslow @@ -164,4 +164,4 @@ def test_detection_is_correct_in_legacy_npm_package_json(): result_file = test_env.get_temp_file('json') expected_file = test_env.get_test_loc('plugin_license/package/package.expected.json') run_scan_click(['-lp', '--json-pp', result_file, test_dir]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) diff --git a/tests/licensedcode/test_plugin_license_text.py b/tests/licensedcode/test_plugin_license_text.py index 3709a5b1c5d..1040421c7f4 100644 --- a/tests/licensedcode/test_plugin_license_text.py +++ b/tests/licensedcode/test_plugin_license_text.py @@ -33,4 +33,4 @@ def test_is_licensing_works(): test_dir, '--json-pp', result_file, '--verbose'] run_scan_click(args) check_json_scan(test_env.get_test_loc('plugin_license_text/scan.expected.json'), - result_file, remove_file_date=True, regen=False, ignore_headers=True) + result_file, remove_file_date=True, regen=False) diff --git a/tests/packagedcode/test_build.py b/tests/packagedcode/test_build.py index d158a347b11..ad0a0cafdef 100644 --- a/tests/packagedcode/test_build.py +++ b/tests/packagedcode/test_build.py @@ -25,14 +25,14 @@ def test_end2end_scan_can_detect_bazel(self): expected_file = self.get_test_loc('bazel/end2end-expected.json') result_file = self.get_temp_file('results.json') run_scan_click(['--package', test_file, '--json-pp', result_file]) - check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False) def test_end2end_scan_can_detect_buck(self): test_file = self.get_test_loc('buck/end2end') expected_file = self.get_test_loc('buck/end2end-expected.json') result_file = self.get_temp_file('results.json') run_scan_click(['--package', test_file, '--json-pp', result_file]) - check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False) def test_build_get_package_resources(self): test_loc = self.get_test_loc('get_package_resources') diff --git a/tests/packagedcode/test_plugin.py b/tests/packagedcode/test_plugin.py index 848acd3726a..7a23a9e7a96 100644 --- a/tests/packagedcode/test_plugin.py +++ b/tests/packagedcode/test_plugin.py @@ -33,179 +33,179 @@ def test_package_command_scan_python(self): result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/python-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False) def test_package_command_scan_maven(self): test_dir = self.get_test_loc('maven2') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/maven-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False) def test_package_command_scan_about(self): test_dir = self.get_test_loc('about') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/about-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False) def test_package_command_scan_bower(self): test_dir = self.get_test_loc('bower/package') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/bower-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False) def test_package_command_scan_cargo(self): test_dir = self.get_test_loc('cargo/package') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/cargo-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False) def test_package_command_scan_chef(self): test_dir = self.get_test_loc('chef/package') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/chef-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False) def test_package_command_scan_conda(self): test_dir = self.get_test_loc('conda/package') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/conda-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False) def test_package_command_scan_freebsd(self): test_dir = self.get_test_loc('freebsd/package') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/freebsd-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False) def test_package_command_scan_haxe(self): test_dir = self.get_test_loc('haxe/package') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/haxe-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False) def test_package_command_scan_npm(self): test_dir = self.get_test_loc('npm/package') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/npm-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False) def test_package_command_scan_nuget(self): test_dir = self.get_test_loc('nuget/package') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/nuget-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False) def test_package_command_scan_opam(self): test_dir = self.get_test_loc('opam/package') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/opam-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False) def test_package_command_scan_phpcomposer(self): test_dir = self.get_test_loc('phpcomposer/package') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/phpcomposer-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False) def test_package_command_scan_rubygems(self): test_dir = self.get_test_loc('rubygems/package') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/rubygems-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False) def test_package_command_scan_rpm(self): test_dir = self.get_test_loc('rpm/package') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/rpm-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False) def test_package_command_scan_cran_r_package(self): test_dir = self.get_test_loc('cran/package') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/cran-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False) def test_package_command_scan_win_pe(self): test_dir = self.get_test_loc('win_pe/file.exe') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/win_pe-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False) def test_package_command_scan_mum(self): test_dir = self.get_test_loc('windows/mum/test.mum') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/mum-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False) def test_package_command_scan_pubspec_package(self): test_dir = self.get_test_loc('pubspec/specs/authors-pubspec.yaml') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/pubspec-expected.json', must_exist=False) run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False) def test_package_command_scan_pubspec_lock_package(self): test_dir = self.get_test_loc('pubspec/locks/dart-pubspec.lock') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/pubspec-lock-expected.json', must_exist=False) run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False) def test_package_command_scan_mui(self): test_dir = self.get_test_loc('win_pe/clfs.sys.mui') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/mui-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False) def test_package_command_scan_mun(self): test_dir = self.get_test_loc('win_pe/crypt32.dll.mun') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/mun-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False) def test_package_command_scan_com(self): test_dir = self.get_test_loc('win_pe/chcp.com') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/com-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False) def test_package_command_scan_tlb(self): test_dir = self.get_test_loc('win_pe/stdole2.tlb') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/tlb-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False) def test_package_command_scan_sys(self): test_dir = self.get_test_loc('win_pe/tbs.sys') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/sys-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False) def test_package_command_scan_winmd(self): test_dir = self.get_test_loc('win_pe/Windows.AI.winmd') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin/winmd-package-expected.json') run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False) diff --git a/tests/scancode/data/help/help.txt b/tests/scancode/data/help/help.txt index 17bbea58733..a5e24d6c205 100644 --- a/tests/scancode/data/help/help.txt +++ b/tests/scancode/data/help/help.txt @@ -70,13 +70,13 @@ Options: is not treated as findings). output control: - --future-format Output the next experimental data format, for JSON and YAML - output.See CHANGELOG for more details on the changes in this - experimental data format. - --full-root Report full, absolute paths. - --strip-root Strip the root directory segment of all paths. The default is to - always include the last directory segment of the scanned path - such that all paths have a common root directory. + --full-root Report full, absolute paths. + --future-format Output the future data format, for JSON and YAML + output. See CHANGELOG for more details on the changes in this + future data format. + --strip-root Strip the root directory segment of all paths. The default is + to always include the last directory segment of the scanned + path such that all paths have a common root directory. pre-scan: --ignore Ignore files matching . diff --git a/tests/scancode/test_cli.py b/tests/scancode/test_cli.py index 8225294bdbd..394ae2f5acd 100644 --- a/tests/scancode/test_cli.py +++ b/tests/scancode/test_cli.py @@ -134,7 +134,7 @@ def test_scan_info_does_collect_info(): args = ['--info', '--strip-root', test_dir, '--json', result_file] run_scan_click(args) expected = test_env.get_test_loc('info/basic.expected.json') - check_json_scan(expected, result_file, regen=False, ignore_headers=True) + check_json_scan(expected, result_file, regen=False) def test_scan_info_does_collect_info_with_root(): @@ -142,7 +142,7 @@ def test_scan_info_does_collect_info_with_root(): result_file = test_env.get_temp_file('json') run_scan_click(['--info', test_dir, '--json', result_file]) expected = test_env.get_test_loc('info/basic.rooted.expected.json') - check_json_scan(expected, result_file, regen=False, ignore_headers=True) + check_json_scan(expected, result_file, regen=False) def test_scan_info_returns_full_root(): @@ -177,7 +177,7 @@ def test_scan_info_returns_does_not_strip_root_with_single_file(): args = ['--info', '--strip-root', test_file, '--json', result_file] run_scan_click(args) expected = test_env.get_test_loc('single/iproute.expected.json') - check_json_scan(expected, result_file, remove_file_date=True, regen=False, ignore_headers=True) + check_json_scan(expected, result_file, remove_file_date=True, regen=False) @pytest.mark.scanslow @@ -186,7 +186,7 @@ def test_scan_info_license_copyrights(): result_file = test_env.get_temp_file('json') args = ['--info', '--license', '--copyright', '--strip-root', test_dir, '--json', result_file] run_scan_click(args) - check_json_scan(test_env.get_test_loc('info/all.expected.json'), result_file, regen=False, ignore_headers=True) + check_json_scan(test_env.get_test_loc('info/all.expected.json'), result_file, regen=False) def test_scan_noinfo_license_copyrights_with_root(): @@ -195,7 +195,7 @@ def test_scan_noinfo_license_copyrights_with_root(): args = ['--email', '--url', '--license', '--copyright', test_dir, '--json', result_file] run_scan_click(args) expected = test_env.get_test_loc('info/all.rooted.expected.json') - check_json_scan(expected, result_file, regen=False, ignore_headers=True) + check_json_scan(expected, result_file, regen=False) def test_scan_email_url_info(): @@ -204,7 +204,7 @@ def test_scan_email_url_info(): args = ['--email', '--url', '--info', '--strip-root', test_dir, '--json', result_file] run_scan_click(args) expected = test_env.get_test_loc('info/email_url_info.expected.json') - check_json_scan(expected, result_file, regen=False, ignore_headers=True) + check_json_scan(expected, result_file, regen=False) def test_scan_should_not_fail_on_faulty_pdf_or_pdfminer_bug_but_instead_keep_trucking_with_json(): @@ -213,7 +213,7 @@ def test_scan_should_not_fail_on_faulty_pdf_or_pdfminer_bug_but_instead_keep_tru args = ['--copyright', '--strip-root', test_file, '--json', result_file] result = run_scan_click(args, expected_rc=0) expected = test_env.get_test_loc('failing/patchelf.expected.json') - check_json_scan(expected, result_file, regen=False, ignore_headers=True) + check_json_scan(expected, result_file, regen=False) assert 'Some files failed to scan' not in result.output assert 'patchelf.pdf' not in result.output @@ -393,7 +393,7 @@ def check_scan_does_not_fail_when_scanning_unicode_files_and_paths(verbosity): elif on_windows: expected = 'unicodepath/unicodepath.expected-win.json' + verbosity - check_json_scan(test_env.get_test_loc(expected), result_file, remove_file_date=True, regen=False, ignore_headers=True) + check_json_scan(test_env.get_test_loc(expected), result_file, remove_file_date=True, regen=False) return results @@ -477,7 +477,7 @@ def test_scan_can_return_matched_license_text(): result_file = test_env.get_temp_file('json') args = ['--license', '--license-text', '--strip-root', test_file, '--json', result_file] run_scan_click(args) - check_json_scan(test_env.get_test_loc(expected_file), result_file, regen=False, ignore_headers=True) + check_json_scan(test_env.get_test_loc(expected_file), result_file, regen=False) @pytest.mark.skipif(on_windows, reason='This test cannot run on windows as these are not legal file names.') @@ -491,7 +491,7 @@ def test_scan_can_handle_weird_file_names(): # Some info vary on each OS # See https://github.com/nexB/scancode-toolkit/issues/438 for details expected = 'weird_file_name/expected-posix.json' - check_json_scan(test_env.get_test_loc(expected), result_file, regen=False, ignore_headers=True) + check_json_scan(test_env.get_test_loc(expected), result_file, regen=False) @pytest.mark.skipif(on_macos_14_or_higher or on_windows, @@ -516,7 +516,7 @@ def test_scan_can_handle_non_utf8_file_names_on_posix(): elif on_windows: expected = 'non_utf8/expected-win.json' - check_json_scan(test_env.get_test_loc(expected), result_file, regen=False, ignore_headers=True) + check_json_scan(test_env.get_test_loc(expected), result_file, regen=False) def test_scan_can_run_from_other_directory(): @@ -526,7 +526,7 @@ def test_scan_can_run_from_other_directory(): work_dir = os.path.dirname(result_file) args = ['-ci', '--strip-root', test_file, '--json', result_file] run_scan_plain(args, cwd=work_dir) - check_json_scan(test_env.get_test_loc(expected_file), result_file, remove_file_date=True, regen=False, ignore_headers=True) + check_json_scan(test_env.get_test_loc(expected_file), result_file, remove_file_date=True, regen=False) def test_scan_logs_errors_messages_not_verbosely_on_stderr(): @@ -640,7 +640,7 @@ def test_scan_does_scan_php_composer(): expected_file = test_env.get_test_loc('composer/composer.expected.json') result_file = test_env.get_temp_file('results.json') run_scan_click(['--package', test_file, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False) def test_scan_does_scan_rpm(): @@ -648,7 +648,7 @@ def test_scan_does_scan_rpm(): expected_file = test_env.get_test_loc('rpm/fping-2.4-0.b2.rhfc1.dag.i386.rpm.expected.json') result_file = test_env.get_temp_file('results.json') run_scan_click(['--package', test_file, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False) def test_scan_cli_help(regen=False): diff --git a/tests/scancode/test_plugin_mark_source.py b/tests/scancode/test_plugin_mark_source.py index ad842f9095a..d30b19c3c05 100644 --- a/tests/scancode/test_plugin_mark_source.py +++ b/tests/scancode/test_plugin_mark_source.py @@ -42,4 +42,4 @@ def test_scan_mark_source_with_info(self): result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin_mark_source/with_info.expected.json') run_scan_click(['--info', '--mark-source', test_dir, '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False) diff --git a/tests/scancode/test_plugin_only_findings.py b/tests/scancode/test_plugin_only_findings.py index c506024511b..5fe2678b310 100644 --- a/tests/scancode/test_plugin_only_findings.py +++ b/tests/scancode/test_plugin_only_findings.py @@ -27,7 +27,7 @@ def test_scan_only_findings(self): result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin_only_findings/basic.expected.json') run_scan_click(['-clip', '--only-findings', '--json', result_file, test_dir]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) def test_scan_only_findings_with_errors(self): test_file = self.get_test_loc('plugin_only_findings/errors.json') @@ -35,11 +35,11 @@ def test_scan_only_findings_with_errors(self): expected_file = self.get_test_loc('plugin_only_findings/errors.expected.json') run_scan_click(['--from-json', test_file, '--only-findings', '--json-pp', result_file]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) def test_scan_only_findings_with_only_info(self): test_dir = self.extract_test_tar('plugin_only_findings/basic.tgz') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin_only_findings/info.expected.json') run_scan_click(['--info', '--only-findings', '--json', result_file, test_dir]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) diff --git a/tests/summarycode/test_classify.py b/tests/summarycode/test_classify.py index 0b68cf335b6..caef5f40011 100644 --- a/tests/summarycode/test_classify.py +++ b/tests/summarycode/test_classify.py @@ -67,4 +67,4 @@ def test_classify_cli_option(self): result_file = self.get_temp_file('json') expected_file = self.get_test_loc('classify/cli.expected.json') run_scan_click(['--info', '--classify', '--json-pp', result_file, test_dir]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) diff --git a/tests/summarycode/test_facet.py b/tests/summarycode/test_facet.py index 14bf33bffac..e30ded0d55e 100644 --- a/tests/summarycode/test_facet.py +++ b/tests/summarycode/test_facet.py @@ -29,4 +29,4 @@ def test_facet_cli_option(self): '--facet', 'data=*.json', '--facet', 'docs=*/docs/*', '--json-pp', result_file, test_dir]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) diff --git a/tests/summarycode/test_generated.py b/tests/summarycode/test_generated.py index bd57c474691..84fd336605e 100644 --- a/tests/summarycode/test_generated.py +++ b/tests/summarycode/test_generated.py @@ -86,5 +86,5 @@ def test_generated_cli_option(self): result_file = self.get_temp_file('json') expected_file = self.get_test_loc('generated/cli.expected.json') run_scan_click(['--generated', '--json-pp', result_file, test_dir]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) diff --git a/tests/summarycode/test_plugin_consolidate.py b/tests/summarycode/test_plugin_consolidate.py index bb7612847a5..2da4f95582a 100644 --- a/tests/summarycode/test_plugin_consolidate.py +++ b/tests/summarycode/test_plugin_consolidate.py @@ -28,7 +28,7 @@ def test_consolidate_package(self): result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin_consolidate/package-fileset-expected.json') run_scan_click(['-clip', scan_loc, '--consolidate', '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, remove_file_date=True, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False, remove_file_date=True) def test_consolidate_package_files_should_not_be_considered_in_license_holder_consolidated_component(self): scan_loc = self.get_test_loc('plugin_consolidate/package-files-not-counted-in-license-holders') @@ -38,7 +38,7 @@ def test_consolidate_package_files_should_not_be_considered_in_license_holder_co # expression and holder expected_file = self.get_test_loc('plugin_consolidate/package-files-not-counted-in-license-holders-expected.json') run_scan_click(['-clip', scan_loc, '--consolidate', '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, remove_file_date=True, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False, remove_file_date=True) def test_consolidate_component_package_from_json_can_run_twice(self): scan_file = self.get_scan('plugin_consolidate/component-package', cli_options='-clip') @@ -46,26 +46,26 @@ def test_consolidate_component_package_from_json_can_run_twice(self): result_file = self.get_temp_file('json') run_scan_click(['--from-json', scan_file, '--consolidate', '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, remove_file_date=True, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False, remove_file_date=True) # rerun with result_file from last run result_file2 = self.get_temp_file('json') run_scan_click(['--from-json', result_file, '--consolidate', '--json', result_file2]) - check_json_scan(expected_file, result_file2, regen=False, remove_file_date=True, ignore_headers=True) + check_json_scan(expected_file, result_file2, regen=False, remove_file_date=True) def test_consolidate_component_package_from_live_scan(self): scan_loc = self.get_test_loc('plugin_consolidate/component-package') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin_consolidate/component-package-expected.json') run_scan_click(['-clip', scan_loc, '--consolidate', '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, remove_file_date=True, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False, remove_file_date=True) def test_consolidate_package_always_include_own_manifest_file(self): scan_loc = self.get_test_loc('plugin_consolidate/package-manifest') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin_consolidate/package-manifest-expected.json') run_scan_click(['-clip', scan_loc, '--consolidate', '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, remove_file_date=True, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False, remove_file_date=True) def test_get_package_resources_on_nested_packages_should_include_manifest(self): from packagedcode import get_package_instance @@ -83,7 +83,7 @@ def test_consolidate_multiple_same_holder_and_license(self): result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin_consolidate/multiple-same-holder-and-license-expected.json') run_scan_click(['-clip', scan_loc, '--consolidate', '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, remove_file_date=True, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False, remove_file_date=True) def test_consolidate_origin_summary_license_holder_rollup(self): scan_loc = self.get_test_loc('plugin_consolidate/license-holder-rollup') @@ -92,7 +92,7 @@ def test_consolidate_origin_summary_license_holder_rollup(self): run_scan_click(['-clip', scan_loc, '--consolidate', '--json', result_file]) # There should be two consolidated components for things under # no-majority and one consolidated component for clear-majority - check_json_scan(expected_file, result_file, regen=False, remove_file_date=True, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False, remove_file_date=True) def test_consolidate_return_nested_local_majority(self): scan_loc = self.get_test_loc('plugin_consolidate/return-nested-local-majority') @@ -101,32 +101,32 @@ def test_consolidate_return_nested_local_majority(self): run_scan_click(['-clip', scan_loc, '--consolidate', '--json', result_file]) # The nested majority is just 1 file, but has a different origin than the rest of the files above it # and should be reported as a separate consolidated component - check_json_scan(expected_file, result_file, regen=False, remove_file_date=True, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False, remove_file_date=True) def test_consolidate_component_package_build_from_live_scan(self): scan_loc = self.get_test_loc('plugin_consolidate/component-package-build') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin_consolidate/component-package-build-expected.json') run_scan_click(['-clip', scan_loc, '--consolidate', '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, remove_file_date=True, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False, remove_file_date=True) def test_consolidate_report_minority_origin_directory(self): scan_loc = self.get_test_loc('plugin_consolidate/report-subdirectory-with-minority-origin') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin_consolidate/report-subdirectory-with-minority-origin-expected.json') run_scan_click(['-clip', scan_loc, '--consolidate', '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, remove_file_date=True, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False, remove_file_date=True) def test_consolidate_zlib(self): scan_loc = self.get_test_loc('plugin_consolidate/zlib.json') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin_consolidate/zlib-expected.json') run_scan_click(['--from-json', scan_loc, '--consolidate', '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, remove_file_date=True, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False, remove_file_date=True) def test_consolidate_e2fsprogs(self): scan_loc = self.get_test_loc('plugin_consolidate/e2fsprogs.json') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('plugin_consolidate/e2fsprogs-expected.json') run_scan_click(['--from-json', scan_loc, '--consolidate', '--json', result_file]) - check_json_scan(expected_file, result_file, regen=False, remove_file_date=True, ignore_headers=True) + check_json_scan(expected_file, result_file, regen=False, remove_file_date=True) diff --git a/tests/summarycode/test_score.py b/tests/summarycode/test_score.py index 74e88f074f2..3a88ab4ae41 100644 --- a/tests/summarycode/test_score.py +++ b/tests/summarycode/test_score.py @@ -53,7 +53,6 @@ def closure_test_function(*args, **kwargs): result_file, remove_file_date=True, regen=regen, - ignore_headers=True, ) test_name = 'test_license_clarity_score_%(test_name)s' % locals() diff --git a/tests/summarycode/test_summarizer.py b/tests/summarycode/test_summarizer.py index ac8541e40d0..7072eb046ec 100644 --- a/tests/summarycode/test_summarizer.py +++ b/tests/summarycode/test_summarizer.py @@ -29,42 +29,42 @@ def test_copyright_summary_base(self): result_file = self.get_temp_file('json') expected_file = self.get_test_loc('copyright_summary/summary.expected.json') run_scan_click(['-c', '--summary', '--json-pp', result_file, test_dir]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) def test_copyright_summary_with_details(self): test_dir = self.get_test_loc('copyright_summary/scan') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('copyright_summary/summary_details.expected.json') run_scan_click(['-c', '--summary-with-details', '--json-pp', result_file, test_dir]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) def test_copyright_summary_with_details_plain_json(self): test_dir = self.get_test_loc('copyright_summary/scan') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('copyright_summary/summary_details.expected2.json') run_scan_click(['-c', '--summary-with-details', '--json', result_file, test_dir]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) def test_copyright_summary_does_not_crash(self): test_dir = self.get_test_loc('copyright_summary/scan2') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('copyright_summary/summary2.expected.json') run_scan_click(['-c', '--summary', '--json-pp', result_file, test_dir]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) def test_full_summary_base(self): test_dir = self.get_test_loc('full_summary/scan') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('full_summary/summary.expected.json') run_scan_click(['-clip', '--summary', '--json-pp', result_file, test_dir]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) def test_full_summary_with_details(self): test_dir = self.get_test_loc('full_summary/scan') result_file = self.get_temp_file('json') expected_file = self.get_test_loc('full_summary/summary_details.expected.json') run_scan_click(['-clip', '--summary-with-details', '--json-pp', result_file, test_dir]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) def test_copyright_summary_key_files(self): test_dir = self.get_test_loc('copyright_summary/scan') @@ -74,7 +74,7 @@ def test_copyright_summary_key_files(self): ['-c', '-i', '--classify', '--summary', '--summary-key-files', '--json-pp', result_file, test_dir]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) def test_full_summary_key_files(self): test_dir = self.get_test_loc('full_summary/scan') @@ -83,7 +83,7 @@ def test_full_summary_key_files(self): run_scan_click( ['-cli', '--classify', '--summary', '--summary-key-files', '--json-pp', result_file, test_dir]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) def test_full_summary_key_files_json_lines(self): test_dir = self.get_test_loc('full_summary/scan') @@ -92,7 +92,7 @@ def test_full_summary_key_files_json_lines(self): run_scan_click( ['-cli', '--classify', '--summary', '--summary-key-files', '--json-lines', result_file, test_dir]) - check_jsonlines_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) + check_jsonlines_scan(expected_file, result_file, remove_file_date=True, regen=False) def test_full_summary_by_facet(self): test_dir = self.get_test_loc('full_summary/scan') @@ -110,7 +110,7 @@ def test_full_summary_by_facet(self): '--summary-by-facet', '--json-pp', result_file, test_dir ]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) def test_end2end_summary_and_classify_works_with_empty_dir_and_empty_values(self): test_dir = self.extract_test_tar('end-2-end/bug-1141.tar.gz') @@ -124,7 +124,7 @@ def test_end2end_summary_and_classify_works_with_empty_dir_and_empty_values(self '--summary-key-files', '--json-pp', result_file, test_dir ]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) def test_summary_with_packages_reports_packages_with_files(self): test_dir = self.get_test_loc('packages/scan') @@ -135,4 +135,4 @@ def test_summary_with_packages_reports_packages_with_files(self): '--summary', '--json-pp', result_file, test_dir ]) - check_json_scan(expected_file, result_file, remove_file_date=True, regen=False, ignore_headers=True) + check_json_scan(expected_file, result_file, remove_file_date=True, regen=False) From 457f782d03c2aea00733083fff64436d6060df11 Mon Sep 17 00:00:00 2001 From: Ayan Sinha Mahapatra Date: Mon, 6 Sep 2021 23:06:09 +0530 Subject: [PATCH 09/10] Remove --future-format flag See https://github.com/nexB/scancode-toolkit/issues/2653#issuecomment-913708258 Signed-off-by: Ayan Sinha Mahapatra --- src/scancode/cli.py | 12 ------------ src/scancode_config.py | 1 - tests/scancode/data/help/help.txt | 3 --- 3 files changed, 16 deletions(-) diff --git a/src/scancode/cli.py b/src/scancode/cli.py index 9b4c30674e6..988b46f245a 100644 --- a/src/scancode/cli.py +++ b/src/scancode/cli.py @@ -95,7 +95,6 @@ def print_version(ctx, param, value): return click.echo('ScanCode version ' + scancode_config.__version__) click.echo('Output Format version ' + scancode_config.__output_format_version__) - click.echo('Future Output Format version ' + scancode_config.__future_output_format_version__) ctx.exit() @@ -251,13 +250,6 @@ def validate_depth(ctx, param, value): 'the starting directory. Use 0 for no scan depth limit.', help_group=cliutils.CORE_GROUP, sort_order=301, cls=PluggableCommandLineOption) -@click.option('--future-format', - is_flag=True, - help='Output the future data format, for JSON and YAML output. ' - 'See CHANGELOG for more details on the changes in this future data format.', - help_group=cliutils.OUTPUT_CONTROL_GROUP, cls=PluggableCommandLineOption) - - @click.help_option('-h', '--help', help_group=cliutils.DOC_GROUP, sort_order=10, cls=PluggableCommandLineOption) @@ -354,7 +346,6 @@ def scancode( verbose, max_depth, from_json, - future_format, timing, max_in_memory, test_mode, @@ -458,7 +449,6 @@ def scancode( quiet=quiet, verbose=verbose, max_depth=max_depth, - future_format=future_format, timing=timing, max_in_memory=max_in_memory, test_mode=test_mode, @@ -495,7 +485,6 @@ def scancode( def run_scan( input, # NOQA from_json=False, - future_format=False, strip_root=False, full_root=False, max_in_memory=10000, @@ -602,7 +591,6 @@ def echo_func(*_args, **_kwargs): quiet=quiet, verbose=verbose, from_json=from_json, - future_format=future_format, timing=timing, max_in_memory=max_in_memory, test_mode=test_mode, diff --git a/src/scancode_config.py b/src/scancode_config.py index 9500fffc792..9b39612c7cb 100644 --- a/src/scancode_config.py +++ b/src/scancode_config.py @@ -79,7 +79,6 @@ def _create_dir(location): # See https://github.com/nexB/scancode-toolkit/issues/2653 for more information # on the data format version __output_format_version__ = '1.0.0' -__future_output_format_version__ = '1.0.0' try: diff --git a/tests/scancode/data/help/help.txt b/tests/scancode/data/help/help.txt index a5e24d6c205..5d031946d3c 100644 --- a/tests/scancode/data/help/help.txt +++ b/tests/scancode/data/help/help.txt @@ -71,9 +71,6 @@ Options: output control: --full-root Report full, absolute paths. - --future-format Output the future data format, for JSON and YAML - output. See CHANGELOG for more details on the changes in this - future data format. --strip-root Strip the root directory segment of all paths. The default is to always include the last directory segment of the scanned path such that all paths have a common root directory. From 661ceeafbaeed6a19e2eb9c4bb2f61825f97e0d3 Mon Sep 17 00:00:00 2001 From: Ayan Sinha Mahapatra Date: Tue, 7 Sep 2021 16:01:16 +0530 Subject: [PATCH 10/10] Update release docs with output data versioning Signed-off-by: Ayan Sinha Mahapatra --- docs/source/contribute/cut_new_release.rst | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/docs/source/contribute/cut_new_release.rst b/docs/source/contribute/cut_new_release.rst index 30e70d02fc9..8dea6a47d40 100644 --- a/docs/source/contribute/cut_new_release.rst +++ b/docs/source/contribute/cut_new_release.rst @@ -1,8 +1,17 @@ How to cut a new release: ========================= +Update version +-------------- + - Run bumpversion with major, minor or patch to bump the version in - ``setup.cfg`` and ``src/scancode_config.py`` + ``setup.cfg`` and ``src/scancode_config.py``. Note that this is CalVer. + +- If scancode output data format is changed, increment manually the major, minor or patch + to bump the version in ``src/scancode_config.py``. Note that this is SemVer. + +Tag and publish +--------------- - Update the CHANGELOG.rst @@ -22,6 +31,9 @@ How to cut a new release: - Draft a new release in GitHub, using the previous release blurb as a base. Highlight new and noteworthy changes from the CHANGELOG.rst. +Create Release on GitHub +------------------------ + - Run ``etc/release/scancode_release.sh`` locally. - Upload the release archives created in the ``dist/`` directory to the GitHub release page. @@ -33,6 +45,9 @@ How to cut a new release: - publish the release on GitHub +Upload wheels to pypi and Test +------------------------------ + - then build and publish the released wheel on Pypi. For this you need your own Pypi credentials (and get authorized to publish Pypi release: ask @pombredanne) and you need to have the ``twine`` package installed and configured.