File: test.py

package info (click to toggle)
clazy 1.17-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,248 kB
  • sloc: cpp: 23,552; python: 1,450; xml: 450; sh: 237; makefile: 46
file content (94 lines) | stat: -rw-r--r-- 3,148 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
82
83
84
85
86
87
88
89
90
91
92
93
94
import os

class Test:
    def __init__(self, check):
        self.filename = ""
        self.minimum_qt_version = 500
        self.maximum_qt_version = 69999
        self.minimum_clang_version = 380
        self.minimum_clang_version_for_fixits = 380
        self.compare_everything = False
        self.check = check
        self.expects_failure = False
        self.skip_qtnamespaced = False
        self.qt_major_versions = [5, 6]
        self.env = os.environ
        self.checks = []
        self.flags = ""
        self.must_fail = False
        self.blacklist_platforms = []
        self.only_qt = False
        self.qt_developer = False
        self.header_filter = ""
        self.ignore_dirs = ""
        self.has_fixits = False
        self.should_run_fixits_test = False
        self.should_run_on_32bit = True
        self.cppStandards = ["c++14", "c++17"]
        self.extra_definitions = False
        self.qt_modules_includes = False
        self.fixed_file_base = None


    def relativeFilename(self):
        # example: "auto-unexpected-qstringbuilder/main.cpp"
        return self.check.name + "/" + self.filename

    def yamlFilename(self, is_standalone):
        # The name of the yaml file with fixits
        # example: "auto-unexpected-qstringbuilder/main.cpp.clazy.yaml"
        if is_standalone:
            return self.relativeFilename() + ".clazy-standalone.yaml"
        else:
            return self.relativeFilename() + ".clazy.yaml"

    def fixedFilename(self, is_standalone):
        if is_standalone:
            return self.relativeFilename() + ".clazy-standalone.fixed"
        else:
            return self.relativeFilename() + ".clazy.fixed"

    def expectedFixedFilename(self):
        return self.relativeFilename() + ".fixed.expected"

    def isScript(self):
        return self.filename.endswith(".sh")

    def setQtMajorVersions(self, major_versions):
        self.qt_major_versions = major_versions
        if 4 in major_versions:
            if self.minimum_qt_version >= 500:
                self.minimum_qt_version = 400

    def setEnv(self, e):
        self.env = os.environ.copy()
        for key in e:
            if type(key) is bytes:
                key = key.decode('utf-8')

            self.env[key] = e[key]

    def printableName(self, cppStandard, qt_major_version, is_standalone, is_tidy, is_fixits):
        name = self.check.name
        if len(self.check.tests) > 1:
            name += "/" + self.filename
        if len(cppStandard) > 0:
            name += " (" + cppStandard + ")"
        if qt_major_version > 0:
            name += " (Qt " + str(qt_major_version) + ")"
        if is_fixits and is_standalone:
            name += " (standalone, fixits)"
        elif is_standalone:
            name += " (standalone)"
        elif is_tidy:
            name += " (clang-tidy)"
        elif is_fixits:
            name += " (plugin, fixits)"
        else:
            name += " (plugin)"
        return name

    def removeYamlFiles(self):
        for f in [self.yamlFilename(False), self.yamlFilename(True)]:
            if os.path.exists(f):
                os.remove(f)