File: running-autopkgtests

package info (click to toggle)
ubuntu-dev-tools 0.206
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,172 kB
  • sloc: python: 9,120; sh: 1,304; perl: 135; makefile: 10
file content (81 lines) | stat: -rwxr-xr-x 2,733 bytes parent folder | download
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/python3
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-

# Authors:
#   Andy P. Whitcroft
#   Christian Ehrhardt
#   Chris Peterson <chris.peterson@canonical.com>
#
# Copyright (C) 2024 Canonical Ltd.
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program.  If not, see <http://www.gnu.org/licenses/>.
"""Dumps a list of currently running tests in Autopkgtest"""

__example__ = """
Display first listed test running on amd64 hardware:
  $ running-autopkgtests | grep amd64 | head -n1
  R     0:01:40 systemd-upstream               -          focal    amd64\
    upstream-systemd-ci/systemd-ci  - ['CFLAGS=-O0', 'DEB_BUILD_PROFILES=noudeb',\
 'TEST_UPSTREAM=1', 'CONFFLAGS_UPSTREAM=--werror -Dslow-tests=true',\
 'UPSTREAM_PULL_REQUEST=23153',\
 'GITHUB_STATUSES_URL=https://api.github.com/repos/\
systemd/systemd/statuses/cfb0935923dff8050315b5dd22ce8ab06461ff0e']
"""

import sys
from argparse import ArgumentParser, RawDescriptionHelpFormatter

from ubuntutools.running_autopkgtests import get_queued, get_running


def parse_args():
    description = (
        "Dumps a list of currently running and queued tests in Autopkgtest. "
        "Pass --running to only see running tests, or --queued to only see "
        "queued tests. Passing both will print both, which is the default behavior. "
    )

    parser = ArgumentParser(
        prog="running-autopkgtests",
        description=description,
        epilog=f"example: {__example__}",
        formatter_class=RawDescriptionHelpFormatter,
    )
    parser.add_argument(
        "-r", "--running", action="store_true", help="Print runnning autopkgtests (default: true)"
    )
    parser.add_argument(
        "-q", "--queued", action="store_true", help="Print queued autopkgtests (default: true)"
    )

    options = parser.parse_args()

    # If neither flag was specified, default to both not neither
    if not options.running and not options.queued:
        options.running = True
        options.queued = True

    return options


def main() -> int:
    args = parse_args()
    if args.running:
        print(get_running())
    if args.queued:
        print(get_queued())

    return 0


if __name__ == "__main__":
    sys.exit(main())