forked from fediverse-devnet/feditest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now recording everything in a TestRun regardless of what we want to r…
…eport on New classes XXXTranscript for JSON-based serialization and deserialization of full TestRun transcripts per fediverse-devnet#103 Distinguish between hard failures, soft failures, degradations, errors: use new feditest.xxx_assert_that instead of Hamcrest assert_that to raise different kinds of problems per fediverse-devnet#83 A TestRunController decides what to do next after a session, test, or step has been executed; automatic and interactive implementations per fediverse-devnet#79 Simplified result reporting implementations, can report in several formats, also addresses fediverse-devnet#105 New sub-command: convert_transcript Shrunk what needs to be in feditest.__init__.py More consistent object naming when printing to the console FEDITEST_VERSION as a constant Would be surprised if I hadn't broken some stuff, sorry
- Loading branch information
Johannes Ernst
committed
May 15, 2024
1 parent
5b44174
commit 8c574ed
Showing
15 changed files
with
1,143 additions
and
489 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
""" | ||
Convert a TestRunTranscript to a different format | ||
""" | ||
|
||
from argparse import ArgumentParser, Namespace, _SubParsersAction | ||
|
||
from feditest.reporting import warning | ||
from feditest.testruntranscript import TestRunTranscript, TestRunTranscriptSerializer, TapTestRunTranscriptSerializer, HtmlTestRunTranscriptSerializer, JsonTestRunTranscriptSerializer, SummaryTestRunTranscriptSerializer | ||
from feditest.utils import FEDITEST_VERSION | ||
|
||
def run(parser: ArgumentParser, args: Namespace, remaining: list[str]) -> int: | ||
""" | ||
Run this command. | ||
""" | ||
|
||
transcript = TestRunTranscript.load(args.in_file) | ||
if not transcript.has_compatible_version(): | ||
warning(f'Transcript was created by FediTest { transcript.feditest_version }, you are running FediTest { FEDITEST_VERSION }: incompatibilities may occur.') | ||
|
||
serializer : TestRunTranscriptSerializer | None = None | ||
if isinstance(args.tap, str) or args.tap: | ||
serializer = TapTestRunTranscriptSerializer(transcript) | ||
serializer.write(args.tap) | ||
|
||
if isinstance(args.html, str) or args.html: | ||
serializer = HtmlTestRunTranscriptSerializer(transcript) | ||
serializer.write(args.html) | ||
|
||
if isinstance(args.json, str) or args.json: | ||
serializer = JsonTestRunTranscriptSerializer(transcript) | ||
serializer.write(args.json) | ||
|
||
if isinstance(args.summary, str) or args.summary: | ||
serializer = SummaryTestRunTranscriptSerializer(transcript) | ||
serializer.write(args.json) | ||
|
||
return 0 | ||
|
||
|
||
def add_sub_parser(parent_parser: _SubParsersAction, cmd_name: str) -> None: | ||
""" | ||
Add command-line options for this sub-command | ||
parent_parser: the parent argparse parser | ||
cmd_name: name of this command | ||
""" | ||
parser = parent_parser.add_parser(cmd_name, help='Convert a transcript of a TestRun to a different format') | ||
parser.add_argument('--in', required=True, dest="in_file", help='JSON file containing the transcript') | ||
parser.add_argument('--tap', nargs="?", const=True, default=False, | ||
help="Write results in TAP format to stdout, or to the provided file (if given).") | ||
html_group = parser.add_argument_group('html', 'HTML options') | ||
html_group.add_argument('--html', nargs="?", const=True, default=False, | ||
help="Write results in HTML format to stdout, or to the provided file (if given).") | ||
html_group.add_argument('--template', default='report-standalone.jinja2', | ||
help="When specifying --html, use this HTML template (jinja2 format).") | ||
parser.add_argument('--json', nargs="?", const=True, default=False, | ||
help="Write results in JSON format to stdout, or to the provided file (if given).") | ||
parser.add_argument('--summary', nargs="?", const=True, default=False, | ||
help="Write summary to stdout, or to the provided file (if given). This is the default if no other output option is given") |
Oops, something went wrong.