gatelight 0.0.0-stage → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.antigravity-plugin/plugin.json +9 -0
- package/.claude-plugin/plugin.json +11 -0
- package/.codex-plugin/plugin.json +18 -0
- package/.mcp.json +8 -0
- package/LICENSE +21 -0
- package/README.md +29 -2
- package/bin/modwall +8 -0
- package/bin/node.sh +14 -0
- package/bin/testcraft +8 -0
- package/bin/testpace +8 -0
- package/entry/command +44 -0
- package/hooks/antigravity.sh +24 -0
- package/hooks/codex.json +50 -0
- package/hooks/codex.sh +7 -0
- package/hooks/hooks.json +43 -0
- package/hooks/testpace.ts +25 -0
- package/hooks.json +16 -0
- package/mcp_config.json +8 -0
- package/package.json +23 -4
- package/setup.mjs +99 -0
- package/skills/merge/SKILL.md +42 -0
- package/skills/modular/SKILL.md +75 -0
- package/skills/setup/SKILL.md +101 -0
- package/skills/setup-modwall/SKILL.md +112 -0
- package/skills/setup-testcraft/SKILL.md +23 -0
- package/skills/setup-testcraft/checklist/dev-login.md +20 -0
- package/skills/write-tests/SKILL.md +153 -0
- package/src/base/agent.ts +100 -0
- package/src/base/baseline.ts +54 -0
- package/src/base/commandline.ts +40 -0
- package/src/base/commands.ts +94 -0
- package/src/base/confirm.ts +161 -0
- package/src/base/contract.ts +94 -0
- package/src/base/coverage.ts +46 -0
- package/src/base/entry.ts +90 -0
- package/src/base/excerpt.ts +46 -0
- package/src/base/execute.ts +70 -0
- package/src/base/exit.ts +6 -0
- package/src/base/format.ts +27 -0
- package/src/base/full.ts +160 -0
- package/src/base/gate.ts +251 -0
- package/src/base/git.ts +361 -0
- package/src/base/glob.ts +38 -0
- package/src/base/hook.ts +297 -0
- package/src/base/hookformat.ts +257 -0
- package/src/base/judging.ts +27 -0
- package/src/base/layermap.ts +69 -0
- package/src/base/module.ts +88 -0
- package/src/base/process-group.ts +101 -0
- package/src/base/records.ts +66 -0
- package/src/base/repo.ts +155 -0
- package/src/base/sessions.ts +55 -0
- package/src/base/shell.ts +176 -0
- package/src/base/stop.ts +100 -0
- package/src/base/store.ts +348 -0
- package/src/base/version.ts +24 -0
- package/src/cli.ts +186 -0
- package/src/craft/change.ts +24 -0
- package/src/craft/checklist.ts +157 -0
- package/src/craft/commands.ts +111 -0
- package/src/craft/config.ts +15 -0
- package/src/craft/full.ts +30 -0
- package/src/craft/index.ts +12 -0
- package/src/craft/session.ts +21 -0
- package/src/mcp.ts +79 -0
- package/src/modules.ts +10 -0
- package/src/modwall.ts +8 -0
- package/src/pace/commands.ts +281 -0
- package/src/pace/config.ts +103 -0
- package/src/pace/consent.ts +81 -0
- package/src/pace/focused.ts +208 -0
- package/src/pace/full.ts +38 -0
- package/src/pace/index.ts +16 -0
- package/src/pace/record.ts +84 -0
- package/src/pace/report.ts +335 -0
- package/src/pace/results.ts +243 -0
- package/src/pace/run/node-test-reporter.mjs +34 -0
- package/src/pace/run/node-test.ts +26 -0
- package/src/pace/run/playwright-reporter.mjs +48 -0
- package/src/pace/run/playwright.ts +34 -0
- package/src/pace/run/runner.ts +157 -0
- package/src/pace/run/targets.ts +130 -0
- package/src/pace/run/vitest-launcher.mjs +101 -0
- package/src/pace/run/vitest.ts +22 -0
- package/src/pace/session.ts +35 -0
- package/src/pace/testlist.ts +91 -0
- package/src/pace/tests.ts +22 -0
- package/src/pace/verify.ts +95 -0
- package/src/testcraft.ts +9 -0
- package/src/wall/check.ts +258 -0
- package/src/wall/commands.ts +279 -0
- package/src/wall/config.ts +394 -0
- package/src/wall/database.ts +136 -0
- package/src/wall/dbcheck.ts +389 -0
- package/src/wall/dbrules.ts +213 -0
- package/src/wall/edit.ts +64 -0
- package/src/wall/files.ts +35 -0
- package/src/wall/full.ts +30 -0
- package/src/wall/index.ts +15 -0
- package/src/wall/init.ts +149 -0
- package/src/wall/layermap.ts +124 -0
- package/src/wall/layout.ts +231 -0
- package/src/wall/loosen.ts +157 -0
- package/src/wall/miniprogram.ts +80 -0
- package/src/wall/project.ts +88 -0
- package/src/wall/rules.ts +400 -0
- package/src/wall/session.ts +198 -0
- package/src/wall/sql.ts +510 -0
- package/src/wall/store.ts +39 -0
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
// 计时诊断:只汇总和报告,不替项目改任何东西。
|
|
2
|
+
|
|
3
|
+
import { AGENTS } from '../base/agent.ts'
|
|
4
|
+
import { COMMAND_KEYS } from './config.ts'
|
|
5
|
+
import { isValidPass } from '../base/coverage.ts'
|
|
6
|
+
import { duration, day, short, when } from '../base/format.ts'
|
|
7
|
+
import type { Landing } from '../base/git.ts'
|
|
8
|
+
import type { PaceRun } from './record.ts'
|
|
9
|
+
import { testFile } from './testlist.ts'
|
|
10
|
+
|
|
11
|
+
/** fast 平均超过这个时长,提示它可能不是增量的。 */
|
|
12
|
+
export const FAST_SLOW_MS = 20_000
|
|
13
|
+
|
|
14
|
+
const WEEK_MS = 7 * 24 * 3600 * 1000
|
|
15
|
+
/** 报告里最多列出几份先失败后通过的代码。 */
|
|
16
|
+
const SHOWN_RETRIED = 5
|
|
17
|
+
|
|
18
|
+
export interface CommandStats {
|
|
19
|
+
count: number
|
|
20
|
+
pass: number
|
|
21
|
+
fail: number
|
|
22
|
+
totalMs: number
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function commandStats(runs: PaceRun[]): Map<string, CommandStats> {
|
|
26
|
+
const stats = new Map<string, CommandStats>()
|
|
27
|
+
for (const run of runs) {
|
|
28
|
+
const s = stats.get(run.kind) ?? { count: 0, pass: 0, fail: 0, totalMs: 0 }
|
|
29
|
+
s.count += 1
|
|
30
|
+
s.totalMs += run.durationMs
|
|
31
|
+
if (run.result === 'pass') s.pass += 1
|
|
32
|
+
else s.fail += 1
|
|
33
|
+
stats.set(run.kind, s)
|
|
34
|
+
}
|
|
35
|
+
return stats
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** 谁跑的:agent 的名字;记了版本却没有 agent 的是用户在终端里跑的;版本也没有的是旧版本写的,不知道谁跑的。 */
|
|
39
|
+
function runnerOf(run: PaceRun): string {
|
|
40
|
+
if (run.agent) return AGENTS[run.agent].name
|
|
41
|
+
return run.version ? '终端' : '未记录(旧版本)'
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** 按谁跑的分开:次数、合计用时、整组次数,多的在前。只有一种时返回空:不用分。 */
|
|
45
|
+
export function byRunner(runs: PaceRun[]): Array<{ runner: string; count: number; totalMs: number; fulls: number }> {
|
|
46
|
+
const rows = new Map<string, { runner: string; count: number; totalMs: number; fulls: number }>()
|
|
47
|
+
for (const run of runs) {
|
|
48
|
+
const runner = runnerOf(run)
|
|
49
|
+
const row = rows.get(runner) ?? { runner, count: 0, totalMs: 0, fulls: 0 }
|
|
50
|
+
row.count += 1
|
|
51
|
+
row.totalMs += run.durationMs
|
|
52
|
+
if (run.kind === 'full') row.fulls += 1
|
|
53
|
+
rows.set(runner, row)
|
|
54
|
+
}
|
|
55
|
+
return rows.size > 1 ? [...rows.values()].sort((a, b) => b.totalMs - a.totalMs) : []
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** 测试文件被 files 跑了多少次,多的在前。 */
|
|
59
|
+
export function repeatedFiles(runs: PaceRun[]): Array<[string, number]> {
|
|
60
|
+
const counts = new Map<string, number>()
|
|
61
|
+
for (const run of runs) {
|
|
62
|
+
// 连跑(--repeat)是有意的,不算反复跑
|
|
63
|
+
if (run.kind !== 'files' || run.repeat) continue
|
|
64
|
+
// 文件:行号 算那个文件;一次里给了同一文件的几行,算跑了一次
|
|
65
|
+
for (const file of new Set((run.files ?? []).map(testFile))) counts.set(file, (counts.get(file) ?? 0) + 1)
|
|
66
|
+
}
|
|
67
|
+
return [...counts].filter(([, n]) => n > 1).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** 每个工作区里,整组失败后连续又跑了几轮才通过。 */
|
|
71
|
+
export function rerunsAfterFailure(runs: PaceRun[]): number[] {
|
|
72
|
+
const byWorktree = new Map<string, PaceRun[]>()
|
|
73
|
+
for (const run of runs) {
|
|
74
|
+
if (run.kind !== 'full') continue
|
|
75
|
+
const list = byWorktree.get(run.worktree) ?? []
|
|
76
|
+
list.push(run)
|
|
77
|
+
byWorktree.set(run.worktree, list)
|
|
78
|
+
}
|
|
79
|
+
const rounds: number[] = []
|
|
80
|
+
for (const list of byWorktree.values()) {
|
|
81
|
+
let failures = 0
|
|
82
|
+
for (const run of list.sort((a, b) => a.startedAt - b.startedAt)) {
|
|
83
|
+
if (run.result === 'fail') failures += 1
|
|
84
|
+
else if (isValidPass(run)) {
|
|
85
|
+
if (failures > 0) rounds.push(failures)
|
|
86
|
+
failures = 0
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return rounds
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** 同一份代码整组先失败、后通过:可能是测试不稳定,也可能是环境问题(数据库没起来这类),要看失败的日志才分得清。 */
|
|
94
|
+
export interface FailedThenPassed {
|
|
95
|
+
tree: string
|
|
96
|
+
failed: PaceRun
|
|
97
|
+
passed: PaceRun
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** 同一份代码内容,整组先失败、后通过。只看跑的过程中代码没改过的运行。 */
|
|
101
|
+
export function failedThenPassed(runs: PaceRun[]): FailedThenPassed[] {
|
|
102
|
+
const byTree = new Map<string, PaceRun[]>()
|
|
103
|
+
for (const run of runs) {
|
|
104
|
+
if (run.kind !== 'full' || run.tree !== run.treeAtEnd) continue
|
|
105
|
+
const list = byTree.get(run.tree) ?? []
|
|
106
|
+
list.push(run)
|
|
107
|
+
byTree.set(run.tree, list)
|
|
108
|
+
}
|
|
109
|
+
const found: FailedThenPassed[] = []
|
|
110
|
+
for (const [tree, list] of byTree) {
|
|
111
|
+
const failed = list.filter(run => run.result === 'fail').sort((a, b) => a.startedAt - b.startedAt)[0]
|
|
112
|
+
if (!failed) continue
|
|
113
|
+
const passed = list.find(run => run.result === 'pass' && run.startedAt > failed.startedAt)
|
|
114
|
+
if (passed) found.push({ tree, failed, passed })
|
|
115
|
+
}
|
|
116
|
+
return found.sort((a, b) => b.passed.startedAt - a.passed.startedAt)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const CODE_EXTENSIONS = new Set([
|
|
120
|
+
'ts', 'tsx', 'mts', 'cts', 'js', 'jsx', 'mjs', 'cjs', 'vue', 'svelte',
|
|
121
|
+
'go', 'py', 'java', 'kt', 'kts', 'scala', 'swift', 'm', 'mm', 'rs', 'rb', 'php', 'cs',
|
|
122
|
+
'c', 'cc', 'cpp', 'h', 'hpp', 'sql',
|
|
123
|
+
])
|
|
124
|
+
|
|
125
|
+
const TEST_DIRS = new Set(['test', 'tests', '__tests__', 'e2e', 'testdata'])
|
|
126
|
+
const TEST_NAMES = [/\.(test|spec)\.[^./]+$/, /_test\.(go|py)$/, /^test_[^/]*\.py$/, /Tests?\.(swift|java|kt)$/]
|
|
127
|
+
|
|
128
|
+
export type FileRole = 'test' | 'code' | 'other'
|
|
129
|
+
|
|
130
|
+
/** 按常见命名规则区分测试代码和主代码;非代码文件(文档、配置、锁文件)不算。 */
|
|
131
|
+
export function fileRole(path: string): FileRole {
|
|
132
|
+
const parts = path.split('/')
|
|
133
|
+
const name = parts.at(-1)!
|
|
134
|
+
const ext = name.includes('.') ? name.slice(name.lastIndexOf('.') + 1) : ''
|
|
135
|
+
if (!CODE_EXTENSIONS.has(ext)) return 'other'
|
|
136
|
+
if (parts.slice(0, -1).some(part => TEST_DIRS.has(part))) return 'test'
|
|
137
|
+
if (TEST_NAMES.some(re => re.test(name))) return 'test'
|
|
138
|
+
return 'code'
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export interface WeekRow {
|
|
142
|
+
start: number
|
|
143
|
+
landings: number
|
|
144
|
+
testLines: number
|
|
145
|
+
codeLines: number
|
|
146
|
+
fullPasses: number
|
|
147
|
+
fullMedianMs?: number
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function median(values: number[]): number | undefined {
|
|
151
|
+
if (values.length === 0) return undefined
|
|
152
|
+
const sorted = [...values].sort((a, b) => a - b)
|
|
153
|
+
const mid = Math.floor(sorted.length / 2)
|
|
154
|
+
return sorted.length % 2 ? sorted[mid] : (sorted[mid - 1]! + sorted[mid]!) / 2
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** 按周汇总落地的测试行数、主代码行数,以及通过的整组耗时中位数。周从 since 开始算。 */
|
|
158
|
+
export function weekly(runs: PaceRun[], landingList: Landing[], since: number, now: number): WeekRow[] {
|
|
159
|
+
const rows: WeekRow[] = []
|
|
160
|
+
for (let start = since; start < now; start += WEEK_MS) {
|
|
161
|
+
const end = start + WEEK_MS
|
|
162
|
+
const row: WeekRow = { start, landings: 0, testLines: 0, codeLines: 0, fullPasses: 0 }
|
|
163
|
+
for (const landing of landingList) {
|
|
164
|
+
if (landing.time < start || landing.time >= end) continue
|
|
165
|
+
row.landings += 1
|
|
166
|
+
for (const file of landing.files) {
|
|
167
|
+
const role = fileRole(file.path)
|
|
168
|
+
if (role === 'test') row.testLines += file.added
|
|
169
|
+
else if (role === 'code') row.codeLines += file.added
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
const passes = runs.filter(run => isValidPass(run) && run.startedAt >= start && run.startedAt < end)
|
|
173
|
+
row.fullPasses = passes.length
|
|
174
|
+
row.fullMedianMs = median(passes.map(run => run.durationMs))
|
|
175
|
+
rows.push(row)
|
|
176
|
+
}
|
|
177
|
+
return rows
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* 平均每次落地花在测试上的时间和整组次数:看工作方式(比如几个分支一起合、还是一个分支合一次)有没有降下测试成本。
|
|
182
|
+
* 落地从这段时间里 testpace 第一次运行算起,接入前的落地不摊;分支上跑了、还没落地的也算在里面。
|
|
183
|
+
*/
|
|
184
|
+
export function landingCost(runs: PaceRun[], landings: Landing[], branch: string | undefined): string | undefined {
|
|
185
|
+
if (!branch || runs.length === 0) return undefined
|
|
186
|
+
const from = Math.min(...runs.map(run => run.startedAt))
|
|
187
|
+
const landed = landings.filter(landing => landing.time >= from).length
|
|
188
|
+
if (landed === 0) return undefined
|
|
189
|
+
const total = runs.reduce((sum, run) => sum + run.durationMs, 0)
|
|
190
|
+
const fulls = runs.filter(run => run.kind === 'full').length
|
|
191
|
+
return `落地到 ${branch} ${landed} 次,平均每次落地跑测试 ${duration(total / landed)}、整组 ${(fulls / landed).toFixed(1)} 次(从这段时间第一次运行算起,含分支上还没落地的)`
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export interface ReportInput {
|
|
195
|
+
repo: string
|
|
196
|
+
days: number
|
|
197
|
+
now: number
|
|
198
|
+
runs: PaceRun[]
|
|
199
|
+
defaultBranch?: string
|
|
200
|
+
landings: Landing[]
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** 整组里"跑测试"自己两段的名字(full.ts 交段时用,这里认旧记录时也用)。 */
|
|
204
|
+
export const FULL_STEP = '整组的检查(full)'
|
|
205
|
+
export const TESTS_STEP = '全部测试'
|
|
206
|
+
|
|
207
|
+
export interface StepStats {
|
|
208
|
+
/** 哪一段:模块给的名字(base/module.ts 的 FullStep.name)。 */
|
|
209
|
+
step: string
|
|
210
|
+
/** 跑到这一段的整组次数(前面一段没过的,后面的没有跑)。 */
|
|
211
|
+
count: number
|
|
212
|
+
totalMs: number
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* 整组的时间花在哪一段:各模块的检查、整组的检查(full)、全部测试,各跑了几次、共多久。按第一次出现的顺序。
|
|
217
|
+
* 只算记了分段的整组(旧版本写的记录没有分段);fulls 是这样的整组有几次。
|
|
218
|
+
* 段的名字是跑的时候模块给的;旧版本写的记录里没有名字的,"跑测试"自己的两段按 kind 认,别的写 kind。
|
|
219
|
+
*/
|
|
220
|
+
export function fullSteps(runs: PaceRun[]): { fulls: number; steps: StepStats[] } {
|
|
221
|
+
const stats = new Map<string, StepStats>()
|
|
222
|
+
let fulls = 0
|
|
223
|
+
for (const run of runs) {
|
|
224
|
+
if (run.kind !== 'full' || !run.steps) continue
|
|
225
|
+
fulls += 1
|
|
226
|
+
for (const step of run.steps) {
|
|
227
|
+
const name = step.name ?? (step.kind === 'full' ? FULL_STEP : step.kind === 'tests' ? TESTS_STEP : step.kind)
|
|
228
|
+
const s = stats.get(name) ?? { step: name, count: 0, totalMs: 0 }
|
|
229
|
+
s.count += 1
|
|
230
|
+
s.totalMs += step.durationMs
|
|
231
|
+
stats.set(name, s)
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return { fulls, steps: [...stats.values()] }
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function table(rows: string[][]): string[] {
|
|
238
|
+
const widths = rows[0]!.map((_, col) => Math.max(...rows.map(row => displayWidth(row[col]!))))
|
|
239
|
+
return rows.map(row => row.map((cell, col) => cell + ' '.repeat(widths[col]! - displayWidth(cell))).join(' ').trimEnd())
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function displayWidth(text: string): number {
|
|
243
|
+
let width = 0
|
|
244
|
+
for (const ch of text) width += /[ᄀ-ᅟ⺀-가-힣豈-︰-﹏-⦆¢-₩]/.test(ch) ? 2 : 1
|
|
245
|
+
return width
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export function renderReport(input: ReportInput): string {
|
|
249
|
+
const since = input.now - input.days * 24 * 3600 * 1000
|
|
250
|
+
const runs = input.runs.filter(run => run.startedAt >= since)
|
|
251
|
+
const lines: string[] = [`testpace 报告 · 最近 ${input.days} 天 · ${input.repo}`]
|
|
252
|
+
|
|
253
|
+
if (runs.length === 0) {
|
|
254
|
+
lines.push('', '这段时间没有 testpace 跑过的命令。')
|
|
255
|
+
} else {
|
|
256
|
+
const stats = commandStats(runs)
|
|
257
|
+
const rows = [['命令', '次数', '通过', '失败', '平均', '合计']]
|
|
258
|
+
for (const key of COMMAND_KEYS) {
|
|
259
|
+
const s = stats.get(key)
|
|
260
|
+
if (!s) continue
|
|
261
|
+
rows.push([key, String(s.count), String(s.pass), String(s.fail), duration(s.totalMs / s.count), duration(s.totalMs)])
|
|
262
|
+
}
|
|
263
|
+
lines.push('', ...table(rows))
|
|
264
|
+
|
|
265
|
+
const runners = byRunner(runs)
|
|
266
|
+
if (runners.length > 0) {
|
|
267
|
+
const byAgent = [['谁跑的', '次数', '整组', '合计']]
|
|
268
|
+
for (const row of runners) byAgent.push([row.runner, String(row.count), String(row.fulls), duration(row.totalMs)])
|
|
269
|
+
lines.push('', ...table(byAgent))
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
const parts = fullSteps(runs)
|
|
273
|
+
if (parts.fulls > 0) {
|
|
274
|
+
const all = parts.steps.reduce((sum, step) => sum + step.totalMs, 0)
|
|
275
|
+
const rows = [['整组的哪一段', '跑到', '平均', '合计', '占比']]
|
|
276
|
+
for (const step of parts.steps) {
|
|
277
|
+
rows.push([step.step, `${step.count} 次`, duration(step.totalMs / step.count), duration(step.totalMs), all > 0 ? `${Math.round((step.totalMs / all) * 100)}%` : '-'])
|
|
278
|
+
}
|
|
279
|
+
lines.push('', `整组的时间花在哪(${parts.fulls} 次整组;前一段没过,后面的不跑):`, ...table(rows))
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
const notes: string[] = []
|
|
283
|
+
const cost = landingCost(runs, input.landings, input.defaultBranch)
|
|
284
|
+
if (cost) notes.push(cost)
|
|
285
|
+
const full = stats.get('full')
|
|
286
|
+
if (full && full.fail > 0) {
|
|
287
|
+
const rounds = rerunsAfterFailure(runs)
|
|
288
|
+
const average = rounds.length ? (rounds.reduce((a, b) => a + b, 0) / rounds.length).toFixed(1) : undefined
|
|
289
|
+
notes.push(`整组失败 ${full.fail} 次` + (average ? `;失败后平均重跑 ${average} 轮才通过(${rounds.length} 次)` : ',之后还没有通过'))
|
|
290
|
+
}
|
|
291
|
+
const changedDuring = runs.filter(run => run.kind === 'full' && run.result === 'pass' && run.tree !== run.treeAtEnd).length
|
|
292
|
+
if (changedDuring > 0) notes.push(`整组跑的过程中代码改过 ${changedDuring} 次,这些结果没算通过记录`)
|
|
293
|
+
const retried = failedThenPassed(runs)
|
|
294
|
+
if (retried.length > 0) {
|
|
295
|
+
notes.push(
|
|
296
|
+
[
|
|
297
|
+
`先失败后通过:${retried.length} 份代码整组先失败、后通过。可能是测试不稳定,也可能是环境问题(比如数据库没起来),看失败的日志分辨:`,
|
|
298
|
+
...retried
|
|
299
|
+
.slice(0, SHOWN_RETRIED)
|
|
300
|
+
.map(({ tree, failed, passed }) => ` 代码 ${short(tree)}(${when(failed.startedAt)}):失败用时 ${duration(failed.durationMs)},之后通过用时 ${duration(passed.durationMs)},失败日志 ${failed.log}`),
|
|
301
|
+
...(retried.length > SHOWN_RETRIED ? [` 另有 ${retried.length - SHOWN_RETRIED} 份没列出`] : []),
|
|
302
|
+
].join('\n'),
|
|
303
|
+
)
|
|
304
|
+
}
|
|
305
|
+
const fast = stats.get('fast')
|
|
306
|
+
if (fast && fast.totalMs / fast.count > FAST_SLOW_MS) {
|
|
307
|
+
notes.push(`fast 平均 ${duration(fast.totalMs / fast.count)},超过 ${FAST_SLOW_MS / 1000} 秒,可能不是增量的`)
|
|
308
|
+
}
|
|
309
|
+
if (notes.length) lines.push('', ...notes)
|
|
310
|
+
|
|
311
|
+
const repeated = repeatedFiles(runs).slice(0, 10)
|
|
312
|
+
if (repeated.length > 0) {
|
|
313
|
+
lines.push('', '反复跑的测试文件(前 10):', ...repeated.map(([file, n]) => ` ${n} 次 ${file}`))
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
const weeks = weekly(input.runs, input.landings, since, input.now)
|
|
318
|
+
if (weeks.some(week => week.landings > 0 || week.fullPasses > 0)) {
|
|
319
|
+
const branch = input.defaultBranch ? `落地到 ${input.defaultBranch}` : '没找到默认分支'
|
|
320
|
+
const rows = [['周起始', '落地', '测试行', '主代码行', '测试/主代码', '整组通过', '整组耗时中位数']]
|
|
321
|
+
for (const week of weeks) {
|
|
322
|
+
rows.push([
|
|
323
|
+
day(week.start),
|
|
324
|
+
String(week.landings),
|
|
325
|
+
String(week.testLines),
|
|
326
|
+
String(week.codeLines),
|
|
327
|
+
week.codeLines > 0 ? (week.testLines / week.codeLines).toFixed(2) : '-',
|
|
328
|
+
String(week.fullPasses),
|
|
329
|
+
week.fullMedianMs === undefined ? '-' : duration(week.fullMedianMs),
|
|
330
|
+
])
|
|
331
|
+
}
|
|
332
|
+
lines.push('', `测试量和整组耗时(按周,${branch},行数为新增行,只看趋势):`, ...table(rows))
|
|
333
|
+
}
|
|
334
|
+
return lines.join('\n')
|
|
335
|
+
}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
// 每个测试的结果:testpace 跑项目命令时在环境变量 RESULTS_ENV 里给一个文件,命令里的 testpace run 把每个测试的结果追加进去
|
|
2
|
+
// (见 run/runner.ts)。跑完由这里读出来:记下没过的测试,认出时好时坏的测试(记进名单、点名),数同一个测试连着几轮没过。
|
|
3
|
+
// 项目没经 testpace run 跑的测试交不回结果,这些都不做。
|
|
4
|
+
|
|
5
|
+
import { existsSync, mkdtempSync, readFileSync, realpathSync, rmSync } from 'node:fs'
|
|
6
|
+
import { tmpdir } from 'node:os'
|
|
7
|
+
import { join, relative } from 'node:path'
|
|
8
|
+
import { currentAgent } from '../base/agent.ts'
|
|
9
|
+
import { when } from '../base/format.ts'
|
|
10
|
+
import type { Repo } from '../base/repo.ts'
|
|
11
|
+
import type { Ran } from './run/targets.ts'
|
|
12
|
+
import type { PaceRun } from './record.ts'
|
|
13
|
+
import { addFlaky, type FlakyTest, flakyTests, LOCATED, readRounds, removeFlaky, saveRounds, type TestId, testKey } from './testlist.ts'
|
|
14
|
+
|
|
15
|
+
export const RESULTS_ENV = 'TESTPACE_RESULTS'
|
|
16
|
+
|
|
17
|
+
/** 连跑这么多次都过(代码没改),才算证明时好时坏的测试修好了,从名单上去掉。 */
|
|
18
|
+
export const PROVE_RUNS = 3
|
|
19
|
+
|
|
20
|
+
/** 同一个测试连着这么多轮(每轮改了代码)没过,就提醒 agent 先别接着试、回头找原因。只是提醒,不找用户。 */
|
|
21
|
+
export const STOP_ROUNDS = 3
|
|
22
|
+
|
|
23
|
+
/** 一个测试的结果,文件相对仓库根目录。 */
|
|
24
|
+
export interface TestResult extends TestId {
|
|
25
|
+
status: Ran['status']
|
|
26
|
+
retried?: boolean
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** 给一次运行准备交结果的文件。用完调 dispose。 */
|
|
30
|
+
export function resultsFile(): { path: string; dispose: () => void } {
|
|
31
|
+
const dir = mkdtempSync(join(tmpdir(), 'testpace-results-'))
|
|
32
|
+
return { path: join(dir, 'results.jsonl'), dispose: () => rmSync(dir, { recursive: true, force: true }) }
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** 读交回的结果,路径换成相对仓库根目录;仓库外的文件不算。没交回任何结果时为空。 */
|
|
36
|
+
export function readResults(path: string, root: string): TestResult[] {
|
|
37
|
+
let text: string
|
|
38
|
+
try {
|
|
39
|
+
text = readFileSync(path, 'utf8')
|
|
40
|
+
} catch {
|
|
41
|
+
return []
|
|
42
|
+
}
|
|
43
|
+
const base = realpathSync(root)
|
|
44
|
+
const results: TestResult[] = []
|
|
45
|
+
for (const line of text.split('\n')) {
|
|
46
|
+
if (!line.trim()) continue
|
|
47
|
+
let ran: Ran
|
|
48
|
+
try {
|
|
49
|
+
ran = JSON.parse(line) as Ran
|
|
50
|
+
} catch {
|
|
51
|
+
continue // 写到一半的(进程被杀)
|
|
52
|
+
}
|
|
53
|
+
const file = relative(base, ran.file)
|
|
54
|
+
if (file.startsWith('..')) continue
|
|
55
|
+
results.push({ file, ...(ran.line === undefined ? {} : { line: ran.line }), name: ran.name, status: ran.status, ...(ran.retried ? { retried: true } : {}) })
|
|
56
|
+
}
|
|
57
|
+
return results
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* 这次运行里认得清的结果:一个测试只留一条。同一个文件里同名的测试、Playwright 的 repeatEach 拷贝会共用一个名字,
|
|
62
|
+
* 一次运行里同一个名字既有过的又有没过的,分不清是哪个,不算(不记没过,不比时好时坏,不数轮数)。
|
|
63
|
+
* 名字带 project 的(Vitest、Playwright 有多个 project 时)各算一个。
|
|
64
|
+
*/
|
|
65
|
+
function distinct(results: TestResult[]): TestResult[] {
|
|
66
|
+
const byKey = new Map<string, TestResult>()
|
|
67
|
+
const mixed = new Set<string>()
|
|
68
|
+
for (const test of results) {
|
|
69
|
+
const key = testKey(test)
|
|
70
|
+
const seen = byKey.get(key)
|
|
71
|
+
if (!seen) byKey.set(key, test)
|
|
72
|
+
else if (seen.status !== test.status && (seen.status === 'failed' || test.status === 'failed')) mixed.add(key)
|
|
73
|
+
else if (test.status === 'failed' || (test.status === 'passed' && seen.status === 'skipped')) byKey.set(key, test)
|
|
74
|
+
}
|
|
75
|
+
return [...byKey.values()].filter(test => !mixed.has(testKey(test)))
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** 没过的测试(见 distinct)。 */
|
|
79
|
+
export function failedTests(results: TestResult[]): TestId[] {
|
|
80
|
+
return distinct(results)
|
|
81
|
+
.filter(test => test.status === 'failed')
|
|
82
|
+
.map(test => ({ file: test.file, ...(test.line === undefined ? {} : { line: test.line }), name: test.name }))
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** 说一个测试:文件:行号 「名字」。 */
|
|
86
|
+
export function describeTest(test: TestId): string {
|
|
87
|
+
return `${test.line === undefined ? test.file : `${test.file}:${test.line}`} 「${test.name}」`
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** 给的参数里整个文件给的那些(不带行号)。 */
|
|
91
|
+
export function wholeFiles(args: string[]): string[] {
|
|
92
|
+
return args.filter(arg => !LOCATED.test(arg))
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface ResultsInput {
|
|
96
|
+
/** 这次运行的记录,已经写进 runs.jsonl。 */
|
|
97
|
+
record: PaceRun
|
|
98
|
+
results: TestResult[]
|
|
99
|
+
/** 这次运行之前的记录。 */
|
|
100
|
+
before: PaceRun[]
|
|
101
|
+
/** 整个文件跑的测试文件(相对仓库根目录)。 */
|
|
102
|
+
whole: string[]
|
|
103
|
+
/** 连跑时前面几次通过的测试,按 testKey,值是那次的日志。 */
|
|
104
|
+
passedEarlier?: Map<string, string>
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* 看这次运行的结果:
|
|
109
|
+
* - 时好时坏:同一份代码上以前没过、这次过了;连跑时前面过了、这次没过;框架重试后才过。记进名单,点名。
|
|
110
|
+
* "同一份代码"要两次都是跑的过程中代码没改过的(tree 和 treeAtEnd 一样)。
|
|
111
|
+
* - 名单上的测试不在了:在认出它的工作区里(或那个工作区已经删了)整个跑了它的文件、全部通过,
|
|
112
|
+
* 文件里却没有这个名字(删掉或改了名),从名单上去掉。别的工作区的代码可能还没有这个测试,不算。
|
|
113
|
+
* - 几轮没过:改了代码再跑还没过算一轮,过了清零;到 STOP_ROUNDS 轮提醒 agent 先找原因再改。
|
|
114
|
+
* 返回要说给 agent 的话。
|
|
115
|
+
*/
|
|
116
|
+
export function noteResults(repo: Repo, input: ResultsInput): string[] {
|
|
117
|
+
const { record } = input
|
|
118
|
+
if (input.results.length === 0) return []
|
|
119
|
+
const results = distinct(input.results)
|
|
120
|
+
const notes: string[] = []
|
|
121
|
+
const listed = new Map(flakyTests(repo.store).map(test => [testKey(test), test]))
|
|
122
|
+
const session = currentAgent()?.session
|
|
123
|
+
|
|
124
|
+
// 认出的新的时好时坏测试,和说它的话。名单上已有的、这次已经认出的不再算
|
|
125
|
+
const found: Array<{ test: FlakyTest; note: string }> = []
|
|
126
|
+
const flag = (test: TestResult, how: FlakyTest['how'], failLog: string, passLog: string, note: string): void => {
|
|
127
|
+
const key = testKey(test)
|
|
128
|
+
if (listed.has(key) || found.some(other => testKey(other.test) === key)) return
|
|
129
|
+
const flaky: FlakyTest = {
|
|
130
|
+
file: test.file,
|
|
131
|
+
...(test.line === undefined ? {} : { line: test.line }),
|
|
132
|
+
name: test.name,
|
|
133
|
+
how,
|
|
134
|
+
foundAt: record.startedAt,
|
|
135
|
+
tree: record.tree,
|
|
136
|
+
worktree: record.worktree,
|
|
137
|
+
failLog,
|
|
138
|
+
passLog,
|
|
139
|
+
...(session ? { session } : {}),
|
|
140
|
+
}
|
|
141
|
+
found.push({ test: flaky, note: `时好时坏:${describeTest(test)} ${note}` })
|
|
142
|
+
}
|
|
143
|
+
// 同一份代码上的、跑的过程中代码没改过的,近的在前。这次跑的过程中代码改过就不比
|
|
144
|
+
const stable = record.treeAtEnd === record.tree
|
|
145
|
+
const sameCode = input.before.filter(run => run.tree === record.tree && run.treeAtEnd === run.tree).sort((a, b) => b.startedAt - a.startedAt)
|
|
146
|
+
for (const test of stable ? results : []) {
|
|
147
|
+
if (test.status === 'passed' && test.retried) {
|
|
148
|
+
flag(test, 'retried', record.log, record.log, '框架重试之后才过。')
|
|
149
|
+
} else if (test.status === 'passed') {
|
|
150
|
+
const failedRun = sameCode.find(run => run.failed?.some(other => testKey(other) === testKey(test)))
|
|
151
|
+
if (failedRun) flag(test, 'reran', failedRun.log, record.log, `这次过了,同一份代码 ${when(failedRun.startedAt)} 却没过(那次的日志:${failedRun.log})。`)
|
|
152
|
+
} else if (test.status === 'failed') {
|
|
153
|
+
const passLog = input.passedEarlier?.get(testKey(test))
|
|
154
|
+
if (passLog) flag(test, 'reran', record.log, passLog, `这次没过,代码没改,连跑时前面却过了(过的那次的日志:${passLog})。`)
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
for (const { test } of found) addFlaky(repo.store, test)
|
|
158
|
+
if (found.length > 0) {
|
|
159
|
+
notes.push(
|
|
160
|
+
...found.map(({ note }) => note),
|
|
161
|
+
`不要靠重跑过关:按 testcraft 写测试技能里"测试时好时坏"一节找原因修;和手上的活无关的,告诉用户是哪个测试、在哪次没过、日志在哪。修好后用 testpace files --repeat ${PROVE_RUNS} <文件:行号> 连跑证明,都过了才从时好时坏名单上去掉(名单用 testpace status 看)。`,
|
|
162
|
+
)
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// 名单上的测试不在了。整组被跳过的(node:test 只报组名)里面的测试不算不在
|
|
166
|
+
if (record.result === 'pass') {
|
|
167
|
+
const ranFiles = new Set(input.results.map(test => test.file))
|
|
168
|
+
const names = new Set(input.results.map(testKey))
|
|
169
|
+
const skippedGroups = input.results.filter(test => test.status === 'skipped')
|
|
170
|
+
const inSkipped = (test: FlakyTest): boolean => skippedGroups.some(group => group.file === test.file && test.name.startsWith(`${group.name} > `))
|
|
171
|
+
for (const test of listed.values()) {
|
|
172
|
+
if (test.worktree !== record.worktree && existsSync(test.worktree)) continue
|
|
173
|
+
if (!input.whole.includes(test.file) || !ranFiles.has(test.file) || names.has(testKey(test)) || inSkipped(test)) continue
|
|
174
|
+
removeFlaky(repo.store, test)
|
|
175
|
+
notes.push(`${describeTest(test)} 不在了(删掉或改了名),从时好时坏名单上去掉。`)
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// 几轮没过
|
|
180
|
+
const rounds = readRounds(repo.store, record.worktree)
|
|
181
|
+
let changed = false
|
|
182
|
+
const stuck: string[] = []
|
|
183
|
+
for (const test of results) {
|
|
184
|
+
const key = testKey(test)
|
|
185
|
+
if (test.status === 'passed') {
|
|
186
|
+
if (rounds[key]) {
|
|
187
|
+
delete rounds[key]
|
|
188
|
+
changed = true
|
|
189
|
+
}
|
|
190
|
+
continue
|
|
191
|
+
}
|
|
192
|
+
if (test.status !== 'failed') continue
|
|
193
|
+
const entry = rounds[key] ?? { file: test.file, name: test.name, rounds: [] }
|
|
194
|
+
if (test.line !== undefined) entry.line = test.line
|
|
195
|
+
if (entry.rounds.at(-1)?.tree !== record.tree) {
|
|
196
|
+
entry.rounds.push({ tree: record.tree, log: record.log, at: record.startedAt })
|
|
197
|
+
rounds[key] = entry
|
|
198
|
+
changed = true
|
|
199
|
+
}
|
|
200
|
+
if (entry.rounds.length >= STOP_ROUNDS) {
|
|
201
|
+
const logs = entry.rounds.slice(-STOP_ROUNDS).map(round => round.log)
|
|
202
|
+
stuck.push(`${describeTest(entry)} 已经连着 ${entry.rounds.length} 轮改了代码还没过(最近 ${STOP_ROUNDS} 轮的日志:${logs.join('、')})。`)
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
if (changed) saveRounds(repo.store, record.worktree, rounds)
|
|
206
|
+
if (stuck.length > 0) {
|
|
207
|
+
notes.push(...stuck, '因为用户这次改了需求才不过、留到合并时再改的不用管。其余的先别接着试:回头读失败输出和它测的代码,找到原因再改;不要改测试凑通过。查出来是业务规则本身说不清或要变的,才问用户。')
|
|
208
|
+
}
|
|
209
|
+
return notes
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** 连跑全都过了(代码没改):每次都过了的名单上的测试,从名单上去掉。 */
|
|
213
|
+
export function provenFixed(repo: Repo, runs: TestResult[][]): string[] {
|
|
214
|
+
if (runs.length < PROVE_RUNS) return []
|
|
215
|
+
const notes: string[] = []
|
|
216
|
+
for (const test of flakyTests(repo.store)) {
|
|
217
|
+
const key = testKey(test)
|
|
218
|
+
if (!runs.every(results => results.some(result => testKey(result) === key && result.status === 'passed' && !result.retried))) continue
|
|
219
|
+
removeFlaky(repo.store, test)
|
|
220
|
+
notes.push(`${describeTest(test)} 连跑 ${runs.length} 次都过了,从时好时坏名单上去掉。`)
|
|
221
|
+
}
|
|
222
|
+
return notes
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** 时好时坏名单的说明:会话开始时告诉 agent。名单空时没有。 */
|
|
226
|
+
export function flakyBrief(list: FlakyTest[]): string | undefined {
|
|
227
|
+
if (list.length === 0) return undefined
|
|
228
|
+
const shown = list.slice(0, 5).map(describeTest).join('、')
|
|
229
|
+
const more = list.length > 5 ? ` 等 ${list.length} 个` : ''
|
|
230
|
+
return `时好时坏的测试(同一份代码时过时不过,testpace status 看详情):${shown}${more}。它们没过时不要靠重跑过关,按 testcraft 写测试技能里"测试时好时坏"一节处理。`
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/** testpace status 里的时好时坏名单。 */
|
|
234
|
+
export function flakyStatus(list: FlakyTest[]): string[] {
|
|
235
|
+
if (list.length === 0) return ['时好时坏的测试:没有']
|
|
236
|
+
return [
|
|
237
|
+
`时好时坏的测试(${list.length} 个;修好后用 testpace files --repeat ${PROVE_RUNS} <文件:行号> 连跑证明,都过了才去掉):`,
|
|
238
|
+
...list.flatMap(test => [
|
|
239
|
+
` ${describeTest(test)}:${when(test.foundAt)} ${test.how === 'retried' ? '框架重试之后才过' : '同一份代码先后一次没过、一次过了'}`,
|
|
240
|
+
test.how === 'retried' ? ` 日志:${test.passLog}` : ` 没过那次的日志:${test.failLog}\n 过了那次的日志:${test.passLog}`,
|
|
241
|
+
]),
|
|
242
|
+
]
|
|
243
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// testpace run node-test 的计数报告器:每个跑过或被跳过的测试写一行 {file, line, ancestors, name, status}(见 targets.ts 的 Ran),
|
|
2
|
+
// testpace 跑完按给的文件和行核对。由项目的 node 加载,写成 .mjs,不靠 node 直接运行 TypeScript。node:test 不重试,没有 retried。
|
|
3
|
+
//
|
|
4
|
+
// 外层各级的行和名字:node:test 的 test:start、test:pass、test:fail 都按声明的顺序发,nesting 是层级。
|
|
5
|
+
// 按文件记下每一层最近开始的那一个,一个测试的结果到的时候,比它浅的那几层就是它的外层。
|
|
6
|
+
// 整组被跳过(describe 带 skip)时 node:test 只报这一组,不报组里的测试:把这一组记成一条被跳过的。
|
|
7
|
+
export default async function* reporter(source) {
|
|
8
|
+
/** 每个文件当前各层开始的那一个:行号和名字。 */
|
|
9
|
+
const open = new Map()
|
|
10
|
+
for await (const event of source) {
|
|
11
|
+
const data = event.data
|
|
12
|
+
if (event.type === 'test:start') {
|
|
13
|
+
if (!data.file) continue
|
|
14
|
+
const stack = open.get(data.file) ?? []
|
|
15
|
+
stack.length = data.nesting
|
|
16
|
+
stack.push({ line: data.line, name: data.name })
|
|
17
|
+
open.set(data.file, stack)
|
|
18
|
+
continue
|
|
19
|
+
}
|
|
20
|
+
if (event.type !== 'test:pass' && event.type !== 'test:fail') continue
|
|
21
|
+
const { file, name, nesting, line, details, skip, todo } = data
|
|
22
|
+
if (!file) continue
|
|
23
|
+
// 文件本身没加载起来、或里面一个测试都没有时,node:test 把文件当成一个测试报上来,名字就是交给它的路径。
|
|
24
|
+
// testpace run 交的都是绝对路径,所以名字和 file 一样。它不是测试,不算
|
|
25
|
+
if (nesting === 0 && name === file) continue
|
|
26
|
+
// skip、todo 可以是一段说明,按真假算
|
|
27
|
+
const skipped = Boolean(skip || todo)
|
|
28
|
+
if (details?.type === 'suite' && !skipped) continue
|
|
29
|
+
const status = skipped ? 'skipped' : event.type === 'test:pass' ? 'passed' : 'failed'
|
|
30
|
+
const outer = (open.get(file) ?? []).slice(0, nesting)
|
|
31
|
+
const ancestors = outer.map(level => level.line)
|
|
32
|
+
yield `${JSON.stringify({ file, line, ancestors, name: [...outer.map(level => level.name), name].join(' > '), status })}\n`
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// testpace run node-test:用项目的 node(PATH 上的)以 node:test 跑给定的测试文件,守 testpace 对 files 的约定。
|
|
2
|
+
// node:test 不能按行跑:带行号的整个文件跑(runner 说一句),跑完照样核对给的行上有没有测试。不加 --test-only,留着的 .only 不起作用。
|
|
3
|
+
// 屏幕上照常是 spec 输出;另用插件的计数报告器把每个测试记进报告文件,跑完逐个文件、逐行核对。
|
|
4
|
+
|
|
5
|
+
import { fileURLToPath } from 'node:url'
|
|
6
|
+
import type { Framework } from './runner.ts'
|
|
7
|
+
|
|
8
|
+
const REPORTER = fileURLToPath(new URL('./node-test-reporter.mjs', import.meta.url))
|
|
9
|
+
|
|
10
|
+
export const nodeTest: Framework = {
|
|
11
|
+
usage: 'testpace run node-test [--cwd 目录] [--node-arg 参数]... 文件[:行号[:列号]]...',
|
|
12
|
+
argOption: '--node-arg',
|
|
13
|
+
byLine: false,
|
|
14
|
+
command(targets, args, _cwd, report) {
|
|
15
|
+
return {
|
|
16
|
+
program: 'node',
|
|
17
|
+
args: [
|
|
18
|
+
...args,
|
|
19
|
+
'--test',
|
|
20
|
+
'--test-reporter=spec', '--test-reporter-destination=stdout',
|
|
21
|
+
`--test-reporter=${REPORTER}`, `--test-reporter-destination=${report}`,
|
|
22
|
+
...targets.map(target => target.path),
|
|
23
|
+
],
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
}
|