@ihyeon/error-to-test 0.2.1 → 0.2.2
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/README.ko.md +19 -0
- package/README.md +21 -0
- package/dist/cli.js +49 -6
- package/package.json +1 -1
package/README.ko.md
CHANGED
|
@@ -102,6 +102,25 @@ TC 생성 대상에서 제외된 묶음도 모두 비교합니다. 한쪽에 여
|
|
|
102
102
|
|
|
103
103
|
양쪽 번들을 검증한 뒤 읽으며 원래 산출물·TC 상태·검토 조건·연결 결과는 수정하지 않습니다. 기본 출력은 Markdown이고, `--format json`은 `error-to-test/comparison-1`을 반환합니다. `--out`은 양쪽 번들의 `results` 폴더 밖에 있는 새 파일만 허용합니다. API는 `compareBundles()`와 `renderComparison()`입니다.
|
|
104
104
|
|
|
105
|
+
CI에서는 `--max-new N`으로 **현재에만 있는 오류 서명의 허용 개수**를 정할 수 있습니다.
|
|
106
|
+
|
|
107
|
+
```sh
|
|
108
|
+
error-to-test compare ./before ./current --max-new 0
|
|
109
|
+
error-to-test compare ./before ./current --max-new 2 --format json --out ./comparison.json
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
0~10,000의 십진 정수를 받습니다. TC 생성에서 제외된 묶음을 포함한 전체 비교 결과의 `only-current` 서명 수를 기준으로 합니다. 릴리스만 다른 동일 비교 키는 한 번 세며, 로그 건수나 건수 증가는 한도에 포함하지 않습니다.
|
|
113
|
+
|
|
114
|
+
| 종료 코드 | 의미 |
|
|
115
|
+
| --- | --- |
|
|
116
|
+
| `0` | 비교 성공, 한도 이내 또는 한도 옵션 미사용 |
|
|
117
|
+
| `1` | 잘못된 옵션·입력 형식 불일치·번들 변조·출력 오류 |
|
|
118
|
+
| `2` | 비교 성공, 현재에만 있는 서명 수가 한도 초과 |
|
|
119
|
+
|
|
120
|
+
한도를 넘겨도 전체 비교 보고서를 출력하거나 저장하므로 CI에서 검토 자료로 남길 수 있습니다. 숫자로 된 통과·실패 요약은 stderr에 쓰고, JSON stdout은 기존 `error-to-test/comparison-1` 형식을 유지합니다. 출력 오류는 코드 1로 처리하고 기존 파일을 보존합니다. 옵션을 생략하면 기존 비교 동작을 유지하며, `--max-new`는 `compare`에서만 사용할 수 있습니다.
|
|
121
|
+
|
|
122
|
+
프로젝트·환경·기간·수집 범위를 맞춘 분석을 기준으로 사용하세요. 부분 내보내기와 수집 범위 경고는 보고서에 남습니다. 이 값은 제공한 이전 분석에 없던 서명 수이며 실제 유입 시점이나 회귀 원인을 확정하지 않습니다. TC 실행·검토 상태는 변경하지 않습니다. API에서는 `comparison.counts['only-current']`로 같은 기준을 적용할 수 있습니다.
|
|
123
|
+
|
|
105
124
|
`analyze --baseline`을 쓰면 **이전 분석에서 관측되지 않은 서명만 골라 TC를 생성**할 수 있습니다.
|
|
106
125
|
|
|
107
126
|
```sh
|
package/README.md
CHANGED
|
@@ -131,6 +131,27 @@ All source groups participate, including groups excluded from TC generation by `
|
|
|
131
131
|
|
|
132
132
|
Both bundles must pass consistency verification. The command reads their verified snapshots without editing artifacts, TC states, review gates, or linked results. Markdown is the default; `--format json` returns `error-to-test/comparison-1`. `--out` requires a new file outside either bundle's `results` directory. The API equivalents are `await compareBundles(baselineDirectory, currentDirectory)` and `renderComparison(comparison)`.
|
|
133
133
|
|
|
134
|
+
### Limit newly observed signatures in CI
|
|
135
|
+
|
|
136
|
+
Set `--max-new N` to fail a CI step when the supplied current analysis has more than N `only-current` signatures:
|
|
137
|
+
|
|
138
|
+
```sh
|
|
139
|
+
error-to-test compare ./before ./current --max-new 0
|
|
140
|
+
error-to-test compare ./before ./current --max-new 2 --format json --out ./comparison.json
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
The limit accepts decimal integers from 0 to 10,000. It counts distinct comparison signatures across all retained groups, including groups excluded from TC generation. Release groups sharing the same comparison key count once. Record counts and count increases do not affect this limit.
|
|
144
|
+
|
|
145
|
+
| Exit code | Result |
|
|
146
|
+
| --- | --- |
|
|
147
|
+
| `0` | Comparison succeeded and the limit was met, or no limit was requested |
|
|
148
|
+
| `1` | Invalid options, incompatible/stale inputs, or an output error |
|
|
149
|
+
| `2` | Comparison succeeded and the `only-current` count exceeded the limit |
|
|
150
|
+
|
|
151
|
+
On limit failure the full report is still printed or saved, so CI can retain it for review. A numeric pass/fail summary goes to stderr; JSON stdout remains the unchanged `error-to-test/comparison-1` object. Output errors take precedence and preserve existing files. Without `--max-new`, existing comparison behavior is unchanged. The option is available only on `compare`.
|
|
152
|
+
|
|
153
|
+
Choose snapshots with the intended project, environment, period, and collection scope. Partial-export and coverage warnings remain in the report. This limit describes signatures absent from the supplied baseline; it does not establish when an error was introduced, execute TCs, or change their review state. API callers can apply their own threshold to `comparison.counts['only-current']`.
|
|
154
|
+
|
|
134
155
|
### Generate TCs for signatures absent from a baseline
|
|
135
156
|
|
|
136
157
|
Pass a verified analysis bundle to `analyze --baseline` to focus TC generation on current signatures that were not observed in that baseline:
|
package/dist/cli.js
CHANGED
|
@@ -23,7 +23,7 @@ const help = `Error to Test — local error analysis and regression TC drafts
|
|
|
23
23
|
error-to-test init-profile new-directory --profile existing.json --out extended.json
|
|
24
24
|
error-to-test link-run new-directory --report path/to/qa-report.json
|
|
25
25
|
error-to-test results new-directory [--format text|json] [--out summary.md]
|
|
26
|
-
error-to-test compare BASELINE CURRENT [--format text|json] [--out comparison.md]
|
|
26
|
+
error-to-test compare BASELINE CURRENT [--format text|json] [--out comparison.md] [--max-new N]
|
|
27
27
|
|
|
28
28
|
Options:
|
|
29
29
|
--input FILE SDK export, manual JSON, JSONL, or plain error text; repeat for same-format files in order (analyze: sole - for stdin)
|
|
@@ -50,6 +50,7 @@ Options:
|
|
|
50
50
|
--out FILE New init-profile JSON file; existing files are never overwritten
|
|
51
51
|
--out FILE New results summary file; existing files are never overwritten
|
|
52
52
|
--out FILE New comparison file; existing files are never overwritten
|
|
53
|
+
--max-new N Compare only: allow 0..10000 only-current signatures; exit 0 within limit, 2 over limit, 1 on error
|
|
53
54
|
--reviewed Acknowledge review; unresolved questions still block cases
|
|
54
55
|
--report FILE Normalized Flow QA report (link-run only)
|
|
55
56
|
--version, -v Print the package version
|
|
@@ -74,6 +75,23 @@ async function stdinText() {
|
|
|
74
75
|
throw new Error('Input must be valid UTF-8.');
|
|
75
76
|
return input.toString('utf8');
|
|
76
77
|
}
|
|
78
|
+
async function writeGateOutput(content) {
|
|
79
|
+
await new Promise((resolveWrite, rejectWrite) => {
|
|
80
|
+
const onError = (error) => { process.stdout.off('error', onError); rejectWrite(error); };
|
|
81
|
+
process.stdout.on('error', onError);
|
|
82
|
+
process.stdout.write(content, (error) => {
|
|
83
|
+
if (error) {
|
|
84
|
+
rejectWrite(error);
|
|
85
|
+
// Writable can emit 'error' after invoking the failed write callback.
|
|
86
|
+
setImmediate(() => process.stdout.off('error', onError));
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
process.stdout.off('error', onError);
|
|
90
|
+
resolveWrite();
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
}
|
|
77
95
|
async function inputContents(paths, allowStdin) {
|
|
78
96
|
if (paths.length < 1 || paths.length > 50)
|
|
79
97
|
throw new Error('Provide between 1 and 50 --input files.');
|
|
@@ -124,7 +142,7 @@ export async function main(args = process.argv.slice(2)) {
|
|
|
124
142
|
help: { type: 'boolean', short: 'h' }, version: { type: 'boolean', short: 'v' }, input: { type: 'string', multiple: true }, error: { type: 'string' }, report: { type: 'string' },
|
|
125
143
|
format: { type: 'string' }, profile: { type: 'string' }, baseline: { type: 'string' }, project: { type: 'string' }, environment: { type: 'string' },
|
|
126
144
|
release: { type: 'string' }, page: { type: 'string' }, type: { type: 'string' }, runtime: { type: 'string' }, from: { type: 'string' }, to: { type: 'string' },
|
|
127
|
-
top: { type: 'string' }, 'min-count': { type: 'string' }, out: { type: 'string' }, reviewed: { type: 'boolean' },
|
|
145
|
+
top: { type: 'string' }, 'min-count': { type: 'string' }, 'max-new': { type: 'string' }, out: { type: 'string' }, reviewed: { type: 'boolean' },
|
|
128
146
|
reproduce: { type: 'string', multiple: true }, precondition: { type: 'string', multiple: true },
|
|
129
147
|
expected: { type: 'string' }, 'expected-source': { type: 'string' },
|
|
130
148
|
} });
|
|
@@ -229,19 +247,37 @@ export async function main(args = process.argv.slice(2)) {
|
|
|
229
247
|
if (command === 'compare') {
|
|
230
248
|
if (positionals.length !== 3 || !positionals[1] || !positionals[2])
|
|
231
249
|
throw new Error('compare requires BASELINE and CURRENT bundle directories.');
|
|
232
|
-
if (Object.keys(values).some(key => !['format', 'out', 'help'].includes(key)))
|
|
233
|
-
throw new Error('Unsupported option for compare. Use only --format text|json and --
|
|
250
|
+
if (Object.keys(values).some(key => !['format', 'out', 'max-new', 'help'].includes(key)))
|
|
251
|
+
throw new Error('Unsupported option for compare. Use only --format text|json, --out FILE, and --max-new N.');
|
|
234
252
|
const format = values.format ?? 'text';
|
|
235
253
|
if (format !== 'text' && format !== 'json')
|
|
236
254
|
throw new Error('compare --format must be text or json.');
|
|
255
|
+
const maxNewRaw = values['max-new'];
|
|
256
|
+
if (maxNewRaw !== undefined && (!/^[0-9]+$/.test(maxNewRaw) || Number(maxNewRaw) > 10000)) {
|
|
257
|
+
throw new Error('compare --max-new must be a decimal integer between 0 and 10000.');
|
|
258
|
+
}
|
|
259
|
+
const maxNew = maxNewRaw === undefined ? undefined : Number(maxNewRaw);
|
|
237
260
|
const baseline = resolve(positionals[1]);
|
|
238
261
|
const current = resolve(positionals[2]);
|
|
239
262
|
const comparison = await compareBundles(baseline, current);
|
|
240
263
|
const content = format === 'json' ? jsonText(comparison) : renderComparison(comparison);
|
|
241
264
|
if (Buffer.byteLength(content) > 64 * 1024 * 1024)
|
|
242
265
|
throw new Error('The comparison exceeds 64 MiB. Narrow the bundles before requesting output.');
|
|
266
|
+
const finishGate = () => {
|
|
267
|
+
if (maxNew === undefined)
|
|
268
|
+
return;
|
|
269
|
+
const count = comparison.counts['only-current'];
|
|
270
|
+
const passed = count <= maxNew;
|
|
271
|
+
process.stderr.write(`Comparison gate ${passed ? 'passed' : 'failed'}: ${count} only-current signatures ${passed ? `(maximum ${maxNew}).` : `exceed maximum ${maxNew}.`}\n`);
|
|
272
|
+
if (!passed)
|
|
273
|
+
process.exitCode = 2;
|
|
274
|
+
};
|
|
243
275
|
if (values.out === undefined) {
|
|
244
|
-
|
|
276
|
+
if (maxNew === undefined)
|
|
277
|
+
process.stdout.write(content);
|
|
278
|
+
else
|
|
279
|
+
await writeGateOutput(content);
|
|
280
|
+
finishGate();
|
|
245
281
|
return;
|
|
246
282
|
}
|
|
247
283
|
const out = resolve(values.out);
|
|
@@ -260,7 +296,12 @@ export async function main(args = process.argv.slice(2)) {
|
|
|
260
296
|
throw new Error('The output file already exists. Choose a new --out FILE path.');
|
|
261
297
|
throw error;
|
|
262
298
|
}
|
|
263
|
-
|
|
299
|
+
const written = `Comparison written: ${out}\n`;
|
|
300
|
+
if (maxNew === undefined)
|
|
301
|
+
process.stdout.write(written);
|
|
302
|
+
else
|
|
303
|
+
await writeGateOutput(written);
|
|
304
|
+
finishGate();
|
|
264
305
|
return;
|
|
265
306
|
}
|
|
266
307
|
if (command === 'verify') {
|
|
@@ -279,6 +320,8 @@ export async function main(args = process.argv.slice(2)) {
|
|
|
279
320
|
throw new Error('Use analyze, init-profile, verify, link-run, results, or compare. See --help.');
|
|
280
321
|
if (values.report)
|
|
281
322
|
throw new Error('--report applies to link-run only.');
|
|
323
|
+
if (values['max-new'] !== undefined)
|
|
324
|
+
throw new Error('--max-new applies to compare only.');
|
|
282
325
|
if (values.baseline !== undefined && values.baseline.trim() === '')
|
|
283
326
|
throw new Error('--baseline requires a bundle directory.');
|
|
284
327
|
if ((values.input === undefined) === (values.error === undefined))
|
package/package.json
CHANGED