rename(tests): move aot tests directory to compiler

- Renamed test directory from tests/aot/ to tests/compiler/
- Updated all references in documentation files to point to new location
- Modified test runner commands to use new compiler test path
- Updated guide documentation to reflect directory name change
- Changed all test file paths in markdown documentation accordingly
pull/17/head
韩天峰 1 month ago
parent 55b22f8d1d
commit 33f6c67e13
  1. 8
      .github/copilot-instructions.md
  2. 6
      CLAUDE.md
  3. 6
      docs/HIGH_PRECISION_TYPES.md
  4. 4
      docs/QUICKSTART.md
  5. 10
      docs/UNIVERSAL_METHODS.md
  6. 2
      docs/hhvm-review.md
  7. 2
      docs/kphp-review.md
  8. 38
      tests/compiler/RUN_TESTS_GUIDE.md
  9. 12
      tests/compiler/SKIP_TESTS.md
  10. 18
      tests/compiler/TEST_SUPPLEMENT_REPORT.md

@ -53,14 +53,14 @@ Run a single PHPUnit file or a single test method:
Run PHPT integration tests: Run PHPT integration tests:
```bash ```bash
php run-tests.php tests/aot/ php run-tests.php tests/compiler/
php run-tests.php tests/aot/arrays.phpt php run-tests.php tests/compiler/arrays.phpt
``` ```
For parser/runtime comparison without AOT compilation, there are docs using: For parser/runtime comparison without AOT compilation, there are docs using:
```bash ```bash
php run-tests.php --no-aot tests/aot/arrow-functions.phpt php run-tests.php --no-aot tests/compiler/arrow-functions.phpt
``` ```
## Formatting ## Formatting
@ -87,4 +87,4 @@ Generated C++ is auto-formatted by the compiler itself when `clang-format` is av
- PHPUnit tests for compiler internals should use `CompilerTest::create(ROOT_PATH)`, which enables test mode instead of normal fatal exits. - PHPUnit tests for compiler internals should use `CompilerTest::create(ROOT_PATH)`, which enables test mode instead of normal fatal exits.
- `phpunit/bootstrap.php` exposes a `BaseTest::exec()` helper that expects compilation failures to surface as `TypePhp\Exception\TestError`. - `phpunit/bootstrap.php` exposes a `BaseTest::exec()` helper that expects compilation failures to surface as `TypePhp\Exception\TestError`.
- PHPT end-to-end tests live in `tests/aot/`; existing guidance and examples generally put executable test logic inside a `main()` function. - PHPT end-to-end tests live in `tests/compiler/`; existing guidance and examples generally put executable test logic inside a `main()` function.

@ -40,10 +40,10 @@ composer install
./vendor/bin/phpunit phpunit/src/AstNodeTypeTest.php ./vendor/bin/phpunit phpunit/src/AstNodeTypeTest.php
# Run PHPT integration tests (all) # Run PHPT integration tests (all)
php run-tests.php tests/aot/ php run-tests.php tests/compiler/
# Run a single PHPT test # Run a single PHPT test
php run-tests.php tests/aot/arrays.phpt php run-tests.php tests/compiler/arrays.phpt
``` ```
## Architecture ## Architecture
@ -98,6 +98,6 @@ Generated `.cc` and `.o` files land in `build/` directory. The compiled binary i
### Test Infrastructure ### Test Infrastructure
- **PHPUnit tests** (`phpunit/src/`) — unit/integration tests for compiler internals. Bootstrap at `phpunit/bootstrap.php` defines a `BaseTest` class with an `exec()` helper that runs the compiler and expects a `TestError` exception containing a given string - **PHPUnit tests** (`phpunit/src/`) — unit/integration tests for compiler internals. Bootstrap at `phpunit/bootstrap.php` defines a `BaseTest` class with an `exec()` helper that runs the compiler and expects a `TestError` exception containing a given string
- **PHPT tests** (`tests/aot/`) — end-to-end tests using the standard PHPT format (`run-tests.php`). Each `.phpt` contains PHP source and expected output sections - **PHPT tests** (`tests/compiler/`) — end-to-end tests using the standard PHPT format (`run-tests.php`). Each `.phpt` contains PHP source and expected output sections
When writing new compiler tests, use `CompilerTest::create(ROOT_PATH)` (in `src/CompilerTest.php`) which sets `forTest = true` to enable test-specific behavior without writing files to disk. When writing new compiler tests, use `CompilerTest::create(ROOT_PATH)` (in `src/CompilerTest.php`) which sets `forTest = true` to enable test-specific behavior without writing files to disk.

