Skip to content

Commit

Permalink
Update CHANGELOG, docs and CLI option tests
Browse files Browse the repository at this point in the history
Signed-off-by: Ayan Sinha Mahapatra <[email protected]>
  • Loading branch information
AyanSinhaMahapatra committed Mar 18, 2024
1 parent cd54687 commit 7fcd25d
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ v33.0.0 (next next, roadmap)
v32.1.0 (next, roadmap)
----------------------------

New CLI options:

- A new CLI option ``--package-only`` has been added which performs
a faster package scan by skipping the package assembly step and
also skipping license/copyright detection on package metadata.

Major API/other changes:

- Output Format Version updated to 3.1.0 (minor version bump)
Expand Down
4 changes: 4 additions & 0 deletions docs/source/rst_snippets/basic_options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ documenting a program's options. For example:
--system-package Scan ``<input>`` for installed system package
databases.

--package-only Scan ``<input>`` for system and application
only for package metadata, without license/
copyright detection and package assembly.

-e, --email Scan ``<input>`` for emails.

Sub-Options:
Expand Down
6 changes: 4 additions & 2 deletions src/packagedcode/plugin_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,11 @@ class PackageScanner(ScanPlugin):
),
is_flag=True,
default=False,
conflicting_options=['license', 'summary', 'package', 'system_package'],
help=(
'Only detect package information and skip license/copyright detection steps, '
'in application package and dependency manifests, lockfiles and related data.'
'Only detect package metadata and skip license/copyright detection steps, '
'and skip package assembly in package and dependency manifests, lockfiles '
'and related data.'
),
help_group=SCAN_GROUP,
sort_order=22,
Expand Down
36 changes: 36 additions & 0 deletions tests/packagedcode/test_plugin_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,42 @@ def test_package_list_command(self, regen=REGEN_TEST_FIXTURES):
ef.write(result.output)
assert result.output == open(expected_file).read()

def test_plugin_package_only_fails_with_license_scan(self):
test_dir = self.get_test_loc('maven2')
result_file = self.get_temp_file('json')
try:
run_scan_click(['--package-only', '--license', test_dir, '--json', result_file])
raise Exception("This SCAN should raise an AssertionError for conflicting CLI options")
except AssertionError:
pass

def test_plugin_package_only_fails_with_summary_scan(self):
test_dir = self.get_test_loc('maven2')
result_file = self.get_temp_file('json')
try:
run_scan_click(['--package-only', '--summary', '--classify', test_dir, '--json', result_file])
raise Exception("This SCAN should raise an AssertionError for conflicting CLI options")
except AssertionError:
pass

def test_plugin_package_only_fails_with_package_scan(self):
test_dir = self.get_test_loc('maven2')
result_file = self.get_temp_file('json')
try:
run_scan_click(['--package-only', '--package', test_dir, '--json', result_file])
raise Exception("This SCAN should raise an AssertionError for conflicting CLI options")
except AssertionError:
pass

def test_plugin_package_only_fails_with_system_package_scan(self):
test_dir = self.get_test_loc('maven2')
result_file = self.get_temp_file('json')
try:
run_scan_click(['--package-only', '--system-package', test_dir, '--json', result_file])
raise Exception("This SCAN should raise an AssertionError for conflicting CLI options")
except AssertionError:
pass

def test_system_package_get_installed_packages(self):
test_dir = self.extract_test_tar('debian/basic-rootfs.tar.gz')
expected_file = self.get_test_loc('plugin/get_installed_packages-expected.json')
Expand Down

0 comments on commit 7fcd25d

Please sign in to comment.