Skip to content

Introduce an upgrade/downgrade unit tester utility - #12892

Draft
redsun82 wants to merge 1 commit into
mainfrom
redsun82/upgrade-unit-test
Draft

Introduce an upgrade/downgrade unit tester utility#12892
redsun82 wants to merge 1 commit into
mainfrom
redsun82/upgrade-unit-test

Conversation

@redsun82

Copy link
Copy Markdown
Contributor

This is meant specifically for unit testing upgrade/downgrade scripts, that is to throw small DBs at them and checking the effect, without involving the tracer or extractor, using raw trap files instead.

usage: test_upgrade.py [-h] [--learn] [--accept] [--verbose] [DIR ...]
Run upgrade/downgrade scripts unit tests
positional arguments:
  DIR            directories to look for upgrade/downgrade scripts in
options:
  -h, --help     show this help message and exit
  --learn        write down test results in expected files
  --accept       accept actual results
  --verbose, -v  print codeql output

Tests must be contained within a test directory directly within the upgrade/downgrade script directory, and
take the form of a <name>.trap file containing the initial data of the DB and <name>.expected containing a
form of difference between the database before and after the upgrade/downgrade is applied, similar to the format
of codeql database diff. It is required and checked that the initial data is consistent with old.dbscheme, and
it is then checked that final data is consistent with the new dbscheme.
Behavior is similar to codeql test run: if the test fails, a <name>.actual file is created, and --accept
can be later used to accept the test result. --learn can be used to directly write the result in the
<name>.expected file.

Two examples are included, involving a C++ upgrade script and a Swift downgrade one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant