Init: mediaserver

This commit is contained in:
2023-02-08 12:13:28 +01:00
parent 848bc9739c
commit f7c23d4ba9
31914 changed files with 6175775 additions and 0 deletions

View File

@@ -0,0 +1,240 @@
"""Command line parsing for all commands."""
from __future__ import annotations
import argparse
import functools
import sys
from ...util import (
display,
)
from ..completers import (
complete_target,
)
from ..environments import (
CompositeActionCompletionFinder,
)
from .coverage import (
do_coverage,
)
from .env import (
do_env,
)
from .integration import (
do_integration,
)
from .sanity import (
do_sanity,
)
from .shell import (
do_shell,
)
from .units import (
do_units,
)
def do_commands(
parent, # type: argparse.ArgumentParser
completer, # type: CompositeActionCompletionFinder
): # type: (...) -> None
"""Command line parsing for all commands."""
common = argparse.ArgumentParser(add_help=False)
common.add_argument(
'-e',
'--explain',
action='store_true',
help='explain commands that would be executed',
)
common.add_argument(
'-v',
'--verbose',
dest='verbosity',
action='count',
default=0,
help='display more output',
)
common.add_argument(
'--color',
metavar='COLOR',
nargs='?',
help='generate color output: yes, no, auto',
const='yes',
default='auto',
type=color,
)
common.add_argument(
'--debug',
action='store_true',
help='run ansible commands in debug mode',
)
common.add_argument(
'--truncate',
dest='truncate',
metavar='COLUMNS',
type=int,
default=display.columns,
help='truncate some long output (0=disabled) (default: auto)',
)
common.add_argument(
'--redact',
dest='redact',
action='store_true',
default=True,
help=argparse.SUPPRESS, # kept for backwards compatibility, but no point in advertising since it's the default
)
common.add_argument(
'--no-redact',
dest='redact',
action='store_false',
default=False,
help='show sensitive values in output',
)
test = argparse.ArgumentParser(add_help=False, parents=[common])
testing = test.add_argument_group(title='common testing arguments')
testing.add_argument(
'include',
metavar='TARGET',
nargs='*',
help='test the specified target',
).completer = functools.partial(complete_target, completer)
testing.add_argument(
'--include',
metavar='TARGET',
action='append',
help='include the specified target',
).completer = functools.partial(complete_target, completer)
testing.add_argument(
'--exclude',
metavar='TARGET',
action='append',
help='exclude the specified target',
).completer = functools.partial(complete_target, completer)
testing.add_argument(
'--require',
metavar='TARGET',
action='append',
help='require the specified target',
).completer = functools.partial(complete_target, completer)
testing.add_argument(
'--coverage',
action='store_true',
help='analyze code coverage when running tests',
)
testing.add_argument(
'--coverage-check',
action='store_true',
help='only verify code coverage can be enabled',
)
testing.add_argument(
'--metadata',
help=argparse.SUPPRESS,
)
testing.add_argument(
'--base-branch',
metavar='BRANCH',
help='base branch used for change detection',
)
testing.add_argument(
'--changed',
action='store_true',
help='limit targets based on changes',
)
changes = test.add_argument_group(title='change detection arguments')
changes.add_argument(
'--tracked',
action='store_true',
help=argparse.SUPPRESS,
)
changes.add_argument(
'--untracked',
action='store_true',
help='include untracked files',
)
changes.add_argument(
'--ignore-committed',
dest='committed',
action='store_false',
help='exclude committed files',
)
changes.add_argument(
'--ignore-staged',
dest='staged',
action='store_false',
help='exclude staged files',
)
changes.add_argument(
'--ignore-unstaged',
dest='unstaged',
action='store_false',
help='exclude unstaged files',
)
changes.add_argument(
'--changed-from',
metavar='PATH',
help=argparse.SUPPRESS,
)
changes.add_argument(
'--changed-path',
metavar='PATH',
action='append',
help=argparse.SUPPRESS,
)
subparsers = parent.add_subparsers(metavar='COMMAND', required=True)
do_coverage(subparsers, common, completer)
do_env(subparsers, common, completer)
do_shell(subparsers, common, completer)
do_integration(subparsers, test, completer)
do_sanity(subparsers, test, completer)
do_units(subparsers, test, completer)
def color(value): # type: (str) -> bool
"""Strict converter for color option."""
if value == 'yes':
return True
if value == 'no':
return False
if value == 'auto':
return sys.stdout.isatty()
raise argparse.ArgumentTypeError(f"invalid choice: '{value}' (choose from 'yes', 'no', 'auto')")

