Skip to content

Commit

Permalink
Merge branch 'main' into feature/suppress_flask_warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
M6AI authored Sep 28, 2023
2 parents d87f093 + 5e9041e commit 5f9ea64
Show file tree
Hide file tree
Showing 11 changed files with 539 additions and 205 deletions.
1 change: 1 addition & 0 deletions doc/newsfragments/1642_new.json_lister.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added a new lister that dumping testplan metadata to json. Try `--info json` to dump to stdout or `--info json:/var/tmp/tests.json` to dump to a file.
25 changes: 25 additions & 0 deletions testplan/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Testplan base module."""
import argparse
import json
import os
import random
import signal
Expand All @@ -15,6 +16,7 @@
from testplan.common.config import ConfigOption
from testplan.common.utils import logger, path
from testplan.common.utils.callable import arity
from testplan.common.utils.logger import TESTPLAN_LOGGER
from testplan.common.utils.validation import has_method, is_subclass
from testplan.environment import Environments
from testplan.parser import TestplanParser
Expand All @@ -23,6 +25,8 @@
from testplan.runners.local import LocalRunner
from testplan.runners.base import Executor
from testplan.testing import filtering, ordering
from testplan.testing.listing import Lister, MetadataBasedLister
from testplan.testing.multitest.test_metadata import TestPlanMetadata


def pdb_drop_handler(sig, frame):
Expand Down Expand Up @@ -160,6 +164,8 @@ class Testplan(entity.RunnableManager):
:param test_lister: Tests listing class.
:type test_lister: Subclass of
:py:class:`BaseLister <testplan.testing.listing.BaseLister>`
:param test_lister_output: listing results goes to this file, if None goes to stdout
:type test_lister: PathLike object
:param verbose: Enable or disable verbose mode.
:type verbose: ``bool``
:param debug: Enable or disable debug mode.
Expand Down Expand Up @@ -215,6 +221,7 @@ def __init__(
test_filter=filtering.Filter(),
test_sorter=ordering.NoopSorter(),
test_lister=None,
test_lister_output=None,
verbose=False,
debug=False,
timeout=defaults.TESTPLAN_TIMEOUT,
Expand Down Expand Up @@ -274,6 +281,7 @@ def __init__(
test_filter=test_filter,
test_sorter=test_sorter,
test_lister=test_lister,
test_lister_output=test_lister_output,
verbose=verbose,
debug=debug,
timeout=timeout,
Expand Down Expand Up @@ -416,6 +424,7 @@ def main_wrapper(
test_filter=filtering.Filter(),
test_sorter=ordering.NoopSorter(),
test_lister=None,
test_lister_output=None,
verbose=False,
debug=False,
timeout=defaults.TESTPLAN_TIMEOUT,
Expand Down Expand Up @@ -474,6 +483,7 @@ def test_plan_inner_inner():
test_filter=test_filter,
test_sorter=test_sorter,
test_lister=test_lister,
test_lister_output=test_lister_output,
verbose=verbose,
debug=debug,
timeout=timeout,
Expand All @@ -494,6 +504,21 @@ def test_plan_inner_inner():
plan.abort()
raise

lister: MetadataBasedLister = plan.cfg.test_lister
if lister is not None and lister.metadata_based:
output = lister.get_output(
TestPlanMetadata(
plan.cfg.name,
plan.cfg.description,
plan.get_test_metadata(),
)
)
if plan.cfg.test_lister_output:
with open(plan.cfg.test_lister_output, "wt") as file:
file.write(output)
else:
TESTPLAN_LOGGER.user_info(output)

plan_result = plan.run()
plan_result.decorated_value = returned
return plan_result
Expand Down
Loading

0 comments on commit 5f9ea64

Please sign in to comment.