Lines Matching full:self
17 def __init__(self): argument
18 self.state = None
19 self.type = None
20 self.regex = []
21 self.matches = OrderedDict()
22 self.ordered = True
23 self.repeat = 1
24 self.tests = {}
25 self.id = None
26 self.fail_on_fault = True
27 self.fault = False
28 self.capture_coverage = False
29 self.next_pattern = 0
30 self.record = None
31 self.recording = []
32 self.fieldnames = []
33 self.ztest = False
34 self.is_pytest = False
36 def configure(self, instance): argument
38 self.id = instance.testcase.id
40 self.fail_on_fault = False
43 self.type = config.get('type', None)
44 self.regex = config.get('regex', [])
45 self.repeat = config.get('repeat', 1)
46 self.ordered = config.get('ordered', True)
47 self.record = config.get('record', {})
49 def process_test(self, line): argument
51 if self.RUN_PASSED in line:
52 if self.fault:
53 self.state = "failed"
55 self.state = "passed"
57 if self.RUN_FAILED in line:
58 self.state = "failed"
60 if self.fail_on_fault:
61 if self.FAULT == line:
62 self.fault = True
64 if self.GCOV_START in line:
65 self.capture_coverage = True
66 elif self.GCOV_END in line:
67 self.capture_coverage = False
71 def configure(self, instance): argument
72 super(Console, self).configure(instance)
73 if self.type == "one_line":
74 self.pattern = re.compile(self.regex[0])
75 elif self.type == "multi_line":
76 self.patterns = []
77 for r in self.regex:
78 self.patterns.append(re.compile(r))
80 def handle(self, line): argument
81 if self.type == "one_line":
82 if self.pattern.search(line):
83 self.state = "passed"
84 elif self.type == "multi_line" and self.ordered:
85 if (self.next_pattern < len(self.patterns) and
86 self.patterns[self.next_pattern].search(line)):
87 self.next_pattern += 1
88 if self.next_pattern >= len(self.patterns):
89 self.state = "passed"
90 elif self.type == "multi_line" and not self.ordered:
91 for i, pattern in enumerate(self.patterns):
92 r = self.regex[i]
93 if pattern.search(line) and not r in self.matches:
94 self.matches[r] = line
95 if len(self.matches) == len(self.regex):
96 self.state = "passed"
98 if self.fail_on_fault:
99 if self.FAULT in line:
100 self.fault = True
102 if self.GCOV_START in line:
103 self.capture_coverage = True
104 elif self.GCOV_END in line:
105 self.capture_coverage = False
108 if self.record:
109 pattern = re.compile(self.record.get("regex", ""))
113 if not self.fieldnames:
115 self.fieldnames.append(k)
119 self.recording.append(csv)
121 self.process_test(line)
123 if self.state == "passed":
124 self.tests[self.id] = "PASS"
126 self.tests[self.id] = "FAIL"
129 def configure(self, instance): argument
130 super(Pytest, self).configure(instance)
131 self.running_dir = instance.build_dir
132 self.source_dir = instance.testcase.source_dir
133 self.pytest_root = 'pytest'
134 self.is_pytest = True
138 self.pytest_root = config.get('pytest_root', 'pytest')
140 def handle(self, line): argument
146 self.state = "passed"
147 self.tests[self.id] = "PASS"
149 def pytest_run(self, log_file): argument
150 ''' To keep artifacts of pytest in self.running_dir, pass this directory
159 os.path.join(self.source_dir, self.pytest_root),
161 self.running_dir,
163 os.path.join(self.running_dir, 'report.xml'),
176 tree = ET.parse(os.path.join(self.running_dir, "report.xml"))
181 self.state = "failed"
183 self.state = "skipped"
185 self.state = "errors"
187 self.state = "passed"
190 self.state = "failed"
192 self.state = "failed"
195 self.state = "failed"
197 if self.state == "passed":
198 self.tests[self.id] = "PASS"
200 elif self.state == "skipped":
201 self.tests[self.id] = "SKIP"
205 self.tests[self.id] = "FAIL"
218 def handle(self, line): argument
221 name = "{}.{}".format(self.id, match.group(3))
222 self.tests[name] = match.group(1)
223 self.ztest = True
225 self.process_test(line)
227 if not self.ztest and self.state:
228 if self.state == "passed":
229 self.tests[self.id] = "PASS"
231 self.tests[self.id] = "FAIL"