View File

@@ -0,0 +1,85 @@
"""Command line parsing for all `coverage` commands."""
from __future__ import annotations
import argparse
from ....commands.coverage import (
COVERAGE_GROUPS,
)
from ...environments import (
CompositeActionCompletionFinder,
)
from .analyze import (
do_analyze,
)
from .combine import (
do_combine,
)
from .erase import (
do_erase,
)
from .html import (
do_html,
)
from .report import (
do_report,
)
from .xml import (
do_xml,
)
def do_coverage(
subparsers,
parent, # type: argparse.ArgumentParser
completer, # type: CompositeActionCompletionFinder
): # type: (...) -> None
"""Command line parsing for all `coverage` commands."""
coverage_common = argparse.ArgumentParser(add_help=False, parents=[parent])
parser = subparsers.add_parser(
'coverage',
help='code coverage management and reporting',
)
coverage_subparsers = parser.add_subparsers(metavar='COMMAND', required=True)
do_analyze(coverage_subparsers, coverage_common, completer)
do_erase(coverage_subparsers, coverage_common, completer)
do_combine(coverage_subparsers, parent, add_coverage_common, completer)
do_report(coverage_subparsers, parent, add_coverage_common, completer)
do_html(coverage_subparsers, parent, add_coverage_common, completer)
do_xml(coverage_subparsers, parent, add_coverage_common, completer)
def add_coverage_common(
parser, # type: argparse.ArgumentParser
):
"""Add common coverage arguments."""
parser.add_argument(
'--group-by',
metavar='GROUP',
action='append',
choices=COVERAGE_GROUPS,
help='group output by: %s' % ', '.join(COVERAGE_GROUPS),
)
parser.add_argument(
'--all',
action='store_true',
help='include all python/powershell source files',
)
parser.add_argument(
'--stub',
action='store_true',
help='generate empty report of all python/powershell source files',
)

View File

@@ -0,0 +1,28 @@
"""Command line parsing for all `coverage analyze` commands."""
from __future__ import annotations
import argparse
from .targets import (
do_targets,
)
from ....environments import (
CompositeActionCompletionFinder,
)
def do_analyze(
subparsers,
parent, # type: argparse.ArgumentParser
completer, # type: CompositeActionCompletionFinder
): # type: (...) -> None
"""Command line parsing for all `coverage analyze` commands."""
parser = subparsers.add_parser(
'analyze',
help='analyze collected coverage data',
) # type: argparse.ArgumentParser
analyze_subparsers = parser.add_subparsers(metavar='COMMAND', required=True)
do_targets(analyze_subparsers, parent, completer)

View File

@@ -0,0 +1,48 @@
"""Command line parsing for all `coverage analyze targets` commands."""
from __future__ import annotations
import argparse
from .....environments import (
CompositeActionCompletionFinder,
)
from .combine import (
do_combine,
)
from .expand import (
do_expand,
)
from .filter import (
do_filter,
)
from .generate import (
do_generate,
)
from .missing import (
do_missing,
)
def do_targets(
subparsers,
parent, # type: argparse.ArgumentParser
completer, # type: CompositeActionCompletionFinder
): # type: (...) -> None
"""Command line parsing for all `coverage analyze targets` commands."""
targets = subparsers.add_parser(
'targets',
help='analyze integration test target coverage',
)
targets_subparsers = targets.add_subparsers(metavar='COMMAND', required=True)
do_generate(targets_subparsers, parent, completer)
do_expand(targets_subparsers, parent, completer)
do_filter(targets_subparsers, parent, completer)
do_combine(targets_subparsers, parent, completer)
do_missing(targets_subparsers, parent, completer)

View File

