Skip to content

Automatic UI tests#381

Merged
mattias-p merged 10 commits intozonemaster:developfrom
mattias-p:usage-tests
Sep 20, 2024
Merged

Automatic UI tests#381
mattias-p merged 10 commits intozonemaster:developfrom
mattias-p:usage-tests

Conversation

@mattias-p
Copy link
Member

@mattias-p mattias-p commented Jul 26, 2024

Purpose

This PR adds a framework for automatic testing of the user interface of zonemaster-cli.

To validate the design of the framework I've added a large amount of tests providing good coverage of validation and happy paths of command line options. Please let me know if I've missed anything so I can add it in a followup PR. The only options I know I've left out are --save and --restore.

Context

I made this to be able to ensure good test coverage when migrating away from MooseX::Getopt::GLD without having to perform excessive amounts of manual testing.

Changes

The most important part of this PR is the introduction of t/usage.t hosting a testing framework (check_success() and check_usage_error()) as well as a battery of tests. The framework relies on a wrapper script t/usage.wrapper.pl that acts as a test harness.

The added tests are categorized into four groups. Each group uses a separate file for recorded data.

  • tests that doesn't use network at all
  • tests that only uses real network data
  • tests that use real root and fake data
  • tests that use fake root

I found a couple of bugs when adding these tests and I've included fixes for most of those as well.

I've moved all calls to exit from Zonemaster::CLI into zonemaster-cli. This way the wrapper can perform its cleanup.

Zonemaster::CLI is updated to print errors to STDERR and return exit status 2 on usage errors. This is conventional and allows for more accurate testing.

zonemaster-cli is updated to exit with status 1 if Zonemaster::CLI throws an exception. We didn't really exert much control over these exit statuses before.

Some PO files that apparently are untidy in develop are tidied to make t/po-files.t happy.

How to test this PR

Run t/usage.t.

@mattias-p mattias-p marked this pull request as draft July 26, 2024 16:13
@mattias-p mattias-p marked this pull request as ready for review July 26, 2024 16:15
tgreenx
tgreenx previously approved these changes Aug 20, 2024
Copy link
Contributor

@tgreenx tgreenx left a comment

Choose a reason for hiding this comment

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

Great work ! I reviewed as much as I could, and didn't find any obvious issue (and also after manual testing). Moreover the t/usage.t file is quite large and should provide good coverage.

Note that the PR was missing a version tag, so I added V-Minor for now but the updated exit codes (i.e. 0, 1 and 2 instead of just 0 and 1) could justify a V-Major.

@tgreenx tgreenx added the V-Minor Versioning: The change gives an update of minor in version. label Aug 20, 2024
Copy link
Contributor

@matsduf matsduf left a comment

Choose a reason for hiding this comment

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

Press return to run 'make distcheck'...
"/usr/local/bin/perl" "-Iinc" "-MExtUtils::Manifest=fullcheck" -e fullcheck
Not in MANIFEST: t/usage.fake-data.data
Not in MANIFEST: t/usage.fake-root.data
Not in MANIFEST: t/usage.hints
Not in MANIFEST: t/usage.normal.data
Not in MANIFEST: t/usage.profile
Not in MANIFEST: t/usage.t
Not in MANIFEST: t/usage.wrapper.pl

@mattias-p
Copy link
Member Author

I've updated the MANIFEST file. Please approve/review again.

@tgreenx tgreenx requested review from matsduf and tgreenx September 19, 2024 13:39
@matsduf
Copy link
Contributor

matsduf commented Sep 19, 2024

Since it is a API change a V-Major is justified.

@mattias-p mattias-p added V-Major Versioning: The change gives an update of major in version. and removed V-Minor Versioning: The change gives an update of minor in version. labels Sep 20, 2024
@mattias-p
Copy link
Member Author

Thanks for reviewing!

@mattias-p mattias-p merged commit eec57b9 into zonemaster:develop Sep 20, 2024
@mattias-p mattias-p deleted the usage-tests branch November 25, 2024 15:01
@matsduf matsduf added V-Patch Versioning: The change gives an update of patch in version. and removed V-Major Versioning: The change gives an update of major in version. labels Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

V-Patch Versioning: The change gives an update of patch in version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants