Files
Pake/tests/README.md
2025-08-22 12:47:37 +08:00

90 lines
2.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Pake CLI 测试
统一的 CLI 构建测试套件,验证多平台打包功能。
## 运行测试
```bash
# 完整测试套件(推荐)
npm test # 运行完整测试套件包含真实构建测试8-12分钟
# 开发时快速测试
npm test -- --no-build # 跳过构建测试仅验证核心功能30秒
```
### 🚀 完整测试套件包含:
-**单元测试**CLI命令、参数验证、响应时间
-**集成测试**:进程管理、文件权限、依赖解析
-**构建器测试**:平台检测、架构检测、文件命名
-**真实构建测试**完整的GitHub.com应用打包验证
## 测试内容
### 单元测试6个
- 版本命令 (`--version`)
- 帮助命令 (`--help`)
- URL 验证(有效/无效链接)
- 参数验证(数字类型检查)
- CLI 响应时间(<2秒
- Weekly URL 可访问性
### 集成测试3个
- 进程生成和管理
- 文件系统权限检查
- 依赖包解析验证
### 构建测试3个
- 平台检测macOS/Windows/Linux
- 架构检测Intel/ARM64
- 文件命名模式验证
### 真实构建测试(重点)
**macOS**: 🔥 多架构构建Universal Binary
- 编译 Intel + Apple Silicon 双架构
- 检测 `.app` 文件生成:`GitHubMultiArch.app`
- 备用检测:`src-tauri/target/universal-apple-darwin/release/bundle/macos/`
- 验证通用二进制:`file` 命令检查架构
**Windows**: 单架构构建
- 检测 EXE 文件:`src-tauri/target/x86_64-pc-windows-msvc/release/pake.exe`
- 检测 MSI 安装包:`src-tauri/target/x86_64-pc-windows-msvc/release/bundle/msi/*.msi`
**Linux**: 单架构构建
- 检测 DEB 包:`src-tauri/target/release/bundle/deb/*.deb`
- 检测 AppImage`src-tauri/target/release/bundle/appimage/*.AppImage`
## 为什么重点测试多架构?
多架构构建是最复杂、最容易出错的环节:
- 需要同时编译两个架构x86_64 + aarch64
- 生成通用二进制文件技术复杂
- 架构兼容性问题频发
- Apple Silicon 迁移期关键功能
## 测试结果
总计:**13 个测试**,全部通过表示 CLI 功能正常。
## 故障排除
**CLI 文件不存在**:运行 `npm run cli:build`
**测试超时**:构建测试需要较长时间完成
**构建失败**:检查 Rust 工具链 `rustup update`
**权限错误**:确保有写入权限
## 开发建议
提交代码前建议运行 `npm test` 确保所有平台构建正常。