@@ -0,0 +1,49 @@
"""Command line parsing for the `coverage analyze targets combine` command."""
from __future__ import annotations
import argparse
from ......commands.coverage.analyze.targets.combine import (
command_coverage_analyze_targets_combine,
CoverageAnalyzeTargetsCombineConfig,
)
from .....environments import (
CompositeActionCompletionFinder,
ControllerMode,
TargetMode,
add_environments,
)
def do_combine(
subparsers,
parent, # type: argparse.ArgumentParser
completer, # type: CompositeActionCompletionFinder
):
"""Command line parsing for the `coverage analyze targets combine` command."""
parser = subparsers.add_parser(
'combine',
parents=[parent],
help='combine multiple aggregated coverage files',
) # type: argparse.ArgumentParser
parser.set_defaults(
func=command_coverage_analyze_targets_combine,
config=CoverageAnalyzeTargetsCombineConfig,
)
targets_combine = parser.add_argument_group('coverage arguments')
targets_combine.add_argument(
'input_file',
nargs='+',
help='input file to read aggregated coverage from',
)
targets_combine.add_argument(
'output_file',
help='output file to write aggregated coverage to',
)
add_environments(parser, completer, ControllerMode.ORIGIN, TargetMode.NO_TARGETS) # coverage analyze targets combine

View File

@@ -0,0 +1,48 @@
"""Command line parsing for the `coverage analyze targets expand` command."""
from __future__ import annotations
import argparse
from ......commands.coverage.analyze.targets.expand import (
command_coverage_analyze_targets_expand,
CoverageAnalyzeTargetsExpandConfig,
)
from .....environments import (
CompositeActionCompletionFinder,
ControllerMode,
TargetMode,
add_environments,
)
def do_expand(
subparsers,
parent, # type: argparse.ArgumentParser
completer, # type: CompositeActionCompletionFinder
):
"""Command line parsing for the `coverage analyze targets expand` command."""
parser = subparsers.add_parser(
'expand',
parents=[parent],
help='expand target names from integers in aggregated coverage',
) # type: argparse.ArgumentParser
parser.set_defaults(
func=command_coverage_analyze_targets_expand,
config=CoverageAnalyzeTargetsExpandConfig,
)
targets_expand = parser.add_argument_group(title='coverage arguments')
targets_expand.add_argument(
'input_file',
help='input file to read aggregated coverage from',
)
targets_expand.add_argument(
'output_file',
help='output file to write expanded coverage to',
)
add_environments(parser, completer, ControllerMode.ORIGIN, TargetMode.NO_TARGETS) # coverage analyze targets expand

View File

@@ -0,0 +1,76 @@
"""Command line parsing for the `coverage analyze targets filter` command."""
from __future__ import annotations
import argparse
from ......commands.coverage.analyze.targets.filter import (
command_coverage_analyze_targets_filter,
CoverageAnalyzeTargetsFilterConfig,
)
from .....environments import (
CompositeActionCompletionFinder,
ControllerMode,
TargetMode,
add_environments,
)
def do_filter(
subparsers,
parent, # type: argparse.ArgumentParser
completer, # type: CompositeActionCompletionFinder
):
"""Command line parsing for the `coverage analyze targets filter` command."""
parser = subparsers.add_parser(
'filter',
parents=[parent],
help='filter aggregated coverage data',
) # type: argparse.ArgumentParser
parser.set_defaults(
func=command_coverage_analyze_targets_filter,
config=CoverageAnalyzeTargetsFilterConfig,
)
targets_filter = parser.add_argument_group(title='coverage arguments')
targets_filter.add_argument(
'input_file',
help='input file to read aggregated coverage from',
)
targets_filter.add_argument(
'output_file',
help='output file to write expanded coverage to',
)
targets_filter.add_argument(
'--include-target',
metavar='TGT',
dest='include_targets',
action='append',
help='include the specified targets',
)
targets_filter.add_argument(
'--exclude-target',
metavar='TGT',
dest='exclude_targets',
action='append',
help='exclude the specified targets',
)
targets_filter.add_argument(
'--include-path',
metavar='REGEX',
help='include paths matching the given regex',
)
targets_filter.add_argument(
'--exclude-path',
metavar='REGEX',
help='exclude paths matching the given regex',
)
add_environments(parser, completer, ControllerMode.ORIGIN, TargetMode.NO_TARGETS) # coverage analyze targets filter

View File

@@ -0,0 +1,49 @@
"""Command line parsing for the `coverage analyze targets generate` command."""
from __future__ import annotations
import argparse
from ......commands.coverage.analyze.targets.generate import (
command_coverage_analyze_targets_generate,
CoverageAnalyzeTargetsGenerateConfig,
)
from .....environments import (
CompositeActionCompletionFinder,
ControllerMode,
TargetMode,
add_environments,
)
def do_generate(
subparsers,
parent, # type: argparse.ArgumentParser
completer, # type: CompositeActionCompletionFinder
):
"""Command line parsing for the `coverage analyze targets generate` command."""
parser = subparsers.add_parser(
'generate',
parents=[parent],
help='aggregate coverage by integration test target',
) # type: argparse.ArgumentParser
parser.set_defaults(
func=command_coverage_analyze_targets_generate,
config=CoverageAnalyzeTargetsGenerateConfig,
)
targets_generate = parser.add_argument_group(title='coverage arguments')
targets_generate.add_argument(
'input_dir',
nargs='?',
help='directory to read coverage from',
)
targets_generate.add_argument(
'output_file',
help='output file for aggregated coverage',
)
add_environments(parser, completer, ControllerMode.ORIGIN, TargetMode.NO_TARGETS) # coverage analyze targets generate