@ -746,9 +746,9 @@ pi × 2: 6.2831800000000000
## 进一步阅读 ## 进一步阅读
- **类型系统规范**:[`docs/NATIVE_TYPES.md`](NATIVE_TYPES.md) — 完整的类型提升规则、声明语法、C++ API 参考 - **类型系统规范**:[`docs/NATIVE_TYPES.md`](NATIVE_TYPES.md) — 完整的类型提升规则、声明语法、C++ API 参考
- **BigInt PHPT 测试**:[`tests/aot/bigint/`](../tests/aot/bigint/) — BigInt 各项功能的集成测试 - **BigInt PHPT 测试**:[`tests/compiler/bigint/`](../tests/compiler/bigint/) — BigInt 各项功能的集成测试
- **Decimal PHPT 测试**:[`tests/aot/decimal/`](../tests/aot/decimal/) — Decimal 各项功能的集成测试 - **Decimal PHPT 测试**:[`tests/compiler/decimal/`](../tests/compiler/decimal/) — Decimal 各项功能的集成测试
- **BigFloat 集成测试**:[`tests/aot/bignumber/bigfloat_operators.phpt`](../tests/aot/bignumber/bigfloat_operators.phpt) — BigFloat 运算符测试 - **BigFloat 集成测试**:[`tests/compiler/bignumber/bigfloat_operators.phpt`](../tests/compiler/bignumber/bigfloat_operators.phpt) — BigFloat 运算符测试
- **C++ 运行时头文件** - **C++ 运行时头文件**
- [`phpx/include/phpx_big_int.h`](../../phpx/include/phpx_big_int.h) — BigInt C++ API - [`phpx/include/phpx_big_int.h`](../../phpx/include/phpx_big_int.h) — BigInt C++ API
- [`phpx/include/phpx_decimal.h`](../../phpx/include/phpx_decimal.h) — Decimal C++ API - [`phpx/include/phpx_decimal.h`](../../phpx/include/phpx_decimal.h) — Decimal C++ API

