File: ignore.py

package info (click to toggle)
libreswan 5.2-2.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 81,632 kB
  • sloc: ansic: 129,988; sh: 32,018; xml: 20,646; python: 10,303; makefile: 3,022; javascript: 1,506; sed: 574; yacc: 511; perl: 264; awk: 52
file content (71 lines) | stat: -rw-r--r-- 3,181 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
# Lists the tests
#
# Copyright (C) 2015-2016, Andrew Cagney <cagney@gnu.org>
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.  See <https://www.gnu.org/licenses/gpl2.txt>.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.

import re
import argparse

def add_arguments(parser):
    group = parser.add_argument_group("Test filter arguments",
                                      "Options for selecting the tests to run or ignore")
    group.add_argument("--test-kind", default="kvmplutotest",
                       type=re.compile, metavar="REGULAR-EXPRESSION",
                       help="Select tests with kind matching %(metavar)s (default: '%(default)s')")
    group.add_argument("--test-status", default="good",
                       type=re.compile, metavar="REGULAR-EXPRESSION",
                       help="Select tests with status matching %(metavar)s (default: '%(default)s')")
    group.add_argument("--test-name", default="",
                       type=re.compile, metavar="REGULAR-EXPRESSION",
                       help="Select tests with name matching %(metavar)s (default: '%(default)s')")
    group.add_argument("--test-platform", default="",
                       type=re.compile, metavar="REGULAR-EXPRESSION",
                       help="Select tests with all platforms matching %(metavar)s (default: '%(default)s')")


def log_arguments(logger, args):
    logger.info("Test filter arguments:")
    logger.info("  test-kind: '%s'" , args.test_kind.pattern)
    logger.info("  test-status: '%s'" , args.test_status.pattern)
    logger.info("  test-name: '%s'" , args.test_name.pattern)
    logger.info("  test-platform: '%s'" , args.test_platform.pattern)


def test(logger, args, test):

    """Identify tests that should be ignored due to filters

    Returns the ignore reason (or None), really ignore (or False), and details.

    This is different to SKIP where a test isn't run because it has
    been run before.

    """

    for regex, field, title in [(args.test_kind, test.kind, "kind"),
                                (args.test_status, test.status, "status"),
                                (args.test_name, test.name, "name")]:
        if regex.pattern \
        and not regex.search(field):
            return (title+"="+field + "!=" + regex.pattern,
                    "%s (%s) does not match '%s'" % (title, field, regex.pattern))

    for regex, fields, title in [(args.test_platform, test.platforms, "platform")]:
        if not fields:
            continue
        for field in fields:
            if not regex.pattern \
               or not regex.search(field):
                return (title+"="+field + "!=" + regex.pattern,
                        "%s '%s' does not match '%s'" % (title, field, regex.pattern))

    return None, None