View File

@@ -0,0 +1,65 @@
"""Command line parsing for the `coverage analyze targets missing` command."""
from __future__ import annotations
import argparse
from ......commands.coverage.analyze.targets.missing import (
command_coverage_analyze_targets_missing,
CoverageAnalyzeTargetsMissingConfig,
)
from .....environments import (
CompositeActionCompletionFinder,
ControllerMode,
TargetMode,
add_environments,
)
def do_missing(
subparsers,
parent, # type: argparse.ArgumentParser
completer, # type: CompositeActionCompletionFinder
):
"""Command line parsing for the `coverage analyze targets missing` command."""
parser = subparsers.add_parser(
'missing',
parents=[parent],
help='identify coverage in one file missing in another',
) # type: argparse.ArgumentParser
parser.set_defaults(
func=command_coverage_analyze_targets_missing,
config=CoverageAnalyzeTargetsMissingConfig,
)
targets_missing = parser.add_argument_group(title='coverage arguments')
targets_missing.add_argument(
'from_file',
help='input file containing aggregated coverage',
)
targets_missing.add_argument(
'to_file',
help='input file containing aggregated coverage',
)
targets_missing.add_argument(
'output_file',
help='output file to write aggregated coverage to',
)
targets_missing.add_argument(
'--only-gaps',
action='store_true',
help='report only arcs/lines not hit by any target',
)
targets_missing.add_argument(
'--only-exists',
action='store_true',
help='limit results to files that exist',
)
add_environments(parser, completer, ControllerMode.ORIGIN, TargetMode.NO_TARGETS) # coverage analyze targets missing

View File

@@ -0,0 +1,48 @@
"""Command line parsing for the `coverage combine` command."""
from __future__ import annotations
import argparse
import typing as t
from ....commands.coverage.combine import (
command_coverage_combine,
CoverageCombineConfig,
)
from ...environments import (
CompositeActionCompletionFinder,
ControllerMode,
TargetMode,
add_environments,
)
def do_combine(
subparsers,
parent, # type: argparse.ArgumentParser
add_coverage_common, # type: t.Callable[[argparse.ArgumentParser], None]
completer, # type: CompositeActionCompletionFinder
): # type: (...) -> None
"""Command line parsing for the `coverage combine` command."""
parser = subparsers.add_parser(
'combine',
parents=[parent],
help='combine coverage data and rewrite remote paths',
) # type: argparse.ArgumentParser
parser.set_defaults(
func=command_coverage_combine,
config=CoverageCombineConfig,
)
coverage_combine = t.cast(argparse.ArgumentParser, parser.add_argument_group(title='coverage arguments'))
add_coverage_common(coverage_combine)
coverage_combine.add_argument(
'--export',
metavar='DIR',
help='directory to export combined coverage files to',
)
add_environments(parser, completer, ControllerMode.DELEGATED, TargetMode.NO_TARGETS) # coverage combine

View File

@@ -0,0 +1,36 @@
"""Command line parsing for the `coverage erase` command."""
from __future__ import annotations
import argparse
from ....commands.coverage.erase import (
command_coverage_erase,
CoverageEraseConfig,
)
from ...environments import (
CompositeActionCompletionFinder,
ControllerMode,
TargetMode,
add_environments,
)
def do_erase(
subparsers,
parent, # type: argparse.ArgumentParser
completer, # type: CompositeActionCompletionFinder
): # type: (...) -> None
"""Command line parsing for the `coverage erase` command."""
parser = subparsers.add_parser(
'erase',
parents=[parent],
help='erase coverage data files',
) # type: argparse.ArgumentParser
parser.set_defaults(
func=command_coverage_erase,
config=CoverageEraseConfig,
)
add_environments(parser, completer, ControllerMode.ORIGIN, TargetMode.NO_TARGETS) # coverage erase

