初始化测试执行器 Args: config_file: 任务配置文件路径
(self, config_file: str)
| 62 | """通用测试执行器""" |
| 63 | |
| 64 | def __init__(self, config_file: str): |
| 65 | """初始化测试执行器 |
| 66 | |
| 67 | Args: |
| 68 | config_file: 任务配置文件路径 |
| 69 | """ |
| 70 | self.config_file = config_file |
| 71 | self.config = self._load_config() |
| 72 | # 使用当前工作目录作为基础目录,而不是配置文件所在目录 |
| 73 | self.base_dir = os.getcwd() |
| 74 | self.start_time = datetime.now() |
| 75 | |
| 76 | # 生成带时间戳的文件名 |
| 77 | timestamp = self.start_time.strftime("%Y%m%d_%H%M%S") |
| 78 | task_name = self.config['task_name'] |
| 79 | |
| 80 | # 配置日志 |
| 81 | log_config = self.config.get('logging', {}) |
| 82 | log_file = log_config.get('output_file', 'test-{task_name}-{timestamp}.log') |
| 83 | log_file = log_file.format(task_name=task_name, timestamp=timestamp) |
| 84 | |
| 85 | configure_logging( |
| 86 | level=log_config.get('level', 'DEBUG'), |
| 87 | use_colors=log_config.get('use_colors', True), |
| 88 | show_time=log_config.get('show_time', True), |
| 89 | show_module=log_config.get('show_module', True), |
| 90 | output_file=log_file |
| 91 | ) |
| 92 | |
| 93 | # 配置输出文件 |
| 94 | output_config = self.config.get('output', {}) |
| 95 | self.summary_file = output_config.get('summary_file', 'test-{task_name}-summary-{timestamp}.txt') |
| 96 | self.summary_file = self.summary_file.format(task_name=task_name, timestamp=timestamp) |
| 97 | |
| 98 | self.detailed_file = output_config.get('detailed_results_file', 'test-{task_name}-detailed-{timestamp}.json') |
| 99 | self.detailed_file = self.detailed_file.format(task_name=task_name, timestamp=timestamp) |
| 100 | |
| 101 | # 创建验证选项 |
| 102 | self.opts = self._create_verifier_options() |
| 103 | |
| 104 | print(f"=== 通用任务测试执行器 ===") |
| 105 | print(f"任务名称: {self.config['task_name']}") |
| 106 | print(f"任务描述: {self.config.get('description', 'N/A')}") |
| 107 | print(f"日志文件: {log_file}") |
| 108 | print(f"汇总文件: {self.summary_file}") |
| 109 | print(f"详细结果: {self.detailed_file}") |
| 110 | |
| 111 | def _load_config(self) -> Dict[str, Any]: |
| 112 | """加载配置文件""" |
nothing calls this directly
no test coverage detected