refactor: 重命名 command checker 为 cmd checker 并适配跨平台测试
将 type/configKey 从 "command" 统一为 "cmd",源码目录 runner/command/ → runner/cmd/, spec 目录 command-checker/ → cmd-checker/,测试全部改用 bun -e 替代 Unix 系统命令, 归档 cmd-checker-enhancement 变更并同步 delta spec 到主 spec。
This commit is contained in:
@@ -12,7 +12,7 @@ defaults:
|
||||
http:
|
||||
method: GET
|
||||
maxBodyBytes: "10MB"
|
||||
command:
|
||||
cmd:
|
||||
maxOutputBytes: "1MB"
|
||||
|
||||
targets:
|
||||
@@ -149,75 +149,74 @@ targets:
|
||||
expect:
|
||||
status: [200]
|
||||
|
||||
# ========== Command targets ==========
|
||||
# ========== Cmd targets ==========
|
||||
|
||||
- name: "uname 输出匹配"
|
||||
type: command
|
||||
- name: "Bun 版本输出匹配"
|
||||
type: cmd
|
||||
group: "系统检查"
|
||||
command:
|
||||
exec: "uname"
|
||||
args: ["-s"]
|
||||
cmd:
|
||||
exec: "bun"
|
||||
args: ["--version"]
|
||||
expect:
|
||||
exitCode: [0]
|
||||
stdout:
|
||||
- match: "^[A-Z][a-z]+$"
|
||||
- match: "^\\d+\\.\\d+\\.\\d+"
|
||||
|
||||
- name: "echo 自定义文本输出"
|
||||
type: command
|
||||
command:
|
||||
exec: "echo"
|
||||
args: ["check ok"]
|
||||
- name: "自定义文本输出"
|
||||
type: cmd
|
||||
cmd:
|
||||
exec: "bun"
|
||||
args: ["-e", "console.log('check ok')"]
|
||||
expect:
|
||||
stdout:
|
||||
- equals: "check ok\n"
|
||||
maxDurationMs: 3000
|
||||
|
||||
- name: "ls 目录无 stderr"
|
||||
type: command
|
||||
command:
|
||||
exec: "ls"
|
||||
args: ["/tmp"]
|
||||
cwd: "/"
|
||||
- name: "脚本执行无 stderr"
|
||||
type: cmd
|
||||
cmd:
|
||||
exec: "bun"
|
||||
args: ["-e", "process.stdout.write('ok')"]
|
||||
expect:
|
||||
exitCode: [0]
|
||||
stderr:
|
||||
- empty: true
|
||||
|
||||
- name: "date 输出包含年份"
|
||||
type: command
|
||||
command:
|
||||
exec: "date"
|
||||
args: ["+%Y"]
|
||||
- name: "日期脚本输出包含年份"
|
||||
type: cmd
|
||||
cmd:
|
||||
exec: "bun"
|
||||
args: ["-e", "console.log(new Date().getFullYear())"]
|
||||
expect:
|
||||
stdout:
|
||||
- match: "^20\\d{2}\n?$"
|
||||
|
||||
- name: "wc 行数计数"
|
||||
type: command
|
||||
command:
|
||||
exec: "wc"
|
||||
args: ["-l"]
|
||||
cwd: "/etc"
|
||||
- name: "环境变量覆盖"
|
||||
type: cmd
|
||||
cmd:
|
||||
exec: "bun"
|
||||
args: ["-e", "console.log(process.env.LANG ?? '')"]
|
||||
env:
|
||||
LANG: "C"
|
||||
expect:
|
||||
stdout:
|
||||
- match: "\\d+"
|
||||
- contains: "C"
|
||||
|
||||
- name: "hostname 非空输出"
|
||||
type: command
|
||||
command:
|
||||
exec: "hostname"
|
||||
- name: "运行平台非空输出"
|
||||
type: cmd
|
||||
cmd:
|
||||
exec: "bun"
|
||||
args: ["-e", "console.log(process.platform)"]
|
||||
expect:
|
||||
stdout:
|
||||
- match: ".+"
|
||||
|
||||
- name: "多规则 stdout 顺序校验"
|
||||
type: command
|
||||
type: cmd
|
||||
interval: "5m"
|
||||
command:
|
||||
exec: "echo"
|
||||
args: ["version: 2.0.1, status: healthy"]
|
||||
cmd:
|
||||
exec: "bun"
|
||||
args: ["-e", "console.log('version: 2.0.1, status: healthy')"]
|
||||
expect:
|
||||
stdout:
|
||||
- contains: "version:"
|
||||
@@ -225,11 +224,11 @@ targets:
|
||||
- contains: "healthy"
|
||||
|
||||
- name: "stderr 内容检查"
|
||||
type: command
|
||||
command:
|
||||
exec: "ls"
|
||||
args: ["/nonexistent-path-checker-test"]
|
||||
type: cmd
|
||||
cmd:
|
||||
exec: "bun"
|
||||
args: ["-e", "process.stderr.write('simulated error\\n'); process.exit(1)"]
|
||||
expect:
|
||||
exitCode: [0, 1, 2]
|
||||
exitCode: [1]
|
||||
stderr:
|
||||
- contains: "No such file"
|
||||
- contains: "simulated error"
|
||||
|
||||
Reference in New Issue
Block a user