View File

@@ -0,0 +1,42 @@
"""Command line parsing for the `coverage html` command."""
from __future__ import annotations
import argparse
import typing as t
from ....commands.coverage.html import (
command_coverage_html,
CoverageHtmlConfig,
)
from ...environments import (
CompositeActionCompletionFinder,
ControllerMode,
TargetMode,
add_environments,
)
def do_html(
subparsers,
parent, # type: argparse.ArgumentParser
add_coverage_common, # type: t.Callable[[argparse.ArgumentParser], None]
completer, # type: CompositeActionCompletionFinder
): # type: (...) -> None
"""Command line parsing for the `coverage html` command."""
parser = subparsers.add_parser(
'html',
parents=[parent],
help='generate html coverage report',
) # type: argparse.ArgumentParser
parser.set_defaults(
func=command_coverage_html,
config=CoverageHtmlConfig,
)
coverage_combine = t.cast(argparse.ArgumentParser, parser.add_argument_group(title='coverage arguments'))
add_coverage_common(coverage_combine)
add_environments(parser, completer, ControllerMode.DELEGATED, TargetMode.NO_TARGETS) # coverage html

View File

@@ -0,0 +1,60 @@
"""Command line parsing for the `coverage report` command."""
from __future__ import annotations
import argparse
import typing as t
from ....commands.coverage.report import (
command_coverage_report,
CoverageReportConfig,
)
from ...environments import (
CompositeActionCompletionFinder,
ControllerMode,
TargetMode,
add_environments,
)
def do_report(
subparsers,
parent, # type: argparse.ArgumentParser
add_coverage_common, # type: t.Callable[[argparse.ArgumentParser], None]
completer, # type: CompositeActionCompletionFinder
): # type: (...) -> None
"""Command line parsing for the `coverage report` command."""
parser = subparsers.add_parser(
'report',
parents=[parent],
help='generate console coverage report',
) # type: argparse.ArgumentParser
parser.set_defaults(
func=command_coverage_report,
config=CoverageReportConfig,
)
coverage_report = t.cast(argparse.ArgumentParser, parser.add_argument_group('coverage arguments'))
add_coverage_common(coverage_report)
coverage_report.add_argument(
'--show-missing',
action='store_true',
help='show line numbers of statements not executed',
)
coverage_report.add_argument(
'--include',
metavar='PAT[,...]',
help='only include paths that match a pattern (accepts quoted shell wildcards)',
)
coverage_report.add_argument(
'--omit',
metavar='PAT[,...]',
help='omit paths that match a pattern (accepts quoted shell wildcards)',
)
add_environments(parser, completer, ControllerMode.DELEGATED, TargetMode.NO_TARGETS) # coverage report

View File

@@ -0,0 +1,42 @@
"""Command line parsing for the `coverage xml` command."""
from __future__ import annotations
import argparse
import typing as t
from ....commands.coverage.xml import (
command_coverage_xml,
CoverageXmlConfig,
)
from ...environments import (
CompositeActionCompletionFinder,
ControllerMode,
TargetMode,
add_environments,
)
def do_xml(
subparsers,
parent, # type: argparse.ArgumentParser
add_coverage_common, # type: t.Callable[[argparse.ArgumentParser], None]
completer, # type: CompositeActionCompletionFinder
): # type: (...) -> None
"""Command line parsing for the `coverage xml` command."""
parser = subparsers.add_parser(
'xml',
parents=[parent],
help='generate xml coverage report',
) # type: argparse.ArgumentParser
parser.set_defaults(
func=command_coverage_xml,
config=CoverageXmlConfig,
)
coverage_combine = t.cast(argparse.ArgumentParser, parser.add_argument_group(title='coverage arguments'))
add_coverage_common(coverage_combine)
add_environments(parser, completer, ControllerMode.DELEGATED, TargetMode.NO_TARGETS) # coverage xml

View File

