@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
package/dist/parser.js
ADDED
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Transcript Parser
|
|
4
|
+
*
|
|
5
|
+
* Parses .transcript files into a structured format for testing.
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
+
var ownKeys = function(o) {
|
|
25
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
+
var ar = [];
|
|
27
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
+
return ar;
|
|
29
|
+
};
|
|
30
|
+
return ownKeys(o);
|
|
31
|
+
};
|
|
32
|
+
return function (mod) {
|
|
33
|
+
if (mod && mod.__esModule) return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
+
__setModuleDefault(result, mod);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
})();
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.parseTranscriptFile = parseTranscriptFile;
|
|
42
|
+
exports.parseTranscript = parseTranscript;
|
|
43
|
+
exports.validateTranscript = validateTranscript;
|
|
44
|
+
const fs = __importStar(require("fs"));
|
|
45
|
+
/**
|
|
46
|
+
* Parse a transcript file from disk
|
|
47
|
+
*/
|
|
48
|
+
function parseTranscriptFile(filePath) {
|
|
49
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
50
|
+
return parseTranscript(content, filePath);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Parse transcript content string
|
|
54
|
+
*/
|
|
55
|
+
function parseTranscript(content, filePath = '<inline>') {
|
|
56
|
+
const lines = content.split('\n');
|
|
57
|
+
const transcript = {
|
|
58
|
+
filePath,
|
|
59
|
+
header: {},
|
|
60
|
+
commands: [],
|
|
61
|
+
items: [],
|
|
62
|
+
goals: [],
|
|
63
|
+
comments: []
|
|
64
|
+
};
|
|
65
|
+
let inHeader = true;
|
|
66
|
+
let currentCommand = null;
|
|
67
|
+
let lineNumber = 0;
|
|
68
|
+
for (const line of lines) {
|
|
69
|
+
lineNumber++;
|
|
70
|
+
const trimmed = line.trim();
|
|
71
|
+
// Empty lines
|
|
72
|
+
if (trimmed === '') {
|
|
73
|
+
if (currentCommand && currentCommand.expectedOutput.length > 0) {
|
|
74
|
+
// Empty line in output - preserve it
|
|
75
|
+
currentCommand.expectedOutput.push('');
|
|
76
|
+
}
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
// Header separator
|
|
80
|
+
if (trimmed === '---') {
|
|
81
|
+
inHeader = false;
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
// Comments - add to both comments array (legacy) and items array (for annotation context)
|
|
85
|
+
if (trimmed.startsWith('#') && !trimmed.startsWith('#[')) {
|
|
86
|
+
const commentText = trimmed.slice(1).trim();
|
|
87
|
+
transcript.comments.push(commentText);
|
|
88
|
+
// Also add as item for annotation processing
|
|
89
|
+
transcript.items.push({
|
|
90
|
+
type: 'comment',
|
|
91
|
+
comment: { lineNumber, text: commentText },
|
|
92
|
+
});
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
// $ directives ($save, $restore) - these are standalone directives
|
|
96
|
+
if (trimmed.startsWith('$')) {
|
|
97
|
+
// Save any pending command first
|
|
98
|
+
if (currentCommand) {
|
|
99
|
+
finalizeCommand(currentCommand);
|
|
100
|
+
transcript.commands.push(currentCommand);
|
|
101
|
+
transcript.items.push({ type: 'command', command: currentCommand });
|
|
102
|
+
currentCommand = null;
|
|
103
|
+
}
|
|
104
|
+
const directive = parseDollarDirective(trimmed, lineNumber);
|
|
105
|
+
if (directive) {
|
|
106
|
+
transcript.items.push({ type: 'directive', directive });
|
|
107
|
+
}
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
// Header lines (key: value)
|
|
111
|
+
if (inHeader && trimmed.includes(':') && !trimmed.startsWith('>')) {
|
|
112
|
+
const colonIndex = trimmed.indexOf(':');
|
|
113
|
+
const key = trimmed.slice(0, colonIndex).trim().toLowerCase();
|
|
114
|
+
const value = trimmed.slice(colonIndex + 1).trim();
|
|
115
|
+
transcript.header[key] = value;
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
// Command input
|
|
119
|
+
if (trimmed.startsWith('>')) {
|
|
120
|
+
// Save previous command
|
|
121
|
+
if (currentCommand) {
|
|
122
|
+
finalizeCommand(currentCommand);
|
|
123
|
+
transcript.commands.push(currentCommand);
|
|
124
|
+
transcript.items.push({ type: 'command', command: currentCommand });
|
|
125
|
+
}
|
|
126
|
+
currentCommand = {
|
|
127
|
+
lineNumber,
|
|
128
|
+
input: trimmed.slice(1).trim(),
|
|
129
|
+
expectedOutput: [],
|
|
130
|
+
assertions: []
|
|
131
|
+
};
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
// Directive or assertion tags (both use [ ])
|
|
135
|
+
if (trimmed.startsWith('[') && trimmed.endsWith(']')) {
|
|
136
|
+
// Try to parse as directive first
|
|
137
|
+
const directive = parseDirective(trimmed, lineNumber);
|
|
138
|
+
if (directive) {
|
|
139
|
+
// Save any pending command first
|
|
140
|
+
if (currentCommand) {
|
|
141
|
+
finalizeCommand(currentCommand);
|
|
142
|
+
transcript.commands.push(currentCommand);
|
|
143
|
+
transcript.items.push({ type: 'command', command: currentCommand });
|
|
144
|
+
currentCommand = null;
|
|
145
|
+
}
|
|
146
|
+
transcript.items.push({ type: 'directive', directive });
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
// Not a directive - try as assertion (must be attached to a command)
|
|
150
|
+
if (currentCommand) {
|
|
151
|
+
const assertion = parseAssertion(trimmed);
|
|
152
|
+
if (assertion) {
|
|
153
|
+
currentCommand.assertions.push(assertion);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
// Expected output lines
|
|
159
|
+
if (currentCommand) {
|
|
160
|
+
currentCommand.expectedOutput.push(line); // Preserve original indentation
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
// Don't forget the last command
|
|
164
|
+
if (currentCommand) {
|
|
165
|
+
finalizeCommand(currentCommand);
|
|
166
|
+
transcript.commands.push(currentCommand);
|
|
167
|
+
transcript.items.push({ type: 'command', command: currentCommand });
|
|
168
|
+
}
|
|
169
|
+
// Parse goal segments from items
|
|
170
|
+
transcript.goals = parseGoals(transcript.items);
|
|
171
|
+
return transcript;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Parse a directive tag like [GOAL: name], [IF: condition], [NAVIGATE TO: "Room"]
|
|
175
|
+
*/
|
|
176
|
+
function parseDirective(tag, lineNumber) {
|
|
177
|
+
const inner = tag.slice(1, -1).trim(); // Remove [ ]
|
|
178
|
+
// [GOAL: name]
|
|
179
|
+
const goalMatch = inner.match(/^GOAL:\s*(.+)$/i);
|
|
180
|
+
if (goalMatch) {
|
|
181
|
+
return { type: 'goal', lineNumber, goalName: goalMatch[1].trim() };
|
|
182
|
+
}
|
|
183
|
+
// [END GOAL]
|
|
184
|
+
if (inner.toUpperCase() === 'END GOAL') {
|
|
185
|
+
return { type: 'end_goal', lineNumber };
|
|
186
|
+
}
|
|
187
|
+
// [REQUIRES: condition]
|
|
188
|
+
const requiresMatch = inner.match(/^REQUIRES:\s*(.+)$/i);
|
|
189
|
+
if (requiresMatch) {
|
|
190
|
+
return { type: 'requires', lineNumber, condition: requiresMatch[1].trim() };
|
|
191
|
+
}
|
|
192
|
+
// [ENSURES: condition]
|
|
193
|
+
const ensuresMatch = inner.match(/^ENSURES:\s*(.+)$/i);
|
|
194
|
+
if (ensuresMatch) {
|
|
195
|
+
return { type: 'ensures', lineNumber, condition: ensuresMatch[1].trim() };
|
|
196
|
+
}
|
|
197
|
+
// [IF: condition]
|
|
198
|
+
const ifMatch = inner.match(/^IF:\s*(.+)$/i);
|
|
199
|
+
if (ifMatch) {
|
|
200
|
+
return { type: 'if', lineNumber, condition: ifMatch[1].trim() };
|
|
201
|
+
}
|
|
202
|
+
// [END IF]
|
|
203
|
+
if (inner.toUpperCase() === 'END IF') {
|
|
204
|
+
return { type: 'end_if', lineNumber };
|
|
205
|
+
}
|
|
206
|
+
// [WHILE: condition]
|
|
207
|
+
const whileMatch = inner.match(/^WHILE:\s*(.+)$/i);
|
|
208
|
+
if (whileMatch) {
|
|
209
|
+
return { type: 'while', lineNumber, condition: whileMatch[1].trim() };
|
|
210
|
+
}
|
|
211
|
+
// [END WHILE]
|
|
212
|
+
if (inner.toUpperCase() === 'END WHILE') {
|
|
213
|
+
return { type: 'end_while', lineNumber };
|
|
214
|
+
}
|
|
215
|
+
// [NAVIGATE TO: "Room Name"]
|
|
216
|
+
const navigateMatch = inner.match(/^NAVIGATE\s+TO:\s*"([^"]+)"$/i);
|
|
217
|
+
if (navigateMatch) {
|
|
218
|
+
return { type: 'navigate', lineNumber, target: navigateMatch[1] };
|
|
219
|
+
}
|
|
220
|
+
// Not a directive
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Parse a $ directive like $save <name>, $restore <name>, or ext-testing commands
|
|
225
|
+
*/
|
|
226
|
+
function parseDollarDirective(line, lineNumber) {
|
|
227
|
+
const trimmed = line.trim();
|
|
228
|
+
// $save <name>
|
|
229
|
+
const saveMatch = trimmed.match(/^\$save\s+(.+)$/i);
|
|
230
|
+
if (saveMatch) {
|
|
231
|
+
return { type: 'save', lineNumber, saveName: saveMatch[1].trim() };
|
|
232
|
+
}
|
|
233
|
+
// $restore <name>
|
|
234
|
+
const restoreMatch = trimmed.match(/^\$restore\s+(.+)$/i);
|
|
235
|
+
if (restoreMatch) {
|
|
236
|
+
return { type: 'restore', lineNumber, saveName: restoreMatch[1].trim() };
|
|
237
|
+
}
|
|
238
|
+
// Any other $ directive is a test command (ext-testing)
|
|
239
|
+
// Valid test commands: $teleport, $take, $move, $kill, $immortal, $mortal, $state, $describe, etc.
|
|
240
|
+
const testCommandMatch = trimmed.match(/^\$(\w+)(.*)$/);
|
|
241
|
+
if (testCommandMatch) {
|
|
242
|
+
return { type: 'test-command', lineNumber, testCommand: trimmed };
|
|
243
|
+
}
|
|
244
|
+
return null;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Parse goal segments from items array
|
|
248
|
+
*/
|
|
249
|
+
function parseGoals(items) {
|
|
250
|
+
const goals = [];
|
|
251
|
+
let currentGoal = null;
|
|
252
|
+
let goalStartIndex = -1;
|
|
253
|
+
for (let i = 0; i < items.length; i++) {
|
|
254
|
+
const item = items[i];
|
|
255
|
+
if (item.type !== 'directive')
|
|
256
|
+
continue;
|
|
257
|
+
const directive = item.directive;
|
|
258
|
+
switch (directive.type) {
|
|
259
|
+
case 'goal':
|
|
260
|
+
if (currentGoal) {
|
|
261
|
+
console.warn(`Line ${directive.lineNumber}: Nested goals not allowed. Closing previous goal.`);
|
|
262
|
+
goals.push({
|
|
263
|
+
...currentGoal,
|
|
264
|
+
endIndex: i - 1
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
currentGoal = {
|
|
268
|
+
name: directive.goalName,
|
|
269
|
+
lineNumber: directive.lineNumber,
|
|
270
|
+
requires: [],
|
|
271
|
+
ensures: [],
|
|
272
|
+
startIndex: i + 1
|
|
273
|
+
};
|
|
274
|
+
goalStartIndex = i;
|
|
275
|
+
break;
|
|
276
|
+
case 'requires':
|
|
277
|
+
if (currentGoal && directive.condition) {
|
|
278
|
+
currentGoal.requires.push(directive.condition);
|
|
279
|
+
}
|
|
280
|
+
break;
|
|
281
|
+
case 'ensures':
|
|
282
|
+
if (currentGoal && directive.condition) {
|
|
283
|
+
currentGoal.ensures.push(directive.condition);
|
|
284
|
+
}
|
|
285
|
+
break;
|
|
286
|
+
case 'end_goal':
|
|
287
|
+
if (currentGoal) {
|
|
288
|
+
goals.push({
|
|
289
|
+
...currentGoal,
|
|
290
|
+
endIndex: i
|
|
291
|
+
});
|
|
292
|
+
currentGoal = null;
|
|
293
|
+
}
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
// Handle unclosed goal
|
|
298
|
+
if (currentGoal) {
|
|
299
|
+
console.warn(`Unclosed goal: ${currentGoal.name}`);
|
|
300
|
+
goals.push({
|
|
301
|
+
...currentGoal,
|
|
302
|
+
endIndex: items.length - 1
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
return goals;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Parse an assertion tag like [OK], [OK: contains "foo"], [FAIL: reason]
|
|
309
|
+
*/
|
|
310
|
+
function parseAssertion(tag) {
|
|
311
|
+
const inner = tag.slice(1, -1).trim(); // Remove [ ]
|
|
312
|
+
// [OK] - exact match
|
|
313
|
+
if (inner === 'OK') {
|
|
314
|
+
return { type: 'ok' };
|
|
315
|
+
}
|
|
316
|
+
// [SKIP]
|
|
317
|
+
if (inner === 'SKIP') {
|
|
318
|
+
return { type: 'skip' };
|
|
319
|
+
}
|
|
320
|
+
// [OK: contains "text"]
|
|
321
|
+
const containsMatch = inner.match(/^OK:\s*contains\s+"([^"]+)"$/i);
|
|
322
|
+
if (containsMatch) {
|
|
323
|
+
return { type: 'ok-contains', value: containsMatch[1] };
|
|
324
|
+
}
|
|
325
|
+
// [OK: not contains "text"]
|
|
326
|
+
const notContainsMatch = inner.match(/^OK:\s*not\s+contains\s+"([^"]+)"$/i);
|
|
327
|
+
if (notContainsMatch) {
|
|
328
|
+
return { type: 'ok-not-contains', value: notContainsMatch[1] };
|
|
329
|
+
}
|
|
330
|
+
// [OK: matches /regex/flags]
|
|
331
|
+
const matchesMatch = inner.match(/^OK:\s*matches\s+\/(.+)\/([gimsuy]*)$/i);
|
|
332
|
+
if (matchesMatch) {
|
|
333
|
+
try {
|
|
334
|
+
return {
|
|
335
|
+
type: 'ok-matches',
|
|
336
|
+
pattern: new RegExp(matchesMatch[1], matchesMatch[2])
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
catch (e) {
|
|
340
|
+
console.error(`Invalid regex in assertion: ${tag}`);
|
|
341
|
+
return null;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
// [FAIL: reason]
|
|
345
|
+
const failMatch = inner.match(/^FAIL(?::\s*(.+))?$/i);
|
|
346
|
+
if (failMatch) {
|
|
347
|
+
return { type: 'fail', reason: failMatch[1] || 'Expected failure' };
|
|
348
|
+
}
|
|
349
|
+
// [TODO: note]
|
|
350
|
+
const todoMatch = inner.match(/^TODO(?::\s*(.+))?$/i);
|
|
351
|
+
if (todoMatch) {
|
|
352
|
+
return { type: 'todo', reason: todoMatch[1] || 'Not implemented' };
|
|
353
|
+
}
|
|
354
|
+
// [EVENTS: N] - exact event count
|
|
355
|
+
const eventsMatch = inner.match(/^EVENTS:\s*(\d+)$/i);
|
|
356
|
+
if (eventsMatch) {
|
|
357
|
+
return { type: 'event-count', eventCount: parseInt(eventsMatch[1], 10) };
|
|
358
|
+
}
|
|
359
|
+
// [EVENT: true|false, N?, type="..." key="value"]
|
|
360
|
+
// Format: [EVENT: true, 1, type="if.event.pushed" target="y09"]
|
|
361
|
+
// [EVENT: false, type="if.event.destroyed"]
|
|
362
|
+
const eventAssertMatch = inner.match(/^EVENT:\s*(true|false)\s*,\s*(.+)$/i);
|
|
363
|
+
if (eventAssertMatch) {
|
|
364
|
+
const assertTrue = eventAssertMatch[1].toLowerCase() === 'true';
|
|
365
|
+
const rest = eventAssertMatch[2];
|
|
366
|
+
// Check if there's a position number before the type
|
|
367
|
+
const positionMatch = rest.match(/^(\d+)\s*,\s*(.+)$/);
|
|
368
|
+
let eventPosition;
|
|
369
|
+
let propsStr;
|
|
370
|
+
if (positionMatch) {
|
|
371
|
+
eventPosition = parseInt(positionMatch[1], 10);
|
|
372
|
+
propsStr = positionMatch[2];
|
|
373
|
+
}
|
|
374
|
+
else {
|
|
375
|
+
propsStr = rest;
|
|
376
|
+
}
|
|
377
|
+
// Parse key="value" pairs
|
|
378
|
+
const eventData = {};
|
|
379
|
+
let eventType;
|
|
380
|
+
const propRegex = /(\w+)="([^"]+)"/g;
|
|
381
|
+
let match;
|
|
382
|
+
while ((match = propRegex.exec(propsStr)) !== null) {
|
|
383
|
+
const [, key, value] = match;
|
|
384
|
+
if (key === 'type') {
|
|
385
|
+
eventType = value;
|
|
386
|
+
}
|
|
387
|
+
else {
|
|
388
|
+
eventData[key] = value;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
if (eventType) {
|
|
392
|
+
return {
|
|
393
|
+
type: 'event-assert',
|
|
394
|
+
assertTrue,
|
|
395
|
+
eventPosition,
|
|
396
|
+
eventType,
|
|
397
|
+
eventData: Object.keys(eventData).length > 0 ? eventData : undefined
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
// [STATE: true|false, expression]
|
|
402
|
+
// Format: [STATE: true, egg.location = thief]
|
|
403
|
+
// [STATE: false, player.canSee(egg)]
|
|
404
|
+
const stateAssertMatch = inner.match(/^STATE:\s*(true|false)\s*,\s*(.+)$/i);
|
|
405
|
+
if (stateAssertMatch) {
|
|
406
|
+
const assertTrue = stateAssertMatch[1].toLowerCase() === 'true';
|
|
407
|
+
const expression = stateAssertMatch[2].trim();
|
|
408
|
+
return {
|
|
409
|
+
type: 'state-assert',
|
|
410
|
+
assertTrue,
|
|
411
|
+
stateExpression: expression
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
console.warn(`Unknown assertion format: ${tag}`);
|
|
415
|
+
return null;
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* Clean up a command before adding to transcript
|
|
419
|
+
*/
|
|
420
|
+
function finalizeCommand(command) {
|
|
421
|
+
// Trim trailing empty lines from expected output
|
|
422
|
+
while (command.expectedOutput.length > 0 &&
|
|
423
|
+
command.expectedOutput[command.expectedOutput.length - 1].trim() === '') {
|
|
424
|
+
command.expectedOutput.pop();
|
|
425
|
+
}
|
|
426
|
+
// If no explicit assertion and we have expected output, default to [OK]
|
|
427
|
+
if (command.assertions.length === 0 && command.expectedOutput.length > 0) {
|
|
428
|
+
command.assertions.push({ type: 'ok' });
|
|
429
|
+
}
|
|
430
|
+
// If no assertion at all, default to [SKIP]
|
|
431
|
+
if (command.assertions.length === 0) {
|
|
432
|
+
command.assertions.push({ type: 'skip' });
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Validate a transcript for common issues
|
|
437
|
+
*/
|
|
438
|
+
function validateTranscript(transcript) {
|
|
439
|
+
const errors = [];
|
|
440
|
+
if (transcript.commands.length === 0) {
|
|
441
|
+
errors.push('Transcript has no commands');
|
|
442
|
+
}
|
|
443
|
+
if (!transcript.header.story && !transcript.header.title) {
|
|
444
|
+
errors.push('Transcript should have a title or story in header');
|
|
445
|
+
}
|
|
446
|
+
for (const cmd of transcript.commands) {
|
|
447
|
+
if (!cmd.input) {
|
|
448
|
+
errors.push(`Line ${cmd.lineNumber}: Empty command`);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
return errors;
|
|
452
|
+
}
|
|
453
|
+
//# sourceMappingURL=parser.js.map
|
|
@@ -0,0 +1 @@
|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
|
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"}
|