public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
blob 34c815cdda2fd535a2c18226031286793c89292c 1097 bytes (raw)

 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
 
#! /usr/bin/python3

# SPDX-License-Identifier: GPL-2.0-or-later
#
# Copyright Red Hat
# Author: David Gibson <david@gibson.dropbear.id.au>

"""
Manage the manifest of classless tests in a module
"""

import sys

MANIFEST = "__avocado_classless__"
DEFAULT_TIMEOUT = 60.0


def manifest(mod):
    """Return avocado-classless manifest for a Python module"""
    if not hasattr(mod, MANIFEST):
        setattr(mod, MANIFEST, {})
    return getattr(mod, MANIFEST)


class ManifestTestInfo:  # pylint: disable=R0903
    """Metadata about a classless test"""

    def __init__(self, func, timeout=DEFAULT_TIMEOUT):
        self.func = func
        self.__timeout = float(timeout)

    def run_test(self):
        self.func()

    def timeout(self):
        return self.__timeout


def manifest_add(mod, name, func, **kwargs):
    """Register a function as a classless test"""

    if isinstance(mod, str):
        mod = sys.modules[mod]

    mfest = manifest(mod)
    if name in mfest:
        raise ValueError(f"Duplicate classless test name {name}")
    mfest[name] = ManifestTestInfo(func, **kwargs)

debug log:

solving 34c815cd ...
found 34c815cd in https://archives.passt.top/passt-dev/20230627025429.2209702-12-david@gibson.dropbear.id.au/
found 8f7fe688 in https://archives.passt.top/passt-dev/20230627025429.2209702-7-david@gibson.dropbear.id.au/

applying [1/2] https://archives.passt.top/passt-dev/20230627025429.2209702-7-david@gibson.dropbear.id.au/
diff --git a/test/avocado_classless/avocado_classless/manifest.py b/test/avocado_classless/avocado_classless/manifest.py
new file mode 100644
index 00000000..8f7fe688


applying [2/2] https://archives.passt.top/passt-dev/20230627025429.2209702-12-david@gibson.dropbear.id.au/
diff --git a/test/avocado_classless/avocado_classless/manifest.py b/test/avocado_classless/avocado_classless/manifest.py
index 8f7fe688..34c815cd 100644

Checking patch test/avocado_classless/avocado_classless/manifest.py...
Applied patch test/avocado_classless/avocado_classless/manifest.py cleanly.
Checking patch test/avocado_classless/avocado_classless/manifest.py...
Applied patch test/avocado_classless/avocado_classless/manifest.py cleanly.

index at:
100644 34c815cdda2fd535a2c18226031286793c89292c	test/avocado_classless/avocado_classless/manifest.py

Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).