@@ -0,0 +1,63 @@
"""Command line parsing for the `env` command."""
from __future__ import annotations
import argparse
from ...commands.env import (
EnvConfig,
command_env,
)
from ..environments import (
CompositeActionCompletionFinder,
ControllerMode,
TargetMode,
add_environments,
)
def do_env(
subparsers,
parent, # type: argparse.ArgumentParser
completer, # type: CompositeActionCompletionFinder
):
"""Command line parsing for the `env` command."""
parser = subparsers.add_parser(
'env',
parents=[parent],
help='show information about the test environment',
) # type: argparse.ArgumentParser
parser.set_defaults(
func=command_env,
config=EnvConfig,
)
env = parser.add_argument_group(title='env arguments')
env.add_argument(
'--show',
action='store_true',
help='show environment on stdout',
)
env.add_argument(
'--dump',
action='store_true',
help='dump environment to disk',
)
env.add_argument(
'--list-files',
action='store_true',
help='list files on stdout',
)
env.add_argument(
'--timeout',
type=int,
metavar='MINUTES',
help='timeout for future ansible-test commands (0 clears)',
)
add_environments(parser, completer, ControllerMode.NO_DELEGATION, TargetMode.NO_TARGETS) # env

View File

@@ -0,0 +1,161 @@
"""Command line parsing for all integration commands."""
from __future__ import annotations
import argparse
from ...completers import (
complete_target,
)
from ...environments import (
CompositeActionCompletionFinder,
)
from .network import (
do_network_integration,
)
from .posix import (
do_posix_integration,
)
from .windows import (
do_windows_integration,
)
def do_integration(
subparsers,
parent, # type: argparse.ArgumentParser
completer, # type: CompositeActionCompletionFinder
):
"""Command line parsing for all integration commands."""
parser = argparse.ArgumentParser(
add_help=False,
parents=[parent],
) # type: argparse.ArgumentParser
do_posix_integration(subparsers, parser, add_integration_common, completer)
do_network_integration(subparsers, parser, add_integration_common, completer)
do_windows_integration(subparsers, parser, add_integration_common, completer)
def add_integration_common(
parser, # type: argparse.ArgumentParser
):
"""Add common integration argumetns."""
parser.add_argument(
'--start-at',
metavar='TARGET',
help='start at the specified target',
).completer = complete_target
parser.add_argument(
'--start-at-task',
metavar='TASK',
help='start at the specified task',
)
parser.add_argument(
'--tags',
metavar='TAGS',
help='only run plays and tasks tagged with these values',
)
parser.add_argument(
'--skip-tags',
metavar='TAGS',
help='only run plays and tasks whose tags do not match these values',
)
parser.add_argument(
'--diff',
action='store_true',
help='show diff output',
)
parser.add_argument(
'--allow-destructive',
action='store_true',
help='allow destructive tests',
)
parser.add_argument(
'--allow-root',
action='store_true',
help='allow tests requiring root when not root',
)
parser.add_argument(
'--allow-disabled',
action='store_true',
help='allow tests which have been marked as disabled',
)
parser.add_argument(
'--allow-unstable',
action='store_true',
help='allow tests which have been marked as unstable',
)
parser.add_argument(
'--allow-unstable-changed',
action='store_true',
help='allow tests which have been marked as unstable when focused changes are detected',
)
parser.add_argument(
'--allow-unsupported',
action='store_true',
help='allow tests which have been marked as unsupported',
)
parser.add_argument(
'--retry-on-error',
action='store_true',
help='retry failed test with increased verbosity',
)
parser.add_argument(
'--continue-on-error',
action='store_true',
help='continue after failed test',
)
parser.add_argument(
'--debug-strategy',
action='store_true',
help='run test playbooks using the debug strategy',
)
parser.add_argument(
'--changed-all-target',
metavar='TARGET',
default='all',
help='target to run when all tests are needed',
)
parser.add_argument(
'--changed-all-mode',
metavar='MODE',
choices=('default', 'include', 'exclude'),
help='include/exclude behavior with --changed-all-target: %(choices)s',
)
parser.add_argument(
'--list-targets',
action='store_true',
help='list matching targets instead of running tests',
)
parser.add_argument(
'--no-temp-workdir',
action='store_true',
help='do not run tests from a temporary directory (use only for verifying broken tests)',
)
parser.add_argument(
'--no-temp-unicode',
action='store_true',
help='avoid unicode characters in temporary directory (use only for verifying broken tests)',
)

View File

