Skip to content

tests: run test against actual schema files, not snapshots #256

Closed
1 of 1 issue completed
Closed

Description

@jkowalleck

Current implementation of java tests run against a snapshot of the schema files, shipped with org.cyclinedx java package.
This is undesired and error-prone, as changes to the schema files in this repo are not checked against the schema example files.
Therefore, most java checks in pull requests are just bogus results without any meaning.
This must change ASAP.

Use cases:

  • a PullRequest is opened, that modifies a schema file. tests must run based on these changes, not some snapshots.
  • a PullRequest is opened, that modify some test-resources. tests must run based on these changes.

acceptance criteria

  • all test run against the actual schema files in this repo, not against any other snapshots
  • optional, but preferred: tests run offline, do not load any data from external sources
  • all currently running tests still pass

scope

targets

out of scope (since already fixed/done)

  • PHP tests -- done, uses local versions
  • JS tests -- done, uses local versions
  • ProtoBuf tests -- done, uses local versions
    • see
      function validate() {
      FILE="$1"
      SCHEMA_VERS="$2"
      SCHEMA_FILE="bom-${SCHEMA_VERS}.proto"
      MESSAGE="cyclonedx.v${SCHEMA_VERS/./_}.Bom"
      echo ">> validate $(realpath --relative-to="$PWD" "$FILE") as ${MESSAGE} of ${SCHEMA_FILE}" >&2
      # this test method is a bare minimum, and it might not detect all kinds of malformed input.
      # could be improved by utilizing protoc -- see https://github.com/CycloneDX/specification/pull/385/commits/8db0967c11cb913ac3c7a9a037159338df3f3bd9
      docker run --rm \
      --volume "${ROOT_PATH}/${SCHEMA_DIR}:/workspace/${SCHEMA_DIR}:ro" \
      --volume "${FILE}:/workspace/test_res:ro" \
      --workdir '/workspace' \
      bufbuild/buf:"$BUF_IMAGE_VERSION" \
      convert "${SCHEMA_DIR}/${SCHEMA_FILE}" \
      --type "$MESSAGE" \
      --from 'test_res#format=txtpb' \
      --to /dev/null
      }
      shopt -s globstar
      for test_res in "$ROOT_PATH"/"$TEST_RES_DIR"/*/valid-*.textproto
      do
      SCHEMA_VERS="$(basename "$(dirname "$test_res")")"
      validate "$test_res" "$SCHEMA_VERS"
      done

caused by #255
related: https://cyclonedx.slack.com/archives/G01PMU9ERJA/p1687363757137109

Sub-issues

Sub-issues

1 of 1 Issues completed
Loading 1 sub-issues

Activity

  1. jkowalleck commented on Jun 21, 2023

    @jkowalleck
    MemberAuthor

    @CycloneDX/core-team FYI

    @CycloneDX/java-maintainers can you help out and fix the tests?

  2. changed the title [-]tests: tun Java test against local schema files[/-] [+]tests: run Java test against actual schema files, not snapshots[/+] on Jun 21, 2023
  3. stevespringett commented on Jun 22, 2023

    @stevespringett
    Member

    The latest schema from the 1.5-dev branch has been incorporated into the latest Core Java 7.4.0-SNAPSHOT

  4. jkowalleck commented on Jun 22, 2023

    @jkowalleck
    MemberAuthor

    re: #256 (comment)
    this does not solve the following purpose: a PR modifies the schema files. tests should run on these changes, not some snapshot. here is such a case: #255

  5. changed the title [-]tests: run Java test against actual schema files, not snapshots[/-] [+]tests: run test against actual schema files, not snapshots[/+] on Jun 22, 2023
  6. jkowalleck commented on Jul 10, 2023

    @jkowalleck
    MemberAuthor

    @mr-zepol mentioned he might be able to help out here.

  7. added
    test-data
    on Dec 12, 2023
  8. added a commit that references this issue on Jan 22, 2025
  9. jkowalleck commented on Jan 22, 2025

    @jkowalleck
    MemberAuthor

    the situation with java tests is so annoying.
    i am going to tackle this, now.

  10. self-assigned this
    on Jan 22, 2025
  11. ppkarwasz commented on Jan 22, 2025

    @ppkarwasz
    Contributor

    the situation with java tests is so annoying. i am going to tackle this, now.

    I can look at it in the weekend.

  12. 6 remaining items

  13. added 2 commits that reference this issue on Feb 9, 2025
    ee77f65
    08e3851
  14. ppkarwasz commented on Feb 9, 2025

    @ppkarwasz
    Contributor

    @jkowalleck,

    I fixed the tests in #592.

  15. added a commit that references this issue on Feb 17, 2025
    d570ffb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

choretest-data

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions