def __init__(self, path, test_path, comment): if path != test_path: self.name = str(path).replace(".", "_") self.path = test_path / path self.test_name = test_path.name else: self.name = "{}_{}".format(path.parent.name, path.name).replace(".", "_") self.path = path self.test_name = path.parent.name self.test_path = test_path self.relative_path = path self.comment = comment try: _, comment_lines = split_comment( comment, read_file(self.path), ) except UnicodeDecodeError as e: print(e) self.commands = [] self.expect = [] self.dependence = {} else: self.commands = extract_commands(comment_lines) self.expect = extract_expect(comment_lines) self.dependence = extract_dependence(comment_lines)
def read_list(path): if not path.exists(): return {"*"}, {} valid_lines, _ = split_comment("#", read_file(path)) include_flag = "[ALL-TEST-CASE]" exclude_flag = "[EXCLUDE-TEST-CASE]" case_list = set() exclude_case_list = set() is_exclude = False for line in valid_lines: if line.find(include_flag) != -1: is_exclude = False elif line.find(exclude_flag) != -1: is_exclude = True elif is_exclude: exclude_case_list.add(line) else: case_list.add(line) if not case_list: case_list = {"*"} return case_list, exclude_case_list