@@ -0,0 +1,81 @@
"""Command line parsing for the `network-integration` command."""
from __future__ import annotations
import argparse
import os
import typing as t
from ....commands.integration.network import (
command_network_integration,
)
from ....config import (
NetworkIntegrationConfig,
)
from ....target import (
walk_network_integration_targets,
)
from ....data import (
data_context,
)
from ...environments import (
CompositeActionCompletionFinder,
ControllerMode,
TargetMode,
add_environments,
)
def do_network_integration(
subparsers,
parent, # type: argparse.ArgumentParser
add_integration_common, # type: t.Callable[[argparse.ArgumentParser], None]
completer, # type: CompositeActionCompletionFinder
):
"""Command line parsing for the `network-integration` command."""
parser = subparsers.add_parser(
'network-integration',
parents=[parent],
help='network integration tests',
) # type: argparse.ArgumentParser
parser.set_defaults(
func=command_network_integration,
targets_func=walk_network_integration_targets,
config=NetworkIntegrationConfig)
network_integration = t.cast(argparse.ArgumentParser, parser.add_argument_group(title='network integration test arguments'))
add_integration_common(network_integration)
network_integration.add_argument(
'--testcase',
metavar='TESTCASE',
help='limit a test to a specified testcase',
).completer = complete_network_testcase
add_environments(parser, completer, ControllerMode.DELEGATED, TargetMode.NETWORK_INTEGRATION) # network-integration
def complete_network_testcase(prefix, parsed_args, **_): # type: (str, argparse.Namespace, ...) -> t.List[str]
"""Return a list of test cases matching the given prefix if only one target was parsed from the command line, otherwise return an empty list."""
testcases = []
# since testcases are module specific, don't autocomplete if more than one
# module is specidied
if len(parsed_args.include) != 1:
return []
target = parsed_args.include[0]
test_dir = os.path.join(data_context().content.integration_targets_path, target, 'tests')
connection_dirs = data_context().content.get_dirs(test_dir)
for connection_dir in connection_dirs:
for testcase in [os.path.basename(path) for path in data_context().content.get_files(connection_dir)]:
if testcase.startswith(prefix):
testcases.append(testcase.split('.', 1)[0])
return testcases

View File

@@ -0,0 +1,50 @@
"""Command line parsing for the `integration` command."""
from __future__ import annotations
import argparse
import typing as t
from ....commands.integration.posix import (
command_posix_integration,
)
from ....config import (
PosixIntegrationConfig,
)
from ....target import (
walk_posix_integration_targets,
)
from ...environments import (
CompositeActionCompletionFinder,
ControllerMode,
TargetMode,
add_environments,
)
def do_posix_integration(
subparsers,
parent, # type: argparse.ArgumentParser
add_integration_common, # type: t.Callable[[argparse.ArgumentParser], None]
completer, # type: CompositeActionCompletionFinder
):
"""Command line parsing for the `integration` command."""
parser = subparsers.add_parser(
'integration',
parents=[parent],
help='posix integration tests',
) # type: argparse.ArgumentParser
parser.set_defaults(
func=command_posix_integration,
targets_func=walk_posix_integration_targets,
config=PosixIntegrationConfig,
)
posix_integration = t.cast(argparse.ArgumentParser, parser.add_argument_group(title='integration test arguments'))
add_integration_common(posix_integration)
add_environments(parser, completer, ControllerMode.DELEGATED, TargetMode.POSIX_INTEGRATION) # integration

View File

@@ -0,0 +1,50 @@
"""Command line parsing for the `windows-integration` command."""
from __future__ import annotations
import argparse
import typing as t
from ....commands.integration.windows import (
command_windows_integration,
)
from ....config import (
WindowsIntegrationConfig,
)
from ....target import (
walk_windows_integration_targets,
)
from ...environments import (
CompositeActionCompletionFinder,
ControllerMode,
TargetMode,
add_environments,
)
def do_windows_integration(
subparsers,
parent, # type: argparse.ArgumentParser
add_integration_common, # type: t.Callable[[argparse.ArgumentParser], None]
completer, # type: CompositeActionCompletionFinder
):
"""Command line parsing for the `windows-integration` command."""
parser = subparsers.add_parser(
'windows-integration',
parents=[parent],
help='windows integration tests',
) # type: argparse.ArgumentParser
parser.set_defaults(
func=command_windows_integration,
targets_func=walk_windows_integration_targets,
config=WindowsIntegrationConfig,
)
windows_integration = t.cast(argparse.ArgumentParser, parser.add_argument_group(title='windows integration test arguments'))
add_integration_common(windows_integration)
add_environments(parser, completer, ControllerMode.DELEGATED, TargetMode.WINDOWS_INTEGRATION) # windows-integration

View File

