Skip to content

Tooling to merge and update test vectors #240

Description

@davidben

Jumping off of some of the side discussion in #239, and also what I've observed myself, some way to update and add test vectors would be handy.

What I've been doing is including my scripts in PRs like #238. But those scripts have to import existing tests and modify them in-place, then keep all the IDs and test counts updated. This is a bit tedious. Maybe we can build a tool that improves this.

Thinking aloud, now that we have the source field, perhaps the tool could work something like:

go run ./tools/vectormerge testvectors_v1/foo_test.json -import my_new_tests.json \
    -source github/davidben/my-fancy-new-tests -version 0.1

The tool would:

  1. Check the schema of my_new_tests.json and error if anything is wrong, but maybe be permissive about things like tcId, numberOfTests, source, undefined notes, etc., since we'll fix them anyway.
  2. Look for all existing tests whose source is github/davidben/my-fancy-new-tests. If the version is greater than 0.1, return an error. Otherwise, delete them.
  3. Take all tests from my_new_tests.json. Insert them at...
    • The first position of the first deleted test, if any tests were removed
    • The end if no existing tests were removed
  4. Set the source of any inserted tests with the specified source and version
  5. Renumber tcId and fix numberOfTests
  6. Merge the notes fields, warn or error if there are any conflicts
  7. Format the resulting JSON canonically

Then a generator's job is to only output standalone JSON files, in whatever formatting is convenient, and the actual merge process is taken care of by a common script.

Thoughts?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions