Skip to content

Commit bc6d6a5

Browse files
Merge branch 'develop' into add-license-dump-option
Signed-off-by: Ayan Sinha Mahapatra <[email protected]>
2 parents 8b2bbfe + c108206 commit bc6d6a5

File tree

179 files changed

+3516
-1478
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

179 files changed

+3516
-1478
lines changed

CHANGELOG.rst

+21-1
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,34 @@ License detection:
4646
matches in a larger license detecion. This remove a larger number of false
4747
positive or ambiguous license detections.
4848

49-
5049
- The data structure of the JSON output has changed for licenses. We now
5150
return match details once for each matched license expression rather than
5251
once for each license in a matched expression. There is a new top-level
5352
"license_references" attribute that contains the data details for each
5453
detected license only once. This data can contain the reference license text
5554
as an option.
5655

56+
- We can now detect licenses using custom license texts and license rules.
57+
These can be provided as a one off in a directory or packaged as a plugin
58+
for consistent reuse and deployment.
59+
60+
- There is a new "scancode-reindex-licenses" command that replace the
61+
"scancode --reindex-licenses" command line option which has been
62+
removed. This new command supports simpler reindexing using custom
63+
license texts and license rules contributed by plugins or stored in an
64+
additional directory.
65+
66+
Package detection:
67+
~~~~~~~~~~~~~~~~~~~~~
68+
69+
- Code for parsing a Maven POM, npm package.json, freebsd manifest and haxelib
70+
JSON have been separated into two functions: one that creates a PackageData
71+
object from the parsed Resource, and another that calls the previous function
72+
and yields the PackageData. This was done such that we can use the package
73+
manifest data parsing code outside of the scancode-toolkit context in other
74+
libraries.
75+
76+
5777
v31.2.1 - 2022-10-05
5878
----------------------------------
5979

azure-pipelines.yml

+13
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ jobs:
3333
--ignore=tests/licensedcode/test_detection_datadriven2.py \
3434
--ignore=tests/licensedcode/test_detection_datadriven3.py \
3535
--ignore=tests/licensedcode/test_detection_datadriven4.py \
36+
--ignore=tests/licensedcode/test_additional_license.py \
3637
tests/licensedcode
3738
3839
license_datadriven1_2: |
@@ -78,6 +79,18 @@ jobs:
7879
venv/bin/pytest -n 3 -vvs --test-suite=all \
7980
tests/licensedcode/test_zzzz_cache.py
8081
82+
# this test runs in isolation because it modifies the actual
83+
# license index with additional licenses provided by a plugin
84+
# and we use the special --test-suite=plugins marker for these
85+
# tests
86+
additional_license_combined: |
87+
venv/bin/pip install tests/licensedcode/data/additional_licenses/additional_plugin_1/
88+
venv/bin/pip install tests/licensedcode/data/additional_licenses/additional_plugin_2/
89+
venv/bin/scancode-reindex-licenses \
90+
--additional-directory tests/licensedcode/data/additional_licenses/additional_dir/
91+
venv/bin/pytest -vvs --test-suite=plugins \
92+
tests/licensedcode/test_additional_license.py
93+
8194
- template: etc/ci/azure-posix.yml
8295
parameters:
8396
job_name: ubuntu18_cpython

conftest.py

+17-2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
################################################################################
3939
SLOW_TEST = 'scanslow'
4040
VALIDATION_TEST = 'scanvalidate'
41+
PLUGINS_TEST = 'scanplugins'
4142

4243

4344
def pytest_configure(config):
@@ -53,8 +54,14 @@ def pytest_configure(config):
5354
': Mark a ScanCode test as a validation test, super slow, long running test.',
5455
)
5556

57+
config.addinivalue_line(
58+
'markers',
59+
PLUGINS_TEST +
60+
': Mark a ScanCode test as a special CI test to tests installing additional plugins.',
61+
)
62+
5663

57-
TEST_SUITES = 'standard', 'all', 'validate'
64+
TEST_SUITES = ('standard', 'all', 'validate', 'plugins',)
5865

5966

6067
def pytest_addoption(parser):
@@ -72,9 +79,11 @@ def pytest_addoption(parser):
7279
help='Select which test suite to run: '
7380
'"standard" runs the standard test suite designed to run reasonably fast. '
7481
'"all" runs "standard" and "slow" (long running) tests. '
75-
'"validate" runs all the tests. '
82+
'"validate" runs all the tests, except the "plugins" tests. '
83+
'"plugins" runs special plugins tests. Needs extra setup, and is used only in the CI. '
7684
'Use the @pytest.mark.scanslow marker to mark a test as "slow" test. '
7785
'Use the @pytest.mark.scanvalidate marker to mark a test as a "validate" test.'
86+
'Use the @pytest.mark.scanplugins marker to mark a test as a "plugins" test.'
7887
)
7988

8089
################################################################################
@@ -87,13 +96,19 @@ def pytest_collection_modifyitems(config, items):
8796
test_suite = config.getvalue('test_suite')
8897
run_everything = test_suite == 'validate'
8998
run_slow_test = test_suite in ('all', 'validate')
99+
run_only_plugins = test_suite == 'plugins'
90100

91101
tests_to_run = []
92102
tests_to_skip = []
93103

94104
for item in items:
95105
is_validate = bool(item.get_closest_marker(VALIDATION_TEST))
96106
is_slow = bool(item.get_closest_marker(SLOW_TEST))
107+
is_plugins = bool(item.get_closest_marker(PLUGINS_TEST))
108+
109+
if is_plugins and not run_only_plugins:
110+
tests_to_skip.append(item)
111+
continue
97112

98113
if is_validate and not run_everything:
99114
tests_to_skip.append(item)

docs/source/cli-reference/core-options.rst

-16
Original file line numberDiff line numberDiff line change
@@ -69,22 +69,6 @@ Comparing Progress Message Options
6969

7070
----
7171

72-
``--reindex-licenses`` Option
73-
-----------------------------
74-
75-
ScanCode maintains a license index to search for and detect licenses. When Scancode is
76-
configured for the first time, a license index is built and used in every scan thereafter.
77-
78-
This ``--reindex-licenses`` option rebuilds the license index. Running a scan with this option
79-
displays the following message to the terminal in addition to what it normally shows::
80-
81-
Checking and rebuilding the license index...
82-
83-
..
84-
[ToDo] Research and Write Better
85-
86-
----
87-
8872
``--from-json`` Option
8973
----------------------
9074

0 commit comments

Comments
 (0)