Skip to content

run tests according to purl-test.schema-0.2.json - #106

Open
petergardfjall wants to merge 1 commit into
package-url:masterfrom
petergardfjall:adapt-to-test-schema-0.2
Open

petergardfjall wants to merge 1 commit into
package-url:masterfrom
petergardfjall:adapt-to-test-schema-0.2

Conversation

@petergardfjall

Copy link
Copy Markdown
Collaborator

Updates the test execution and test case parsing for the upstream purl-spec tests.
These tests have been updated (from version 0.1 to 0.2) to follow a new schema: https://github.com/package-url/purl-spec/blob/main/docs/tests/test-schema-changes.md

This PR intends to fix the testsuite execution.

It should be noted that not all tests pass but I think that should be fixed in a separate PR, since it might require more substantial changes to the library (the separation of parsing and validation). The pkg:git testcases are still up for debate also:

$ make test | grep FAIL:
--- FAIL: TestPurlTypes (0.01s)
    --- FAIL: TestPurlTypes/gem-test.json[2]parse (0.00s)
    --- FAIL: TestPurlTypes/git-test.json[1]validate (0.00s)
    --- FAIL: TestPurlTypes/git-test.json[2]parse (0.00s)
    --- FAIL: TestPurlTypes/git-test.json[4]build (0.00s)
    --- FAIL: TestPurlTypes/git-test.json[5]parse (0.00s)
    --- FAIL: TestPurlTypes/git-test.json[7]build (0.00s)
    --- FAIL: TestPurlTypes/rpm-test.json[2]parse (0.00s)
make: *** [Makefile:14: test] Error 1

Comment thread Makefile
git submodule update --init

# Bring in the latest version of the upstream testspec.
testsuite-update: testdata/purl-spec/tests

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Let's make this an explicit step, instead of pulling in changes every time we run make test (which makes testing rely on timing).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yeah, that makes sense.

Comment thread packageurl_test.go
ExpectedOutput ComponentsOrPurl `json:"expected_output"`
ExpectedFailureReason *string `json:"expected_failure_reason"`
// TestGroup indicates a conformance group for a [PurlTest].
type TestGroup string

@petergardfjall petergardfjall Aug 24, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Comment thread packageurl_test.go
if err != nil {
t.Logf("%s failed: %s", tc.Description, err)
t.Fail()
return

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Avoids nil pointer panic. Since we've already failed we can just abort.

Comment thread packageurl_test.go
// TestCoreSpec runs purl-spec tests that are for the core specification and not for a specific PURL
// type.
func TestCoreSpec(t *testing.T) {
testFiles, err := readJSONFilesFromDir("testdata/purl-spec/tests/spec/")

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think we did not run through this test file before, only the files for purl types.

@keshav-space keshav-space left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks @petergardfjall, LGTM! 🙇
Also, we should enter an issue for the failing tests.

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.

2 participants