chore: migrate fixtures to testdata (#4651)

* migrate fixtures to testdata

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* fix: correct broken symlinks after testdata migration

The migration from test-fixtures to testdata broke several symlinks:
- elf-test-fixtures symlinks pointed to old test-fixtures paths
- elf-test-fixtures needed to be renamed to elf-testdata
- image-pkg-coverage symlink pointed to test-fixtures instead of testdata

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* fix: handle missing classifiers/bin directory in Makefile

The clean-fingerprint target was failing when classifiers/bin doesn't
exist (e.g., on fresh clone without downloaded binaries).

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* fix: add gitignore negation for jar/zip fixtures in test/cli

The jar and zip files in test/cli/testdata/image-unknowns were being
gitignored by the root .gitignore patterns. This caused them to be
untracked and not included when building docker images in CI, resulting
in Test_Unknowns failures since the test expects errors from corrupt
archive files that weren't present.

Add a .gitignore in test/cli/testdata to negate the exclusions for
these specific test fixture files.

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* switch fixture cache to v2

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* test: update expected versions for rebuilt fixtures

Update test expectations for packages that have been updated in
upstream repositories when docker images are rebuilt:
- glibc: 2.42-r4 → 2.43-r1 (wolfi)
- php: 8.2.29 → 8.2.30 (ubuntu/apache)

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* upgrade go

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* fix: add go-shlex dependency for testdata manager tool

The manager tool in syft/pkg/cataloger/binary/testdata/ imports
go-shlex, but since it's in a testdata directory, Go doesn't track
its dependencies. This caused CI failures when go.mod didn't
explicitly list the dependency.

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* refactor: move binary classifier manager to internal/

Move the manager tool from testdata/manager to internal/manager so
that Go properly tracks its dependencies. Code in testdata directories
is ignored by Go for dependency tracking, which caused CI failures
when go.mod didn't explicitly list transitive dependencies.

This is a cleaner solution than manually adding dependencies to go.mod
for code that happens to live in testdata.

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* fix: add gitignore negations for test fixtures blocked by root patterns

Multiple test fixtures were being blocked by root-level gitignore patterns
like bin/, *.jar, *.tar, and *.exe. This adds targeted .gitignore files with
negation patterns to allow these specific test fixtures to be tracked:

- syft/linux/testdata/os/busybox/bin/busybox (blocked by bin/)
- syft/pkg/cataloger/java/testdata/corrupt/example.{jar,tar} (blocked by *.jar, *.tar)
- syft/pkg/cataloger/binary/testdata/classifiers/snippets/go-version-hint/**/bin/go (blocked by bin/)
- syft/pkg/cataloger/bitnami/testdata/no-rel/.../bin/redis-server (blocked by bin/)

Also updates the bitnami test expectation to include the newly required
.gitignore files in the test fixture.

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* test: update glibc version expectation (2.43-r1 -> 2.43-r2)

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* add capability drift check as unit step

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* dont clear test observations before drift detection

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* bump stereoscope commit to main

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

---------

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
Alex Goodman
2026-03-06 19:42:04 +00:00
committed by GitHub
parent 35278f3d3d
commit b5e85c3ea5
1589 changed files with 1184 additions and 1058 deletions
+2 -2
View File
@@ -25,7 +25,7 @@ func TestAllFormatsConvertable(t *testing.T) {
{to: "syft-json", from: "spdx-json"},
{to: "syft-json", from: "cyclonedx-json"},
{to: "spdx-json", from: "syft-json"},
{to: "template", from: "syft-json", template: "test-fixtures/csv.template"},
{to: "template", from: "syft-json", template: "testdata/csv.template"},
{to: "spdx-json", from: "cyclonedx-json"},
{to: "cyclonedx-json", from: "syft-json"},
{to: "cyclonedx-json", from: "spdx-json"},
@@ -33,7 +33,7 @@ func TestAllFormatsConvertable(t *testing.T) {
for _, test := range tests {
t.Run(fmt.Sprintf("from %s to %s", test.from, test.to), func(t *testing.T) {
sbomArgs := []string{"dir:./test-fixtures/image-pkg-coverage", "-o", test.from}
sbomArgs := []string{"dir:./testdata/image-pkg-coverage", "-o", test.from}
cmd, stdout, stderr := runSyft(t, test.env, sbomArgs...)
if cmd.ProcessState.ExitCode() != 0 {
t.Log("STDOUT:\n", stdout)
+3 -3
View File
@@ -26,9 +26,9 @@ func TestAllFormatsExpressible(t *testing.T) {
require.NotEmpty(t, formatIDs)
for _, o := range formatIDs {
t.Run(fmt.Sprintf("format:%s", o), func(t *testing.T) {
args := []string{"dir:./test-fixtures/image-pkg-coverage", "-o", string(o)}
args := []string{"dir:./testdata/image-pkg-coverage", "-o", string(o)}
if o == template.ID {
args = append(args, "-t", "test-fixtures/csv.template")
args = append(args, "-t", "testdata/csv.template")
}
cmd, stdout, stderr := runSyft(t, nil, args...)
@@ -69,7 +69,7 @@ func Test_formatVersionsExpressible(t *testing.T) {
for _, test := range tests {
t.Run(test.format, func(t *testing.T) {
args := []string{"dir:./test-fixtures/image-pkg-coverage", "-o", test.format}
args := []string{"dir:./testdata/image-pkg-coverage", "-o", test.format}
cmd, stdout, stderr := runSyft(t, nil, args...)
test.assertion(t, stdout, stderr, cmd.ProcessState.ExitCode())
logOutputOnFailure(t, cmd, stdout, stderr)
+1 -1
View File
@@ -23,7 +23,7 @@ func TestArchiveScan(t *testing.T) {
"scan",
"-o",
"json",
"file:" + createArchive(t, "test-fixtures/archive", t.TempDir()),
"file:" + createArchive(t, "testdata/archive", t.TempDir()),
},
assertions: []traitAssertion{
assertSuccessfulReturnCode,
+1 -1
View File
@@ -15,7 +15,7 @@ func Test_configLoading(t *testing.T) {
require.NoError(t, err)
defer func() { require.NoError(t, os.Chdir(cwd)) }()
configsDir := filepath.Join(cwd, "test-fixtures", "configs")
configsDir := filepath.Join(cwd, "testdata", "configs")
path := func(path string) string {
return filepath.Join(configsDir, filepath.Join(strings.Split(path, "/")...))
}
+1 -1
View File
@@ -34,7 +34,7 @@ func TestConvertCmd(t *testing.T) {
for _, test := range tests {
t.Run(fmt.Sprintf("from %s to %s", test.from, test.to), func(t *testing.T) {
sbomArgs := []string{"dir:./test-fixtures/image-pkg-coverage", "-o", test.from}
sbomArgs := []string{"dir:./testdata/image-pkg-coverage", "-o", test.from}
cmd, stdout, stderr := runSyft(t, nil, sbomArgs...)
if cmd.ProcessState.ExitCode() != 0 {
t.Log("STDOUT:\n", stdout)
+1 -1
View File
@@ -41,7 +41,7 @@ func TestJSONSchema(t *testing.T) {
subcommand: "scan",
args: []string{"-o", "json"},
fixture: func(t *testing.T) string {
return "dir:test-fixtures/image-pkg-coverage"
return "dir:testdata/image-pkg-coverage"
},
},
}
+1 -1
View File
@@ -39,7 +39,7 @@ func TestSPDXJSONSchema(t *testing.T) {
subcommand: "scan",
args: []string{"-o", "spdx-json"},
fixture: func(t *testing.T) string {
return "dir:test-fixtures/image-pkg-coverage"
return "dir:testdata/image-pkg-coverage"
},
},
}
+1 -1
View File
@@ -96,7 +96,7 @@ func TestSpdxValidationTooling(t *testing.T) {
imageArg := fmt.Sprintf("IMAGE=%s", imgTag)
validateCmd := exec.Command("make", "validate", fileArg, mountArg, imageArg)
validateCmd.Dir = filepath.Join(cwd, "test-fixtures", "image-java-spdx-tools")
validateCmd.Dir = filepath.Join(cwd, "testdata", "image-java-spdx-tools")
stdout, stderr, err := runCommand(validateCmd, map[string]string{})
if err != nil {
+1 -1
View File
@@ -8,7 +8,7 @@ import (
func Test_RequestedPathIncludesSymlink(t *testing.T) {
// path contains a symlink
path := "test-fixtures/image-pkg-coverage/pkgs/java/example-java-app-maven-0.1.0.jar"
path := "testdata/image-pkg-coverage/pkgs/java/example-java-app-maven-0.1.0.jar"
_, stdout, _ := runSyft(t, nil, "scan", path)
assert.Contains(t, stdout, "example-java-app-maven")
}
@@ -1 +0,0 @@
../../../cmd/syft/internal/test/integration/test-fixtures/image-pkg-coverage
+3
View File
@@ -0,0 +1,3 @@
# negate jar and zip exclusions for test fixtures that need these file types
!image-unknowns/*.jar
!image-unknowns/*.zip
+1
View File
@@ -0,0 +1 @@
../../../cmd/syft/internal/test/integration/testdata/image-pkg-coverage
+1 -1
View File
@@ -11,7 +11,7 @@ TEST_TYPE=deb
WORK_DIR=`mktemp -d -t "syft-acceptance-test-${TEST_TYPE}-XXXXXX"`
NORMAL_TEST_IMAGE=$(echo ${TEST_IMAGE} | tr ':' '-' )
REPORT=${WORK_DIR}/acceptance-${TEST_TYPE}-${NORMAL_TEST_IMAGE}.json
GOLDEN_REPORT=${ACC_DIR}/test-fixtures/acceptance-${NORMAL_TEST_IMAGE}.json
GOLDEN_REPORT=${ACC_DIR}/testdata/acceptance-${NORMAL_TEST_IMAGE}.json
# check if tmp dir was created
if [[ ! "${WORK_DIR}" || ! -d "${WORK_DIR}" ]]; then
+1 -1
View File
@@ -12,7 +12,7 @@ TEST_TYPE=mac
WORK_DIR=`mktemp -d -t "syft-acceptance-test-${TEST_TYPE}-XXXXXX"`
NORMAL_TEST_IMAGE=$(echo ${TEST_IMAGE} | tr ':' '-' )
REPORT=${WORK_DIR}/acceptance-${TEST_TYPE}-${NORMAL_TEST_IMAGE}.json
GOLDEN_REPORT=${ACC_DIR}/test-fixtures/acceptance-${NORMAL_TEST_IMAGE}.json
GOLDEN_REPORT=${ACC_DIR}/testdata/acceptance-${NORMAL_TEST_IMAGE}.json
# check if tmp dir was created
if [[ ! "${WORK_DIR}" || ! -d "${WORK_DIR}" ]]; then
+1 -1
View File
@@ -12,7 +12,7 @@ TEST_TYPE=rpm
WORK_DIR=`mktemp -d -t "syft-acceptance-test-${TEST_TYPE}-XXXXXX"`
NORMAL_TEST_IMAGE=$(echo ${TEST_IMAGE} | tr ':' '-' )
REPORT=${WORK_DIR}/acceptance-${TEST_TYPE}-${NORMAL_TEST_IMAGE}.json
GOLDEN_REPORT=${ACC_DIR}/test-fixtures/acceptance-${NORMAL_TEST_IMAGE}.json
GOLDEN_REPORT=${ACC_DIR}/testdata/acceptance-${NORMAL_TEST_IMAGE}.json
# check if tmp dir was created
if [[ ! "${WORK_DIR}" || ! -d "${WORK_DIR}" ]]; then
+7 -7
View File
@@ -2,7 +2,7 @@
# search for an asset in a release checksums file
test_search_for_asset_release() {
fixture=./test-fixtures/syft_0.36.0_checksums.txt
fixture=./testdata/syft_0.36.0_checksums.txt
# search_for_asset [checksums-file-path] [name] [os] [arch] [format]
@@ -24,7 +24,7 @@ run_test_case test_search_for_asset_release
# search for an asset in a snapshot checksums file
test_search_for_asset_snapshot() {
fixture=./test-fixtures/syft_0.35.1-SNAPSHOT-d461f63_checksums.txt
fixture=./testdata/syft_0.35.1-SNAPSHOT-d461f63_checksums.txt
# search_for_asset [checksums-file-path] [name] [os] [arch] [format]
@@ -42,7 +42,7 @@ run_test_case test_search_for_asset_snapshot
# verify 256 digest of a file
test_hash_sha256() {
target=./test-fixtures/assets/valid/syft_1.5.0_linux_arm64.tar.gz
target=./testdata/assets/valid/syft_1.5.0_linux_arm64.tar.gz
# hash_sha256 [target]
@@ -61,8 +61,8 @@ test_hash_sha256_verify() {
# positive case
checksums=./test-fixtures/assets/valid/checksums.txt
target=./test-fixtures/assets/valid/syft_1.5.0_linux_arm64.tar.gz
checksums=./testdata/assets/valid/checksums.txt
target=./testdata/assets/valid/syft_1.5.0_linux_arm64.tar.gz
hash_sha256_verify "${target}" "${checksums}"
assertEquals "0" "$?" "mismatched checksum"
@@ -73,8 +73,8 @@ test_hash_sha256_verify() {
# we are expecting error messages, which is confusing to look at in passing tests... disable logging for now
log_set_priority -1
checksums=./test-fixtures/assets/invalid/checksums.txt
target=./test-fixtures/assets/invalid/syft_1.5.0_linux_arm64.tar.gz
checksums=./testdata/assets/invalid/checksums.txt
target=./testdata/assets/invalid/syft_1.5.0_linux_arm64.tar.gz
hash_sha256_verify "${target}" "${checksums}"
assertEquals "1" "$?" "verification did not catch mismatched checksum"
+3 -3
View File
@@ -2,7 +2,7 @@
# check that we can extract single json values
test_extract_json_value() {
fixture=./test-fixtures/github-api-syft-v0.36.0-release.json
fixture=./testdata/github-api-syft-v0.36.0-release.json
content=$(cat ${fixture})
actual=$(extract_json_value "${content}" "tag_name")
@@ -17,7 +17,7 @@ run_test_case test_extract_json_value
# check that we can extract github release tag from github api json
test_github_release_tag() {
fixture=./test-fixtures/github-api-syft-v0.36.0-release.json
fixture=./testdata/github-api-syft-v0.36.0-release.json
content=$(cat ${fixture})
actual=$(github_release_tag "${content}")
@@ -38,7 +38,7 @@ test_download_github_release_checksums() {
actual_filepath=$(download_github_release_checksums "${github_download}" "${name}" "${version}" "${tmpdir}")
assertFilesEqual \
"./test-fixtures/syft_0.36.0_checksums.txt" \
"./testdata/syft_0.36.0_checksums.txt" \
"${actual_filepath}" \
"unable to find release tag"