docs(wiki): 18 章补充 Test 回归测试工程集小节(分层、回归复现用例、负向测试、运行脚本)
This commit is contained in:
1 parent
062ff67f02
commit
f2b40cb0b6
1 file changed
+62
@@ -5,6 +5,7 @@
|
||||
| 项目 | 位置 | 定位 |
|
||||
|------|------|------|
|
||||
| **TransPyV** | [../TransPyV](../TransPyV) | Viper 语言编译器本体(自举) |
|
||||
| **Test** | [../Test](../Test) | 回归测试工程集(编译器的质量门禁) |
|
||||
| **VET** | [../VET](../VET) | Viper 环境/产物检查器 |
|
||||
| **ViperOS** | [../ViperApps/ViperOS](../ViperApps/ViperOS) | 用 Viper 写的裸机操作系统 |
|
||||
| **ViperMNIST** | [../ViperApps/ViperMNIST](../ViperApps/ViperMNIST) | 用 Viper 做深度学习(手写数字识别) |
|
||||
@@ -68,6 +69,66 @@ exe\TransPyV.exe --project ViperApps\ViperMNIST\project.vpj --clean --run
|
||||
|
||||
---
|
||||
|
||||
## Test —— 回归测试工程集
|
||||
|
||||
[Test](../Test) 是编译器的**质量门禁**:每个子目录一个**独立可编译工程**(`App/main.vp` + `project.json`),[Test/README.md](../Test/README.md) 收录 68 个并按**实现难度升序**排列,供编译器开发按序推进。
|
||||
|
||||
约定:
|
||||
|
||||
- 几乎所有项目用 `testcheck` 库(`begin` / `section` / `check` / `ok` / `end`)输出 PASS/FAIL 并汇总;
|
||||
- 多数项目依赖 `memhub` 内存分配器与 C 互操作类型。
|
||||
|
||||
难度分层(README 口径):
|
||||
|
||||
| 层 | 数量 | 代表项目 |
|
||||
|----|------|---------|
|
||||
| 简单 | 16 | FuncTest、LoopTest、StringTest、StructTest、EqTest、ShortCircuitTest、IterTest |
|
||||
| 简单→中等 | 3 | GenericTest、GenericTest3 / GenericTest4(泛型入门) |
|
||||
| 中等 | 21 | TypeCastTest、PointerTest、DictTest、ClassArrayTest、HashLibTest、ArgparseTest |
|
||||
| 较难 | 26 | GenericTest2、G4/G5/G7、MultiInheritTest、SuperTest、IsinstanceTest、AstTest、NewAstTest、LLvmLiteTest、ZlibTest、CPythonTest |
|
||||
| 环境依赖 / 回归 | 2 | WebTest(需真实网络)、NoVTableCrossMixinTest |
|
||||
|
||||
**回归复现型(缺陷最小化)**——修 bug 时常单独跑这几个:
|
||||
|
||||
| 项目 | 复现的问题 |
|
||||
|------|-----------|
|
||||
| `G7` | 类名与全局变量同名导致 struct body 不完整(符号表命名冲突) |
|
||||
| `ClosureCallTest` | 闭包返回函数指针后直接 `f()` 调用 |
|
||||
| `Extern2Test` | 外部声明被重复 `define`(应只生成一次 `declare`) |
|
||||
| `SlotsBugTest` | `__slots__` + 类型注解误判崩溃(编译通过即达标) |
|
||||
| `SprintfTest` | `%g` 精度 / 变参整数提升 |
|
||||
| `NoVTableCrossMixinTest` | NoVTable 多继承下跨 Mixin `self.` 调用(this 指针前移 `sizeof(定义类)`) |
|
||||
|
||||
**自举相关**(编译器自身依赖的库,自举前置检查):
|
||||
|
||||
- `AstTest` —— AST 解析 / 遍历 / `dump`,运行时 `isinstance` 区分节点;
|
||||
- `NewAstTest` —— `ast` 模块 93 项全面回归,语法面最广(match / async / lambda / f-string);
|
||||
- `LLvmLiteTest` —— `llvmlite` 库 27 节(类型 / 指令 / phi / switch / 原子操作 / SSA 验证)。
|
||||
|
||||
**负向测试** —— [Test/NegativeTest](../Test/NegativeTest):9 个**故意编译失败**的用例(`call_too_few` / `call_too_many` / `call_wrong_type` / `call_float_to_int` / `missing_return` / `undefined_func` / `import_missing_module` / `import_wrong_path` / `import_stale_path`)+ `run_negative_tests.py`,用于验证 fail-fast 报错行为。
|
||||
|
||||
运行方式:
|
||||
|
||||
```bat
|
||||
:: 全量回归:遍历所有含 project.json 的工程,编译后多线程运行(超时强制结束)
|
||||
python Test\regression_test.py
|
||||
|
||||
:: 顺序回归:按 README 的「建议实现顺序」逐个编译并立即运行,失败即停
|
||||
python Test\SequentialRegressionTest.py
|
||||
```
|
||||
|
||||
> `regression_test.py` 会把 stdout 中出现 `failed` / `error` / `traceback` 等关键词的运行也记为失败,并回显匹配行与上下 5 行。
|
||||
|
||||
TPV 侧另有自测套件 [TransPyV/Test](../TransPyV/Test)(39 个 `.vp`:`App/` 36 + `NegativeTest/` 2 + `Sha1Test/` 1),入口 `test_main.vp` 聚合全部用例:
|
||||
|
||||
```bat
|
||||
exe\TransPyV.exe --project TransPyV\Test\project.vpj --clean --run
|
||||
```
|
||||
|
||||
> 注:`Test/README.md` 收录 68 个工程;`Test/` 目录内另有若干新增工程(如 `CharTest` / `DefaultArgTest` / `CoroTest` / `MLIRLiteTest` / `RawArrayTest` / `ThreadingTest` 等)尚未写进该清单,实际以目录为准。
|
||||
|
||||
---
|
||||
|
||||
## VET —— Viper 环境 / 产物检查器
|
||||
|
||||
[VET](../VET)(Viper Environment Tool)是一个用 Viper 写的**工具链产物检查器**,定位类似 PET。两种模式:
|
||||
@@ -204,6 +265,7 @@ app.exe --mode use --data-dir data --load models/mnist.bin --show 10
|
||||
| 能力 | 由谁验证 |
|
||||
|------|---------|
|
||||
| 自举(编译器编译自己,无 Python 运行时) | TransPyV |
|
||||
| 全语言面回归(语法 / 类型 / 泛型 / OOP / 闭包 / 容器 / 自举库 / 负向报错) | Test、TransPyV/Test |
|
||||
| FFI、PE 解析、Win32 绑定、进程/管道、JSON 库 | VET |
|
||||
| 裸机内核、中断/分页/调度、驱动(FAT32/USB/IDE/网络)、ELF + 动态库、UEFI 启动 | ViperOS |
|
||||
| 数值计算、SIMD 加速、Qt6 GUI、自定义训练循环 | ViperMNIST |
|
||||
|
||||
Reference in new issue
Block a user