Skip to content

test(sbom): make self-test discoverable + independent SPDX oracle - #16

Open
MarkAtwood wants to merge 2 commits into
masterfrom
fix/test-sbom-discoverable
Open

test(sbom): make self-test discoverable + independent SPDX oracle#16
MarkAtwood wants to merge 2 commits into
masterfrom
fix/test-sbom-discoverable

Conversation

@MarkAtwood

Copy link
Copy Markdown

The self-test's checks lived only in helper functions driven by a check() accumulator — no test_-prefixed callables or TestCase. So pytest tests/ (or python -m unittest tests/test_sbom.py) collected the module and ran nothing while exiting 0 — a silent loss of the only reproducibility / path-scrub / end-to-end coverage if CI ever switched runners.

  • Adds TestSelfTest(unittest.TestCase) with test_unit / test_integration (integration skips cleanly when gen-sbom is absent); the python tests/test_sbom.py entry point is unchanged. Switched the CI step to the discovery path (python -m unittest) so it's exercised — now runs 2 real tests instead of 0.
  • Adds an independent SPDX oracle: validate_sbom.py is a shallow same-repo check, so the integration path also runs external pyspdxtools when installed (skipped otherwise, staying dependency-free).

Addresses SBOM-gpex.13. Note: test_sbom.py is also touched by #12 (capture_macros checks in unit_tests()) — different regions, trivially mergeable.

sameehj and others added 2 commits July 23, 2026 15:54
Signed-off-by: Sameeh Jubran <sameeh@wolfssl.com>
The self-test's checks lived only in helper functions driven by a check()
accumulator, with no test_-prefixed callables or TestCase. `pytest tests/`
(or `python -m unittest tests/test_sbom.py`) therefore collected the
module and ran NOTHING while exiting 0 -- a silent loss of the only
reproducibility / path-scrub / end-to-end coverage if CI ever switched
runners.

Add a TestSelfTest(unittest.TestCase) exposing test_unit and
test_integration (integration skips when gen-sbom is absent), and switch
the CI step to the discovery path so it is exercised. The
`python tests/test_sbom.py` entry point is unchanged.

Also add an independent SPDX oracle: validate_sbom.py is a shallow
same-repo check, so the integration path now also runs the external
pyspdxtools validator when installed (skipped cleanly otherwise).
Copilot AI review requested due to automatic review settings July 24, 2026 03:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes the SBOM self-test reliably executable under standard test runners by adding discoverable unittest entry points, and strengthens SPDX validation by optionally using an external validator as an independent oracle when available.

Changes:

  • Add a unittest.TestCase wrapper (TestSelfTest) so pytest and python -m unittest execute the existing self-test logic instead of collecting zero tests.
  • Extend integration validation to optionally run pyspdxtools against the generated SPDX JSON when the tool is installed.
  • Update the GitHub Actions self-test workflow to run the SBOM self-test via python -m unittest.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
tests/test_sbom.py Adds discoverable unittest entry points and an optional external SPDX validator run during integration tests.
.github/workflows/selftest.yml Switches the CI self-test step to execute via python -m unittest so tests are actually collected and run.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_sbom.py
Comment on lines +152 to +154
rc = subprocess.call(["pyspdxtools", "--infile", spdx],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL)
@sameehj
sameehj force-pushed the master branch 4 times, most recently from 3ab77f9 to 9bdf5b7 Compare July 24, 2026 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants