refactor: 重构执行器和CliRunner,简化策略类型实现

1.  将Strategy枚举改为Literal类型,移除normalize_strategy函数
2.  内联策略验证逻辑到run函数中
3.  使用dataclasses.field重构CliRunner的初始化方式
4.  修复测试用例中的函数名和调用方式不匹配问题
5.  调整部分测试用例的构造语法,适配新的API
6.  修正pymake模块中的函数重命名和条件变量命名问题
7.  为部分耗时测试添加@pytest.mark.slow标记
This commit is contained in:
2026-06-21 12:52:32 +08:00
parent 4884fd53e5
commit 179e5b3811
9 changed files with 167 additions and 299 deletions
+4 -4
View File
@@ -70,7 +70,7 @@ def test_taskspec_wrap_cmd_error():
wrapped_fn = spec.effective_fn
with pytest.raises(RuntimeError, match="命令执行失败"):
wrapped_fn()
_ = wrapped_fn()
def test_taskspec_wrap_cmd_file_not_found():
@@ -79,7 +79,7 @@ def test_taskspec_wrap_cmd_file_not_found():
wrapped_fn = spec.effective_fn
with pytest.raises(RuntimeError, match="命令未找到"):
wrapped_fn()
_ = wrapped_fn()
def test_taskspec_wrap_cmd_shell_file_not_found():
@@ -90,13 +90,13 @@ def test_taskspec_wrap_cmd_shell_file_not_found():
# Shell commands don't raise FileNotFoundError
# They just return non-zero exit code
with pytest.raises(RuntimeError):
wrapped_fn()
_ = wrapped_fn()
def test_taskspec_no_fn_no_cmd():
"""Test TaskSpec raises error when no fn or cmd."""
with pytest.raises(ValueError, match="必须提供 fn 或 cmd 参数"):
TaskSpec("test")
_ = TaskSpec("test")
def test_taskspec_cmd_overrides_fn():