Skip to content

Commit

Permalink
Merge branch 'develop' into add-license-dump-option
Browse files Browse the repository at this point in the history
Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
  • Loading branch information
AyanSinhaMahapatra committed Nov 1, 2022
2 parents 8b2bbfe + c108206 commit 8b1d58e
Show file tree
Hide file tree
Showing 178 changed files with 3,527 additions and 1,474 deletions.
22 changes: 21 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,34 @@ License detection:
matches in a larger license detecion. This remove a larger number of false
positive or ambiguous license detections.


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

- We can now detect licenses using custom license texts and license rules.
These can be provided as a one off in a directory or packaged as a plugin
for consistent reuse and deployment.

- There is a new "scancode-reindex-licenses" command that replace the
"scancode --reindex-licenses" command line option which has been
removed. This new command supports simpler reindexing using custom
license texts and license rules contributed by plugins or stored in an
additional directory.

Package detection:
~~~~~~~~~~~~~~~~~~~~~

- Code for parsing a Maven POM, npm package.json, freebsd manifest and haxelib
JSON have been separated into two functions: one that creates a PackageData
object from the parsed Resource, and another that calls the previous function
and yields the PackageData. This was done such that we can use the package
manifest data parsing code outside of the scancode-toolkit context in other
libraries.


v31.2.1 - 2022-10-05
----------------------------------

Expand Down
13 changes: 13 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
--ignore=tests/licensedcode/test_detection_datadriven2.py \
--ignore=tests/licensedcode/test_detection_datadriven3.py \
--ignore=tests/licensedcode/test_detection_datadriven4.py \
--ignore=tests/licensedcode/test_additional_license.py \
tests/licensedcode
license_datadriven1_2: |
Expand Down Expand Up @@ -78,6 +79,18 @@ jobs:
venv/bin/pytest -n 3 -vvs --test-suite=all \
tests/licensedcode/test_zzzz_cache.py
# this test runs in isolation because it modifies the actual
# license index with additional licenses provided by a plugin
# and we use the special --test-suite=plugins marker for these
# tests
additional_license_combined: |
venv/bin/pip install tests/licensedcode/data/additional_licenses/additional_plugin_1/
venv/bin/pip install tests/licensedcode/data/additional_licenses/additional_plugin_2/
venv/bin/scancode-reindex-licenses \
--additional-directory tests/licensedcode/data/additional_licenses/additional_dir/
venv/bin/pytest -vvs --test-suite=plugins \
tests/licensedcode/test_additional_license.py
- template: etc/ci/azure-posix.yml
parameters:
job_name: ubuntu18_cpython
Expand Down
19 changes: 17 additions & 2 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
################################################################################
SLOW_TEST = 'scanslow'
VALIDATION_TEST = 'scanvalidate'
PLUGINS_TEST = 'scanplugins'


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

config.addinivalue_line(
'markers',
PLUGINS_TEST +
': Mark a ScanCode test as a special CI test to tests installing additional plugins.',
)


TEST_SUITES = 'standard', 'all', 'validate'
TEST_SUITES = ('standard', 'all', 'validate', 'plugins',)


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

################################################################################
Expand All @@ -87,13 +96,19 @@ def pytest_collection_modifyitems(config, items):
test_suite = config.getvalue('test_suite')
run_everything = test_suite == 'validate'
run_slow_test = test_suite in ('all', 'validate')
run_only_plugins = test_suite == 'plugins'

tests_to_run = []
tests_to_skip = []

for item in items:
is_validate = bool(item.get_closest_marker(VALIDATION_TEST))
is_slow = bool(item.get_closest_marker(SLOW_TEST))
is_plugins = bool(item.get_closest_marker(PLUGINS_TEST))

if is_plugins and not run_only_plugins:
tests_to_skip.append(item)
continue

if is_validate and not run_everything:
tests_to_skip.append(item)
Expand Down
16 changes: 0 additions & 16 deletions docs/source/cli-reference/core-options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,6 @@ Comparing Progress Message Options

----

``--reindex-licenses`` Option
-----------------------------

ScanCode maintains a license index to search for and detect licenses. When Scancode is
configured for the first time, a license index is built and used in every scan thereafter.

This ``--reindex-licenses`` option rebuilds the license index. Running a scan with this option
displays the following message to the terminal in addition to what it normally shows::

Checking and rebuilding the license index...

..
[ToDo] Research and Write Better
----

``--from-json`` Option
----------------------

Expand Down
Loading

0 comments on commit 8b1d58e

Please sign in to comment.