@@ -0,0 +1,119 @@
"""Command line parsing for the `sanity` command."""
from __future__ import annotations
import argparse
from ...config import (
SanityConfig,
)
from ...commands.sanity import (
command_sanity,
sanity_get_tests,
)
from ...target import (
walk_sanity_targets,
)
from ...data import (
data_context,
)
from ..environments import (
CompositeActionCompletionFinder,
ControllerMode,
TargetMode,
add_environments,
)
def do_sanity(
subparsers,
parent, # type: argparse.ArgumentParser
completer, # type: CompositeActionCompletionFinder
):
"""Command line parsing for the `sanity` command."""
parser = subparsers.add_parser(
'sanity',
parents=[parent],
help='sanity tests',
) # type: argparse.ArgumentParser
parser.set_defaults(
func=command_sanity,
targets_func=walk_sanity_targets,
config=SanityConfig)
sanity = parser.add_argument_group(title='sanity test arguments')
sanity.add_argument(
'--test',
metavar='TEST',
action='append',
choices=[test.name for test in sanity_get_tests()],
help='tests to run',
)
sanity.add_argument(
'--skip-test',
metavar='TEST',
action='append',
choices=[test.name for test in sanity_get_tests()],
help='tests to skip',
)
sanity.add_argument(
'--allow-disabled',
action='store_true',
help='allow tests to run which are disabled by default',
)
sanity.add_argument(
'--list-tests',
action='store_true',
help='list available tests',
)
sanity.add_argument(
'--enable-optional-errors',
action='store_true',
help='enable optional errors',
)
if data_context().content.is_ansible:
sanity.add_argument(
'--keep-git',
action='store_true',
help='transfer git related files to the remote host/container',
)
else:
sanity.set_defaults(
keep_git=False,
)
sanity.add_argument(
'--lint',
action='store_true',
help='write lint output to stdout, everything else stderr',
)
sanity.add_argument(
'--junit',
action='store_true',
help='write test failures to junit xml files',
)
sanity.add_argument(
'--failure-ok',
action='store_true',
help='exit successfully on failed tests after saving results',
)
sanity.add_argument(
'--prime-venvs',
action='store_true',
help='prepare virtual environments without running tests'
)
add_environments(parser, completer, ControllerMode.DELEGATED, TargetMode.SANITY) # sanity

View File

@@ -0,0 +1,47 @@
"""Command line parsing for the `shell` command."""
from __future__ import annotations
import argparse
from ...commands.shell import (
command_shell,
)
from ...config import (
ShellConfig,
)
from ..environments import (
CompositeActionCompletionFinder,
ControllerMode,
TargetMode,
add_environments,
)
def do_shell(
subparsers,
parent, # type: argparse.ArgumentParser
completer, # type: CompositeActionCompletionFinder
):
"""Command line parsing for the `shell` command."""
parser = subparsers.add_parser(
'shell',
parents=[parent],
help='open an interactive shell',
) # type: argparse.ArgumentParser
parser.set_defaults(
func=command_shell,
config=ShellConfig,
)
shell = parser.add_argument_group(title='shell arguments')
shell.add_argument(
'--raw',
action='store_true',
help='direct to shell with no setup',
)
add_environments(parser, completer, ControllerMode.DELEGATED, TargetMode.SHELL) # shell

View File

@@ -0,0 +1,65 @@
"""Command line parsing for the `units` command."""
from __future__ import annotations
import argparse
from ...config import (
UnitsConfig,
)
from ...commands.units import (
command_units,
)
from ...target import (
walk_units_targets,
)
from ..environments import (
CompositeActionCompletionFinder,
ControllerMode,
TargetMode,
add_environments,
)
def do_units(
subparsers,
parent, # type: argparse.ArgumentParser
completer, # type: CompositeActionCompletionFinder
):
"""Command line parsing for the `units` command."""
parser = subparsers.add_parser(
'units',
parents=[parent],
help='unit tests',
) # type: argparse.ArgumentParser
parser.set_defaults(
func=command_units,
targets_func=walk_units_targets,
config=UnitsConfig,
)
units = parser.add_argument_group(title='unit test arguments')
units.add_argument(
'--collect-only',
action='store_true',
help='collect tests but do not execute them',
)
units.add_argument(
'--num-workers',
metavar='INT',
type=int,
help='number of workers to use (default: auto)',
)
units.add_argument(
'--requirements-mode',
choices=('only', 'skip'),
help=argparse.SUPPRESS,
)
add_environments(parser, completer, ControllerMode.DELEGATED, TargetMode.UNITS) # units