@ -209,13 +209,13 @@ for ($i = 0; $i < 10; $i++) { // 错误!
### 运行单个测试 ### 运行单个测试
```bash ```bash
PHPT=1 php run-tests.php tests/aot/arrow_fn/001.phpt PHPT=1 php run-tests.php tests/compiler/arrow_fn/001.phpt
``` ```
### 运行所有测试 ### 运行所有测试
```bash ```bash
PHPT=1 php run-tests.php tests/aot/ PHPT=1 php run-tests.php tests/compiler/
``` ```
### 查看测试结果 ### 查看测试结果

@ -1105,8 +1105,8 @@ function main(): void {
- **类型系统规范**:[`docs/NATIVE_TYPES.md`](NATIVE_TYPES.md) - **类型系统规范**:[`docs/NATIVE_TYPES.md`](NATIVE_TYPES.md)
- **通用方法实现**:[`src/Parser/UniversalMethodCall.php`](../src/Parser/UniversalMethodCall.php) - **通用方法实现**:[`src/Parser/UniversalMethodCall.php`](../src/Parser/UniversalMethodCall.php)
- **集成测试** - **集成测试**
- [`tests/aot/string_method/`](../tests/aot/string_method/) — String 通用方法测试 - [`tests/compiler/string_method/`](../tests/compiler/string_method/) — String 通用方法测试
- [`tests/aot/array_method/`](../tests/aot/array_method/) — Array 通用方法测试 - [`tests/compiler/array_method/`](../tests/compiler/array_method/) — Array 通用方法测试
- [`tests/aot/stream_method/`](../tests/aot/stream_method/) — Stream 通用方法测试 - [`tests/compiler/stream_method/`](../tests/compiler/stream_method/) — Stream 通用方法测试
- [`tests/aot/bigint/`](../tests/aot/bigint/) — BigInt 通用方法测试 - [`tests/compiler/bigint/`](../tests/compiler/bigint/) — BigInt 通用方法测试
- [`tests/aot/decimal/`](../tests/aot/decimal/) — Decimal 通用方法测试 - [`tests/compiler/decimal/`](../tests/compiler/decimal/) — Decimal 通用方法测试

@ -422,7 +422,7 @@ HHVM 有庞大的测试体系:
- Zend 测试:直接复用 php-src 官方测试,验证 PHP 兼容性 - Zend 测试:直接复用 php-src 官方测试,验证 PHP 兼容性
**AOT 借鉴:** **AOT 借鉴:**
- Quick/Slow 分层测试策略——将现有 `tests/aot/` 按运行时间分类 - Quick/Slow 分层测试策略——将现有 `tests/compiler/` 按运行时间分类
- 直接复用 php-src 官方 PHPT 测试——验证 AOT 编译器的 PHP 行为兼容性 - 直接复用 php-src 官方 PHPT 测试——验证 AOT 编译器的 PHP 行为兼容性
- HHBBC 内部单元测试太少(仅 3 个),不应效仿——AOT 的 PHPUnit 测试覆盖更好 - HHBBC 内部单元测试太少(仅 3 个),不应效仿——AOT 的 PHPUnit 测试覆盖更好

@ -293,7 +293,7 @@ KPHP 有三层测试体系:
- 增量编译支持(nocc 分布式编译) - 增量编译支持(nocc 分布式编译)
**AOT 借鉴**: **AOT 借鉴**:
- 当前 AOT 只有 `phpunit/` (PHPUnit) 和 `tests/aot/` (PHPT) 两层,缺少编译器内部单元测试和集成测试 - 当前 AOT 只有 `phpunit/` (PHPUnit) 和 `tests/compiler/` (PHPT) 两层,缺少编译器内部单元测试和集成测试
- 标签机制比纯 PHPT 更灵活——可以标记预期编译失败、预期警告等 - 标签机制比纯 PHPT 更灵活——可以标记预期编译失败、预期警告等
- Python 测试 runner 提供了更好的 CI 集成能力 - Python 测试 runner 提供了更好的 CI 集成能力

@ -2,7 +2,7 @@
## 测试文件位置 ## 测试文件位置
所有测试文件位于 `tests/aot/` 目录下,使用 `.phpt` 扩展名。 所有测试文件位于 `tests/compiler/` 目录下,使用 `.phpt` 扩展名。
## 运行测试 ## 运行测试
@ -10,39 +10,39 @@
```bash ```bash
# 运行特定测试文件 # 运行特定测试文件
php run-tests.php tests/aot/test-name.phpt php run-tests.php tests/compiler/test-name.phpt
# 示例:运行 match expression 测试 # 示例:运行 match expression 测试
php run-tests.php tests/aot/match-expression.phpt php run-tests.php tests/compiler/match-expression.phpt
``` ```
### 运行多个测试 ### 运行多个测试
```bash ```bash
# 运行多个测试(使用通配符) # 运行多个测试(使用通配符)
php run-tests.php tests/aot/pattern*.phpt php run-tests.php tests/compiler/pattern*.phpt
# 运行整个目录 # 运行整个目录
php run-tests.php tests/aot/ php run-tests.php tests/compiler/
``` ```
### 常用选项 ### 常用选项
```bash ```bash
# 显示详细信息 # 显示详细信息
php run-tests.php tests/aot/test-name.phpt -v php run-tests.php tests/compiler/test-name.phpt -v
# 并行运行测试(加快测试速度) # 并行运行测试(加快测试速度)
php run-tests.php tests/aot/ -j4 php run-tests.php tests/compiler/ -j4
# 只显示失败的测试 # 只显示失败的测试
php run-tests.php tests/aot/ -g FAIL php run-tests.php tests/compiler/ -g FAIL
# 保持测试生成的文件 # 保持测试生成的文件
php run-tests.php tests/aot/test-name.phpt --keep-all php run-tests.php tests/compiler/test-name.phpt --keep-all
# 显示内存使用情况 # 显示内存使用情况
php run-tests.php tests/aot/test-name.phpt -m php run-tests.php tests/compiler/test-name.phpt -m
``` ```
## 新增测试用例说明 ## 新增测试用例说明
@ -89,7 +89,7 @@ php run-tests.php tests/aot/test-name.phpt -m
### 基本步骤 ### 基本步骤
1. 在 `tests/aot/` 目录创建新文件,如 `my-feature.phpt` 1. 在 `tests/compiler/` 目录创建新文件,如 `my-feature.phpt`
2. 添加测试头部: 2. 添加测试头部:
``` ```
@ -151,7 +151,7 @@ string(6) "result"
### 查看差异 ### 查看差异
```bash ```bash
php run-tests.php tests/aot/failed-test.phpt -v php run-tests.php tests/compiler/failed-test.phpt -v
``` ```
输出会显示期望值和实际值的差异: 输出会显示期望值和实际值的差异:
@ -168,20 +168,20 @@ string(7) "results"
```bash ```bash
# 保持生成的 C++ 文件 # 保持生成的 C++ 文件
php run-tests.php tests/aot/test-name.phpt --keep-all php run-tests.php tests/compiler/test-name.phpt --keep-all
# 查看生成的 C++ 代码 # 查看生成的 C++ 代码
cat build/tests/aot/test-name.cc cat build/tests/compiler/test-name.cc
``` ```
### 手动编译和运行 ### 手动编译和运行
```bash ```bash
# 1. 生成 stub 文件 # 1. 生成 stub 文件
php bin/gen_stub.php -f tests/aot/test-name.php php bin/gen_stub.php -f tests/compiler/test-name.php
# 2. 转换为 C++ # 2. 转换为 C++
php bin/compiler.php tests/aot/test-name.php php bin/compiler.php tests/compiler/test-name.php
# 3. 编译 C++ 代码 # 3. 编译 C++ 代码
cd build && make test-name cd build && make test-name
@ -196,13 +196,13 @@ cd build && make test-name
```bash ```bash
# 统计测试文件数量 # 统计测试文件数量
ls tests/aot/*.phpt | wc -l ls tests/compiler/*.phpt | wc -l
# 查看所有测试文件 # 查看所有测试文件
ls tests/aot/*.phpt | sort ls tests/compiler/*.phpt | sort
# 查看测试覆盖总结 # 查看测试覆盖总结
cat tests/aot/README_TEST_COVERAGE.md cat tests/compiler/README_TEST_COVERAGE.md
``` ```
## 常见问题 ## 常见问题

@ -79,17 +79,17 @@ echo "skip 不支持的原因";
### 方法 2: 运行测试时观察 ### 方法 2: 运行测试时观察
```bash ```bash
php run-tests.php tests/aot/generators.phpt php run-tests.php tests/compiler/generators.phpt
``` ```
输出会显示: 输出会显示:
``` ```
TEST /home/swoole/workspace/aot/tests/aot/generators.phpt TEST /home/swoole/workspace/aot/tests/compiler/generators.phpt
SKIP Generator syntax not supported in AOT [tests/aot/generators.phpt] SKIP Generator syntax not supported in AOT [tests/compiler/generators.phpt]
``` ```
### 方法 3: 统计 Skip 测试数量 ### 方法 3: 统计 Skip 测试数量
```bash ```bash
grep -l "^--SKIPIF--" tests/aot/*.phpt | wc -l grep -l "^--SKIPIF--" tests/compiler/*.phpt | wc -l
``` ```
--- ---
@ -148,7 +148,7 @@ grep -l "^--SKIPIF--" tests/aot/*.phpt | wc -l
2. **运行测试验证** 2. **运行测试验证**
```bash ```bash
php run-tests.php tests/aot/test-name.phpt -v php run-tests.php tests/compiler/test-name.phpt -v
``` ```
3. **确认测试通过** 3. **确认测试通过**
@ -210,7 +210,7 @@ A: 保留这些测试可以作为未来的开发参考,并且可以在功能
A: 不会。Skip 测试会被正确识别并单独统计,不会影响 pass/fail 的比例。 A: 不会。Skip 测试会被正确识别并单独统计,不会影响 pass/fail 的比例。
### Q: 如何查看所有 skip 测试? ### Q: 如何查看所有 skip 测试?
A: 运行 `php run-tests.php tests/aot/ -g SKIP` 可以查看所有 skip 测试及其原因。 A: 运行 `php run-tests.php tests/compiler/ -g SKIP` 可以查看所有 skip 测试及其原因。
### Q: 什么时候会移除 skip 标记? ### Q: 什么时候会移除 skip 标记?
A: 当对应的语法被实现并通过测试验证后,会移除 skip 标记。 A: 当对应的语法被实现并通过测试验证后,会移除 skip 标记。

@ -2,7 +2,7 @@
## 📋 概述 ## 📋 概述
本次 review 了 `tests/aot/` 目录下的所有单测文件,分析了 PHP 语法覆盖情况,并新增了多个重要测试场景。 本次 review 了 `tests/compiler/` 目录下的所有单测文件,分析了 PHP 语法覆盖情况,并新增了多个重要测试场景。
--- ---
@ -379,10 +379,10 @@ function sumTree(array $tree): int {
### 新增文件位置 ### 新增文件位置
所有新增测试文件位于 `tests/aot/` 目录: 所有新增测试文件位于 `tests/compiler/` 目录:
``` ```
tests/aot/ tests/compiler/
├── readonly-class.phpt # Readonly 类测试 ├── readonly-class.phpt # Readonly 类测试
├── backed-enum.phpt # Backed 枚举测试 ├── backed-enum.phpt # Backed 枚举测试
├── first-class-callable.phpt # 一类可调用语法测试 ├── first-class-callable.phpt # 一类可调用语法测试
@ -393,16 +393,16 @@ tests/aot/
```bash ```bash
# 运行单个测试 # 运行单个测试
php run-tests.php tests/aot/readonly-class.phpt php run-tests.php tests/compiler/readonly-class.phpt
# 运行所有新增测试 # 运行所有新增测试
php run-tests.php tests/aot/readonly-class.phpt \ php run-tests.php tests/compiler/readonly-class.phpt \
tests/aot/backed-enum.phpt \ tests/compiler/backed-enum.phpt \
tests/aot/first-class-callable.phpt \ tests/compiler/first-class-callable.phpt \
tests/aot/deep-recursion.phpt tests/compiler/deep-recursion.phpt
# 运行所有 AOT 测试 # 运行所有 AOT 测试
php run-tests.php tests/aot/ php run-tests.php tests/compiler/
``` ```
--- ---

Loading…
Cancel
Save