summaryrefslogtreecommitdiffstats
path: root/test/lib/ansible_test/_internal/cli/commands/units.py
blob: c541a872a42b9bec54400b723eab21c749c6f878 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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: argparse.ArgumentParser,
    completer: CompositeActionCompletionFinder,
):
    """Command line parsing for the `units` command."""
    parser: argparse.ArgumentParser = subparsers.add_parser(
        'units',
        parents=[parent],
        help='unit tests',
    )

    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