@sharpee/transcript-tester 0.9.61-beta
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/.turbo/turbo-build.log +4 -0
- package/LICENSE +21 -0
- package/dist/cli.d.ts +11 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +367 -0
- package/dist/cli.js.map +1 -0
- package/dist/condition-evaluator.d.ts +30 -0
- package/dist/condition-evaluator.d.ts.map +1 -0
- package/dist/condition-evaluator.js +314 -0
- package/dist/condition-evaluator.js.map +1 -0
- package/dist/fast-cli.d.ts +13 -0
- package/dist/fast-cli.d.ts.map +1 -0
- package/dist/fast-cli.js +363 -0
- package/dist/fast-cli.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -0
- package/dist/navigator.d.ts +27 -0
- package/dist/navigator.d.ts.map +1 -0
- package/dist/navigator.js +303 -0
- package/dist/navigator.js.map +1 -0
- package/dist/parser.d.ts +19 -0
- package/dist/parser.d.ts.map +1 -0
- package/dist/parser.js +453 -0
- package/dist/parser.js.map +1 -0
- package/dist/reporter.d.ts +41 -0
- package/dist/reporter.d.ts.map +1 -0
- package/dist/reporter.js +386 -0
- package/dist/reporter.js.map +1 -0
- package/dist/runner.d.ts +44 -0
- package/dist/runner.d.ts.map +1 -0
- package/dist/runner.js +977 -0
- package/dist/runner.js.map +1 -0
- package/dist/story-loader.d.ts +31 -0
- package/dist/story-loader.d.ts.map +1 -0
- package/dist/story-loader.js +169 -0
- package/dist/story-loader.js.map +1 -0
- package/dist/types.d.ts +204 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/dist-esm/cli.d.ts +11 -0
- package/dist-esm/cli.d.ts.map +1 -0
- package/dist-esm/cli.js +332 -0
- package/dist-esm/cli.js.map +1 -0
- package/dist-esm/condition-evaluator.d.ts +30 -0
- package/dist-esm/condition-evaluator.d.ts.map +1 -0
- package/dist-esm/condition-evaluator.js +311 -0
- package/dist-esm/condition-evaluator.js.map +1 -0
- package/dist-esm/fast-cli.d.ts +13 -0
- package/dist-esm/fast-cli.d.ts.map +1 -0
- package/dist-esm/fast-cli.js +328 -0
- package/dist-esm/fast-cli.js.map +1 -0
- package/dist-esm/index.d.ts +17 -0
- package/dist-esm/index.d.ts.map +1 -0
- package/dist-esm/index.js +21 -0
- package/dist-esm/index.js.map +1 -0
- package/dist-esm/navigator.d.ts +27 -0
- package/dist-esm/navigator.d.ts.map +1 -0
- package/dist-esm/navigator.js +300 -0
- package/dist-esm/navigator.js.map +1 -0
- package/dist-esm/parser.d.ts +19 -0
- package/dist-esm/parser.d.ts.map +1 -0
- package/dist-esm/parser.js +415 -0
- package/dist-esm/parser.js.map +1 -0
- package/dist-esm/reporter.d.ts +41 -0
- package/dist-esm/reporter.d.ts.map +1 -0
- package/dist-esm/reporter.js +342 -0
- package/dist-esm/reporter.js.map +1 -0
- package/dist-esm/runner.d.ts +44 -0
- package/dist-esm/runner.d.ts.map +1 -0
- package/dist-esm/runner.js +941 -0
- package/dist-esm/runner.js.map +1 -0
- package/dist-esm/story-loader.d.ts +31 -0
- package/dist-esm/story-loader.d.ts.map +1 -0
- package/dist-esm/story-loader.js +131 -0
- package/dist-esm/story-loader.js.map +1 -0
- package/dist-esm/types.d.ts +204 -0
- package/dist-esm/types.d.ts.map +1 -0
- package/dist-esm/types.js +7 -0
- package/dist-esm/types.js.map +1 -0
- package/dist-npm/cli.d.ts +11 -0
- package/dist-npm/cli.d.ts.map +1 -0
- package/dist-npm/cli.js +367 -0
- package/dist-npm/cli.js.map +1 -0
- package/dist-npm/condition-evaluator.d.ts +30 -0
- package/dist-npm/condition-evaluator.d.ts.map +1 -0
- package/dist-npm/condition-evaluator.js +314 -0
- package/dist-npm/condition-evaluator.js.map +1 -0
- package/dist-npm/fast-cli.d.ts +13 -0
- package/dist-npm/fast-cli.d.ts.map +1 -0
- package/dist-npm/fast-cli.js +363 -0
- package/dist-npm/fast-cli.js.map +1 -0
- package/dist-npm/index.d.ts +17 -0
- package/dist-npm/index.d.ts.map +1 -0
- package/dist-npm/index.js +48 -0
- package/dist-npm/index.js.map +1 -0
- package/dist-npm/navigator.d.ts +27 -0
- package/dist-npm/navigator.d.ts.map +1 -0
- package/dist-npm/navigator.js +303 -0
- package/dist-npm/navigator.js.map +1 -0
- package/dist-npm/parser.d.ts +19 -0
- package/dist-npm/parser.d.ts.map +1 -0
- package/dist-npm/parser.js +453 -0
- package/dist-npm/parser.js.map +1 -0
- package/dist-npm/reporter.d.ts +41 -0
- package/dist-npm/reporter.d.ts.map +1 -0
- package/dist-npm/reporter.js +386 -0
- package/dist-npm/reporter.js.map +1 -0
- package/dist-npm/runner.d.ts +44 -0
- package/dist-npm/runner.d.ts.map +1 -0
- package/dist-npm/runner.js +977 -0
- package/dist-npm/runner.js.map +1 -0
- package/dist-npm/story-loader.d.ts +31 -0
- package/dist-npm/story-loader.d.ts.map +1 -0
- package/dist-npm/story-loader.js +169 -0
- package/dist-npm/story-loader.js.map +1 -0
- package/dist-npm/types.d.ts +204 -0
- package/dist-npm/types.d.ts.map +1 -0
- package/dist-npm/types.js +8 -0
- package/dist-npm/types.js.map +1 -0
- package/package.json +49 -0
- package/src/cli.ts +385 -0
- package/src/condition-evaluator.ts +382 -0
- package/src/fast-cli.ts +403 -0
- package/src/index.ts +26 -0
- package/src/navigator.ts +365 -0
- package/src/parser.ts +488 -0
- package/src/reporter.ts +409 -0
- package/src/runner.ts +1152 -0
- package/src/story-loader.ts +168 -0
- package/src/types.ts +244 -0
- package/tsconfig.esm.json +11 -0
- package/tsconfig.esm.tsbuildinfo +1 -0
- package/tsconfig.json +22 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transcript Parser
|
|
3
|
+
*
|
|
4
|
+
* Parses .transcript files into a structured format for testing.
|
|
5
|
+
*/
|
|
6
|
+
import * as fs from 'fs';
|
|
7
|
+
/**
|
|
8
|
+
* Parse a transcript file from disk
|
|
9
|
+
*/
|
|
10
|
+
export function parseTranscriptFile(filePath) {
|
|
11
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
12
|
+
return parseTranscript(content, filePath);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Parse transcript content string
|
|
16
|
+
*/
|
|
17
|
+
export function parseTranscript(content, filePath = '<inline>') {
|
|
18
|
+
const lines = content.split('\n');
|
|
19
|
+
const transcript = {
|
|
20
|
+
filePath,
|
|
21
|
+
header: {},
|
|
22
|
+
commands: [],
|
|
23
|
+
items: [],
|
|
24
|
+
goals: [],
|
|
25
|
+
comments: []
|
|
26
|
+
};
|
|
27
|
+
let inHeader = true;
|
|
28
|
+
let currentCommand = null;
|
|
29
|
+
let lineNumber = 0;
|
|
30
|
+
for (const line of lines) {
|
|
31
|
+
lineNumber++;
|
|
32
|
+
const trimmed = line.trim();
|
|
33
|
+
// Empty lines
|
|
34
|
+
if (trimmed === '') {
|
|
35
|
+
if (currentCommand && currentCommand.expectedOutput.length > 0) {
|
|
36
|
+
// Empty line in output - preserve it
|
|
37
|
+
currentCommand.expectedOutput.push('');
|
|
38
|
+
}
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
// Header separator
|
|
42
|
+
if (trimmed === '---') {
|
|
43
|
+
inHeader = false;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
// Comments - add to both comments array (legacy) and items array (for annotation context)
|
|
47
|
+
if (trimmed.startsWith('#') && !trimmed.startsWith('#[')) {
|
|
48
|
+
const commentText = trimmed.slice(1).trim();
|
|
49
|
+
transcript.comments.push(commentText);
|
|
50
|
+
// Also add as item for annotation processing
|
|
51
|
+
transcript.items.push({
|
|
52
|
+
type: 'comment',
|
|
53
|
+
comment: { lineNumber, text: commentText },
|
|
54
|
+
});
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
// $ directives ($save, $restore) - these are standalone directives
|
|
58
|
+
if (trimmed.startsWith('$')) {
|
|
59
|
+
// Save any pending command first
|
|
60
|
+
if (currentCommand) {
|
|
61
|
+
finalizeCommand(currentCommand);
|
|
62
|
+
transcript.commands.push(currentCommand);
|
|
63
|
+
transcript.items.push({ type: 'command', command: currentCommand });
|
|
64
|
+
currentCommand = null;
|
|
65
|
+
}
|
|
66
|
+
const directive = parseDollarDirective(trimmed, lineNumber);
|
|
67
|
+
if (directive) {
|
|
68
|
+
transcript.items.push({ type: 'directive', directive });
|
|
69
|
+
}
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
// Header lines (key: value)
|
|
73
|
+
if (inHeader && trimmed.includes(':') && !trimmed.startsWith('>')) {
|
|
74
|
+
const colonIndex = trimmed.indexOf(':');
|
|
75
|
+
const key = trimmed.slice(0, colonIndex).trim().toLowerCase();
|
|
76
|
+
const value = trimmed.slice(colonIndex + 1).trim();
|
|
77
|
+
transcript.header[key] = value;
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
// Command input
|
|
81
|
+
if (trimmed.startsWith('>')) {
|
|
82
|
+
// Save previous command
|
|
83
|
+
if (currentCommand) {
|
|
84
|
+
finalizeCommand(currentCommand);
|
|
85
|
+
transcript.commands.push(currentCommand);
|
|
86
|
+
transcript.items.push({ type: 'command', command: currentCommand });
|
|
87
|
+
}
|
|
88
|
+
currentCommand = {
|
|
89
|
+
lineNumber,
|
|
90
|
+
input: trimmed.slice(1).trim(),
|
|
91
|
+
expectedOutput: [],
|
|
92
|
+
assertions: []
|
|
93
|
+
};
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
// Directive or assertion tags (both use [ ])
|
|
97
|
+
if (trimmed.startsWith('[') && trimmed.endsWith(']')) {
|
|
98
|
+
// Try to parse as directive first
|
|
99
|
+
const directive = parseDirective(trimmed, lineNumber);
|
|
100
|
+
if (directive) {
|
|
101
|
+
// Save any pending command first
|
|
102
|
+
if (currentCommand) {
|
|
103
|
+
finalizeCommand(currentCommand);
|
|
104
|
+
transcript.commands.push(currentCommand);
|
|
105
|
+
transcript.items.push({ type: 'command', command: currentCommand });
|
|
106
|
+
currentCommand = null;
|
|
107
|
+
}
|
|
108
|
+
transcript.items.push({ type: 'directive', directive });
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
// Not a directive - try as assertion (must be attached to a command)
|
|
112
|
+
if (currentCommand) {
|
|
113
|
+
const assertion = parseAssertion(trimmed);
|
|
114
|
+
if (assertion) {
|
|
115
|
+
currentCommand.assertions.push(assertion);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
// Expected output lines
|
|
121
|
+
if (currentCommand) {
|
|
122
|
+
currentCommand.expectedOutput.push(line); // Preserve original indentation
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
// Don't forget the last command
|
|
126
|
+
if (currentCommand) {
|
|
127
|
+
finalizeCommand(currentCommand);
|
|
128
|
+
transcript.commands.push(currentCommand);
|
|
129
|
+
transcript.items.push({ type: 'command', command: currentCommand });
|
|
130
|
+
}
|
|
131
|
+
// Parse goal segments from items
|
|
132
|
+
transcript.goals = parseGoals(transcript.items);
|
|
133
|
+
return transcript;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Parse a directive tag like [GOAL: name], [IF: condition], [NAVIGATE TO: "Room"]
|
|
137
|
+
*/
|
|
138
|
+
function parseDirective(tag, lineNumber) {
|
|
139
|
+
const inner = tag.slice(1, -1).trim(); // Remove [ ]
|
|
140
|
+
// [GOAL: name]
|
|
141
|
+
const goalMatch = inner.match(/^GOAL:\s*(.+)$/i);
|
|
142
|
+
if (goalMatch) {
|
|
143
|
+
return { type: 'goal', lineNumber, goalName: goalMatch[1].trim() };
|
|
144
|
+
}
|
|
145
|
+
// [END GOAL]
|
|
146
|
+
if (inner.toUpperCase() === 'END GOAL') {
|
|
147
|
+
return { type: 'end_goal', lineNumber };
|
|
148
|
+
}
|
|
149
|
+
// [REQUIRES: condition]
|
|
150
|
+
const requiresMatch = inner.match(/^REQUIRES:\s*(.+)$/i);
|
|
151
|
+
if (requiresMatch) {
|
|
152
|
+
return { type: 'requires', lineNumber, condition: requiresMatch[1].trim() };
|
|
153
|
+
}
|
|
154
|
+
// [ENSURES: condition]
|
|
155
|
+
const ensuresMatch = inner.match(/^ENSURES:\s*(.+)$/i);
|
|
156
|
+
if (ensuresMatch) {
|
|
157
|
+
return { type: 'ensures', lineNumber, condition: ensuresMatch[1].trim() };
|
|
158
|
+
}
|
|
159
|
+
// [IF: condition]
|
|
160
|
+
const ifMatch = inner.match(/^IF:\s*(.+)$/i);
|
|
161
|
+
if (ifMatch) {
|
|
162
|
+
return { type: 'if', lineNumber, condition: ifMatch[1].trim() };
|
|
163
|
+
}
|
|
164
|
+
// [END IF]
|
|
165
|
+
if (inner.toUpperCase() === 'END IF') {
|
|
166
|
+
return { type: 'end_if', lineNumber };
|
|
167
|
+
}
|
|
168
|
+
// [WHILE: condition]
|
|
169
|
+
const whileMatch = inner.match(/^WHILE:\s*(.+)$/i);
|
|
170
|
+
if (whileMatch) {
|
|
171
|
+
return { type: 'while', lineNumber, condition: whileMatch[1].trim() };
|
|
172
|
+
}
|
|
173
|
+
// [END WHILE]
|
|
174
|
+
if (inner.toUpperCase() === 'END WHILE') {
|
|
175
|
+
return { type: 'end_while', lineNumber };
|
|
176
|
+
}
|
|
177
|
+
// [NAVIGATE TO: "Room Name"]
|
|
178
|
+
const navigateMatch = inner.match(/^NAVIGATE\s+TO:\s*"([^"]+)"$/i);
|
|
179
|
+
if (navigateMatch) {
|
|
180
|
+
return { type: 'navigate', lineNumber, target: navigateMatch[1] };
|
|
181
|
+
}
|
|
182
|
+
// Not a directive
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Parse a $ directive like $save <name>, $restore <name>, or ext-testing commands
|
|
187
|
+
*/
|
|
188
|
+
function parseDollarDirective(line, lineNumber) {
|
|
189
|
+
const trimmed = line.trim();
|
|
190
|
+
// $save <name>
|
|
191
|
+
const saveMatch = trimmed.match(/^\$save\s+(.+)$/i);
|
|
192
|
+
if (saveMatch) {
|
|
193
|
+
return { type: 'save', lineNumber, saveName: saveMatch[1].trim() };
|
|
194
|
+
}
|
|
195
|
+
// $restore <name>
|
|
196
|
+
const restoreMatch = trimmed.match(/^\$restore\s+(.+)$/i);
|
|
197
|
+
if (restoreMatch) {
|
|
198
|
+
return { type: 'restore', lineNumber, saveName: restoreMatch[1].trim() };
|
|
199
|
+
}
|
|
200
|
+
// Any other $ directive is a test command (ext-testing)
|
|
201
|
+
// Valid test commands: $teleport, $take, $move, $kill, $immortal, $mortal, $state, $describe, etc.
|
|
202
|
+
const testCommandMatch = trimmed.match(/^\$(\w+)(.*)$/);
|
|
203
|
+
if (testCommandMatch) {
|
|
204
|
+
return { type: 'test-command', lineNumber, testCommand: trimmed };
|
|
205
|
+
}
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Parse goal segments from items array
|
|
210
|
+
*/
|
|
211
|
+
function parseGoals(items) {
|
|
212
|
+
const goals = [];
|
|
213
|
+
let currentGoal = null;
|
|
214
|
+
let goalStartIndex = -1;
|
|
215
|
+
for (let i = 0; i < items.length; i++) {
|
|
216
|
+
const item = items[i];
|
|
217
|
+
if (item.type !== 'directive')
|
|
218
|
+
continue;
|
|
219
|
+
const directive = item.directive;
|
|
220
|
+
switch (directive.type) {
|
|
221
|
+
case 'goal':
|
|
222
|
+
if (currentGoal) {
|
|
223
|
+
console.warn(`Line ${directive.lineNumber}: Nested goals not allowed. Closing previous goal.`);
|
|
224
|
+
goals.push({
|
|
225
|
+
...currentGoal,
|
|
226
|
+
endIndex: i - 1
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
currentGoal = {
|
|
230
|
+
name: directive.goalName,
|
|
231
|
+
lineNumber: directive.lineNumber,
|
|
232
|
+
requires: [],
|
|
233
|
+
ensures: [],
|
|
234
|
+
startIndex: i + 1
|
|
235
|
+
};
|
|
236
|
+
goalStartIndex = i;
|
|
237
|
+
break;
|
|
238
|
+
case 'requires':
|
|
239
|
+
if (currentGoal && directive.condition) {
|
|
240
|
+
currentGoal.requires.push(directive.condition);
|
|
241
|
+
}
|
|
242
|
+
break;
|
|
243
|
+
case 'ensures':
|
|
244
|
+
if (currentGoal && directive.condition) {
|
|
245
|
+
currentGoal.ensures.push(directive.condition);
|
|
246
|
+
}
|
|
247
|
+
break;
|
|
248
|
+
case 'end_goal':
|
|
249
|
+
if (currentGoal) {
|
|
250
|
+
goals.push({
|
|
251
|
+
...currentGoal,
|
|
252
|
+
endIndex: i
|
|
253
|
+
});
|
|
254
|
+
currentGoal = null;
|
|
255
|
+
}
|
|
256
|
+
break;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
// Handle unclosed goal
|
|
260
|
+
if (currentGoal) {
|
|
261
|
+
console.warn(`Unclosed goal: ${currentGoal.name}`);
|
|
262
|
+
goals.push({
|
|
263
|
+
...currentGoal,
|
|
264
|
+
endIndex: items.length - 1
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
return goals;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Parse an assertion tag like [OK], [OK: contains "foo"], [FAIL: reason]
|
|
271
|
+
*/
|
|
272
|
+
function parseAssertion(tag) {
|
|
273
|
+
const inner = tag.slice(1, -1).trim(); // Remove [ ]
|
|
274
|
+
// [OK] - exact match
|
|
275
|
+
if (inner === 'OK') {
|
|
276
|
+
return { type: 'ok' };
|
|
277
|
+
}
|
|
278
|
+
// [SKIP]
|
|
279
|
+
if (inner === 'SKIP') {
|
|
280
|
+
return { type: 'skip' };
|
|
281
|
+
}
|
|
282
|
+
// [OK: contains "text"]
|
|
283
|
+
const containsMatch = inner.match(/^OK:\s*contains\s+"([^"]+)"$/i);
|
|
284
|
+
if (containsMatch) {
|
|
285
|
+
return { type: 'ok-contains', value: containsMatch[1] };
|
|
286
|
+
}
|
|
287
|
+
// [OK: not contains "text"]
|
|
288
|
+
const notContainsMatch = inner.match(/^OK:\s*not\s+contains\s+"([^"]+)"$/i);
|
|
289
|
+
if (notContainsMatch) {
|
|
290
|
+
return { type: 'ok-not-contains', value: notContainsMatch[1] };
|
|
291
|
+
}
|
|
292
|
+
// [OK: matches /regex/flags]
|
|
293
|
+
const matchesMatch = inner.match(/^OK:\s*matches\s+\/(.+)\/([gimsuy]*)$/i);
|
|
294
|
+
if (matchesMatch) {
|
|
295
|
+
try {
|
|
296
|
+
return {
|
|
297
|
+
type: 'ok-matches',
|
|
298
|
+
pattern: new RegExp(matchesMatch[1], matchesMatch[2])
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
catch (e) {
|
|
302
|
+
console.error(`Invalid regex in assertion: ${tag}`);
|
|
303
|
+
return null;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
// [FAIL: reason]
|
|
307
|
+
const failMatch = inner.match(/^FAIL(?::\s*(.+))?$/i);
|
|
308
|
+
if (failMatch) {
|
|
309
|
+
return { type: 'fail', reason: failMatch[1] || 'Expected failure' };
|
|
310
|
+
}
|
|
311
|
+
// [TODO: note]
|
|
312
|
+
const todoMatch = inner.match(/^TODO(?::\s*(.+))?$/i);
|
|
313
|
+
if (todoMatch) {
|
|
314
|
+
return { type: 'todo', reason: todoMatch[1] || 'Not implemented' };
|
|
315
|
+
}
|
|
316
|
+
// [EVENTS: N] - exact event count
|
|
317
|
+
const eventsMatch = inner.match(/^EVENTS:\s*(\d+)$/i);
|
|
318
|
+
if (eventsMatch) {
|
|
319
|
+
return { type: 'event-count', eventCount: parseInt(eventsMatch[1], 10) };
|
|
320
|
+
}
|
|
321
|
+
// [EVENT: true|false, N?, type="..." key="value"]
|
|
322
|
+
// Format: [EVENT: true, 1, type="if.event.pushed" target="y09"]
|
|
323
|
+
// [EVENT: false, type="if.event.destroyed"]
|
|
324
|
+
const eventAssertMatch = inner.match(/^EVENT:\s*(true|false)\s*,\s*(.+)$/i);
|
|
325
|
+
if (eventAssertMatch) {
|
|
326
|
+
const assertTrue = eventAssertMatch[1].toLowerCase() === 'true';
|
|
327
|
+
const rest = eventAssertMatch[2];
|
|
328
|
+
// Check if there's a position number before the type
|
|
329
|
+
const positionMatch = rest.match(/^(\d+)\s*,\s*(.+)$/);
|
|
330
|
+
let eventPosition;
|
|
331
|
+
let propsStr;
|
|
332
|
+
if (positionMatch) {
|
|
333
|
+
eventPosition = parseInt(positionMatch[1], 10);
|
|
334
|
+
propsStr = positionMatch[2];
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
propsStr = rest;
|
|
338
|
+
}
|
|
339
|
+
// Parse key="value" pairs
|
|
340
|
+
const eventData = {};
|
|
341
|
+
let eventType;
|
|
342
|
+
const propRegex = /(\w+)="([^"]+)"/g;
|
|
343
|
+
let match;
|
|
344
|
+
while ((match = propRegex.exec(propsStr)) !== null) {
|
|
345
|
+
const [, key, value] = match;
|
|
346
|
+
if (key === 'type') {
|
|
347
|
+
eventType = value;
|
|
348
|
+
}
|
|
349
|
+
else {
|
|
350
|
+
eventData[key] = value;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
if (eventType) {
|
|
354
|
+
return {
|
|
355
|
+
type: 'event-assert',
|
|
356
|
+
assertTrue,
|
|
357
|
+
eventPosition,
|
|
358
|
+
eventType,
|
|
359
|
+
eventData: Object.keys(eventData).length > 0 ? eventData : undefined
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
// [STATE: true|false, expression]
|
|
364
|
+
// Format: [STATE: true, egg.location = thief]
|
|
365
|
+
// [STATE: false, player.canSee(egg)]
|
|
366
|
+
const stateAssertMatch = inner.match(/^STATE:\s*(true|false)\s*,\s*(.+)$/i);
|
|
367
|
+
if (stateAssertMatch) {
|
|
368
|
+
const assertTrue = stateAssertMatch[1].toLowerCase() === 'true';
|
|
369
|
+
const expression = stateAssertMatch[2].trim();
|
|
370
|
+
return {
|
|
371
|
+
type: 'state-assert',
|
|
372
|
+
assertTrue,
|
|
373
|
+
stateExpression: expression
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
console.warn(`Unknown assertion format: ${tag}`);
|
|
377
|
+
return null;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Clean up a command before adding to transcript
|
|
381
|
+
*/
|
|
382
|
+
function finalizeCommand(command) {
|
|
383
|
+
// Trim trailing empty lines from expected output
|
|
384
|
+
while (command.expectedOutput.length > 0 &&
|
|
385
|
+
command.expectedOutput[command.expectedOutput.length - 1].trim() === '') {
|
|
386
|
+
command.expectedOutput.pop();
|
|
387
|
+
}
|
|
388
|
+
// If no explicit assertion and we have expected output, default to [OK]
|
|
389
|
+
if (command.assertions.length === 0 && command.expectedOutput.length > 0) {
|
|
390
|
+
command.assertions.push({ type: 'ok' });
|
|
391
|
+
}
|
|
392
|
+
// If no assertion at all, default to [SKIP]
|
|
393
|
+
if (command.assertions.length === 0) {
|
|
394
|
+
command.assertions.push({ type: 'skip' });
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Validate a transcript for common issues
|
|
399
|
+
*/
|
|
400
|
+
export function validateTranscript(transcript) {
|
|
401
|
+
const errors = [];
|
|
402
|
+
if (transcript.commands.length === 0) {
|
|
403
|
+
errors.push('Transcript has no commands');
|
|
404
|
+
}
|
|
405
|
+
if (!transcript.header.story && !transcript.header.title) {
|
|
406
|
+
errors.push('Transcript should have a title or story in header');
|
|
407
|
+
}
|
|
408
|
+
for (const cmd of transcript.commands) {
|
|
409
|
+
if (!cmd.input) {
|
|
410
|
+
errors.push(`Line ${cmd.lineNumber}: Empty command`);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
return errors;
|
|
414
|
+
}
|
|
415
|
+
//# sourceMappingURL=parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,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/B,CAAC;IAED,wEAAwE;IACxE,IAAI,OAAO,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzE,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1C,CAAC;IAED,4CAA4C;IAC5C,IAAI,OAAO,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACpC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;IAC5C,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,UAAsB;IACvD,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,IAAI,UAAU,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrC,MAAM,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;IAC5C,CAAC;IAED,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACzD,MAAM,CAAC,IAAI,CAAC,mDAAmD,CAAC,CAAC;IACnE,CAAC;IAED,KAAK,MAAM,GAAG,IAAI,UAAU,CAAC,QAAQ,EAAE,CAAC;QACtC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,IAAI,CAAC,QAAQ,GAAG,CAAC,UAAU,iBAAiB,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transcript Test Reporter
|
|
3
|
+
*
|
|
4
|
+
* Formats and displays test results with colors and diffs.
|
|
5
|
+
*/
|
|
6
|
+
import { TranscriptResult, TestRunResult } from './types';
|
|
7
|
+
/**
|
|
8
|
+
* Report options
|
|
9
|
+
*/
|
|
10
|
+
export interface ReporterOptions {
|
|
11
|
+
verbose?: boolean;
|
|
12
|
+
showDiff?: boolean;
|
|
13
|
+
color?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Report results of running a single transcript
|
|
17
|
+
*/
|
|
18
|
+
export declare function reportTranscript(result: TranscriptResult, options?: ReporterOptions): void;
|
|
19
|
+
/**
|
|
20
|
+
* Report results of running multiple transcripts
|
|
21
|
+
* Note: Individual transcripts should already be reported as they run.
|
|
22
|
+
* This function only shows the aggregate summary.
|
|
23
|
+
*/
|
|
24
|
+
export declare function reportTestRun(result: TestRunResult, options?: ReporterOptions): void;
|
|
25
|
+
/**
|
|
26
|
+
* Get exit code based on results
|
|
27
|
+
*/
|
|
28
|
+
export declare function getExitCode(result: TestRunResult): number;
|
|
29
|
+
/**
|
|
30
|
+
* Generate a timestamp string for filenames
|
|
31
|
+
*/
|
|
32
|
+
export declare function generateTimestamp(): string;
|
|
33
|
+
/**
|
|
34
|
+
* Write test results to a JSON file
|
|
35
|
+
*/
|
|
36
|
+
export declare function writeResultsToJson(result: TestRunResult, outputDir: string, timestamp: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Write a human-readable report to a text file
|
|
39
|
+
*/
|
|
40
|
+
export declare function writeReportToFile(result: TestRunResult, outputDir: string, timestamp: string): string;
|
|
41
|
+
//# sourceMappingURL=reporter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reporter.d.ts","sourceRoot":"","sources":["../src/reporter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EACL,gBAAgB,EAChB,aAAa,EAGd,MAAM,SAAS,CAAC;AAKjB;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,gBAAgB,EACxB,OAAO,GAAE,eAAoB,GAC5B,IAAI,CAmBN;AAiJD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,GAAE,eAAoB,GAAG,IAAI,CAmCxF;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAKzD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAS1C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,aAAa,EACrB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,MAAM,CAmBR;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,aAAa,EACrB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,MAAM,CA0ER"}
|