podlite 0.0.82 → 0.0.84
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/CHANGELOG.podlite +95 -0
- package/esm/assemble/async.d.ts +31 -0
- package/esm/assemble/async.js +113 -0
- package/esm/assemble/async.js.map +1 -0
- package/esm/assemble/files.d.ts +2 -0
- package/esm/assemble/files.js +77 -0
- package/esm/assemble/files.js.map +1 -0
- package/esm/assemble/index.d.ts +59 -0
- package/esm/assemble/index.js +1003 -0
- package/esm/assemble/index.js.map +1 -0
- package/esm/cli.js +160 -30
- package/esm/cli.js.map +1 -1
- package/esm/file-format.d.ts +3 -0
- package/esm/file-format.js +53 -0
- package/esm/file-format.js.map +1 -0
- package/esm/index.d.ts +4 -0
- package/esm/index.js +5 -2
- package/esm/index.js.map +1 -1
- package/esm/lint/config.js +6 -2
- package/esm/lint/config.js.map +1 -1
- package/esm/lint/engine.js +1 -1
- package/esm/lint/grammar/scan.d.ts +1 -1
- package/esm/lint/grammar/scan.js +7 -6
- package/esm/lint/grammar/scan.js.map +1 -1
- package/esm/lint/index.d.ts +1 -1
- package/esm/lint/index.js +14 -14
- package/esm/lint/index.js.map +1 -1
- package/esm/lint/loader.js +5 -4
- package/esm/lint/loader.js.map +1 -1
- package/esm/lint/mute.js +2 -1
- package/esm/lint/mute.js.map +1 -1
- package/esm/lint/parallel.js +1 -1
- package/esm/lint/rules/include-resolves.d.ts +6 -0
- package/esm/lint/rules/include-resolves.js +89 -0
- package/esm/lint/rules/include-resolves.js.map +1 -0
- package/esm/lint/rules/index.js +12 -10
- package/esm/lint/rules/index.js.map +1 -1
- package/esm/lint/rules/link-file-resolves.js +2 -2
- package/esm/lint/rules/link-not-empty.js +1 -1
- package/esm/lint/rules/link-target-resolves.js +1 -1
- package/esm/lint/rules/table-shape.js +7 -1
- package/esm/lint/rules/table-shape.js.map +1 -1
- package/esm/lint/types.d.ts +6 -1
- package/esm/lint/types.js.map +1 -1
- package/esm/lint/worker.js +1 -1
- package/esm/query-blocks.d.ts +6 -0
- package/esm/query-blocks.js +127 -0
- package/esm/query-blocks.js.map +1 -0
- package/esm/query.d.ts +2 -0
- package/esm/query.js +233 -26
- package/esm/query.js.map +1 -1
- package/esm/reader.d.ts +15 -0
- package/esm/reader.js +119 -0
- package/esm/reader.js.map +1 -0
- package/esm/refresh-tocs.d.ts +2 -0
- package/esm/refresh-tocs.js +52 -0
- package/esm/refresh-tocs.js.map +1 -0
- package/esm/resolve-includes.d.ts +27 -1
- package/esm/resolve-includes.js +80 -40
- package/esm/resolve-includes.js.map +1 -1
- package/esm/test/collect.d.ts +16 -0
- package/esm/test/collect.js +368 -0
- package/esm/test/collect.js.map +1 -0
- package/esm/test/documents.d.ts +47 -0
- package/esm/test/documents.js +211 -0
- package/esm/test/documents.js.map +1 -0
- package/esm/test/evaluate.d.ts +41 -0
- package/esm/test/evaluate.js +104 -0
- package/esm/test/evaluate.js.map +1 -0
- package/esm/test/formatters/json.d.ts +2 -0
- package/esm/test/formatters/json.js +11 -0
- package/esm/test/formatters/json.js.map +1 -0
- package/esm/test/formatters/text.d.ts +2 -0
- package/esm/test/formatters/text.js +104 -0
- package/esm/test/formatters/text.js.map +1 -0
- package/esm/test/index.d.ts +11 -0
- package/esm/test/index.js +19 -0
- package/esm/test/index.js.map +1 -0
- package/esm/test/resources.d.ts +5 -0
- package/esm/test/resources.js +45 -0
- package/esm/test/resources.js.map +1 -0
- package/esm/test/run.d.ts +52 -0
- package/esm/test/run.js +91 -0
- package/esm/test/run.js.map +1 -0
- package/esm/test/sources.d.ts +48 -0
- package/esm/test/sources.js +162 -0
- package/esm/test/sources.js.map +1 -0
- package/esm/test/types.d.ts +104 -0
- package/esm/test/types.js +3 -0
- package/esm/test/types.js.map +1 -0
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/lib/assemble/async.d.ts +31 -0
- package/lib/assemble/async.js +118 -0
- package/lib/assemble/async.js.map +1 -0
- package/lib/assemble/files.d.ts +2 -0
- package/lib/assemble/files.js +81 -0
- package/lib/assemble/files.js.map +1 -0
- package/lib/assemble/index.d.ts +59 -0
- package/lib/assemble/index.js +1013 -0
- package/lib/assemble/index.js.map +1 -0
- package/lib/cli.js +154 -24
- package/lib/cli.js.map +1 -1
- package/lib/file-format.d.ts +3 -0
- package/lib/file-format.js +58 -0
- package/lib/file-format.js.map +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +22 -1
- package/lib/index.js.map +1 -1
- package/lib/lint/config.js +6 -2
- package/lib/lint/config.js.map +1 -1
- package/lib/lint/grammar/scan.d.ts +1 -1
- package/lib/lint/grammar/scan.js +7 -3
- package/lib/lint/grammar/scan.js.map +1 -1
- package/lib/lint/index.d.ts +1 -1
- package/lib/lint/index.js +3 -3
- package/lib/lint/index.js.map +1 -1
- package/lib/lint/loader.js +5 -4
- package/lib/lint/loader.js.map +1 -1
- package/lib/lint/mute.js +2 -1
- package/lib/lint/mute.js.map +1 -1
- package/lib/lint/rules/include-resolves.d.ts +6 -0
- package/lib/lint/rules/include-resolves.js +92 -0
- package/lib/lint/rules/include-resolves.js.map +1 -0
- package/lib/lint/rules/index.js +2 -0
- package/lib/lint/rules/index.js.map +1 -1
- package/lib/lint/rules/table-shape.js +7 -1
- package/lib/lint/rules/table-shape.js.map +1 -1
- package/lib/lint/types.d.ts +6 -1
- package/lib/lint/types.js.map +1 -1
- package/lib/query-blocks.d.ts +6 -0
- package/lib/query-blocks.js +136 -0
- package/lib/query-blocks.js.map +1 -0
- package/lib/query.d.ts +2 -0
- package/lib/query.js +232 -25
- package/lib/query.js.map +1 -1
- package/lib/reader.d.ts +15 -0
- package/lib/reader.js +124 -0
- package/lib/reader.js.map +1 -0
- package/lib/refresh-tocs.d.ts +2 -0
- package/lib/refresh-tocs.js +56 -0
- package/lib/refresh-tocs.js.map +1 -0
- package/lib/resolve-includes.d.ts +27 -1
- package/lib/resolve-includes.js +84 -40
- package/lib/resolve-includes.js.map +1 -1
- package/lib/test/collect.d.ts +16 -0
- package/lib/test/collect.js +374 -0
- package/lib/test/collect.js.map +1 -0
- package/lib/test/documents.d.ts +47 -0
- package/lib/test/documents.js +250 -0
- package/lib/test/documents.js.map +1 -0
- package/lib/test/evaluate.d.ts +41 -0
- package/lib/test/evaluate.js +142 -0
- package/lib/test/evaluate.js.map +1 -0
- package/lib/test/formatters/json.d.ts +2 -0
- package/lib/test/formatters/json.js +15 -0
- package/lib/test/formatters/json.js.map +1 -0
- package/lib/test/formatters/text.d.ts +2 -0
- package/lib/test/formatters/text.js +141 -0
- package/lib/test/formatters/text.js.map +1 -0
- package/lib/test/index.d.ts +11 -0
- package/lib/test/index.js +31 -0
- package/lib/test/index.js.map +1 -0
- package/lib/test/resources.d.ts +5 -0
- package/lib/test/resources.js +83 -0
- package/lib/test/resources.js.map +1 -0
- package/lib/test/run.d.ts +52 -0
- package/lib/test/run.js +95 -0
- package/lib/test/run.js.map +1 -0
- package/lib/test/sources.d.ts +48 -0
- package/lib/test/sources.js +200 -0
- package/lib/test/sources.js.map +1 -0
- package/lib/test/types.d.ts +104 -0
- package/lib/test/types.js +8 -0
- package/lib/test/types.js.map +1 -0
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +28 -7
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.formatText = void 0;
|
|
37
|
+
const path = __importStar(require("path"));
|
|
38
|
+
// a fixture is named after the file of its test and its place in it
|
|
39
|
+
const shown = (file, cwd) => {
|
|
40
|
+
const hash = file.indexOf('#');
|
|
41
|
+
const disk = hash === -1 ? file : file.slice(0, hash);
|
|
42
|
+
const rest = hash === -1 ? '' : file.slice(hash);
|
|
43
|
+
return path.isAbsolute(disk) ? `${path.relative(cwd, disk) || '.'}${rest}` : file;
|
|
44
|
+
};
|
|
45
|
+
const at = (place, cwd) => `${shown(place.file, cwd)}${place.location ? `:${place.location.start.line}` : ''}`;
|
|
46
|
+
const describeTestReason = (reason, cwd) => {
|
|
47
|
+
switch (reason.kind) {
|
|
48
|
+
case 'assertion':
|
|
49
|
+
return 'an assertion does not hold';
|
|
50
|
+
case 'no-assertions':
|
|
51
|
+
return 'the test has no assertion';
|
|
52
|
+
case 'malformed-test':
|
|
53
|
+
return `${reason.message} (${at(reason.place, cwd)})`;
|
|
54
|
+
case 'invalid-test':
|
|
55
|
+
return `${reason.message} (${at(reason.place, cwd)})`;
|
|
56
|
+
case 'unknown-child':
|
|
57
|
+
return `a block of an unknown name, ${reason.name}, is in the test (${at(reason.place, cwd)})`;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
const describeAssertionReason = (reason, cwd) => {
|
|
61
|
+
switch (reason.kind) {
|
|
62
|
+
case 'assertion-false':
|
|
63
|
+
return 'does not hold';
|
|
64
|
+
case 'unsupported-selector':
|
|
65
|
+
return `the selection is not supported: ${reason.selector}`;
|
|
66
|
+
case 'operand-unresolved':
|
|
67
|
+
return `the operand of the selection does not resolve: ${reason.message}`;
|
|
68
|
+
case 'source-unavailable':
|
|
69
|
+
return `the source cannot be read: ${reason.source} (from ${shown(reason.base, cwd)})`;
|
|
70
|
+
case 'address-unresolved':
|
|
71
|
+
return `the address is not in the source: #${reason.address} in ${reason.source}`;
|
|
72
|
+
case 'source-unsupported':
|
|
73
|
+
return `the source is not supported: ${reason.source}, ${reason.message}`;
|
|
74
|
+
case 'input-error':
|
|
75
|
+
return `the ${reason.input} document lost content: ${reason.problems.map(p => p.message).join('; ')}`;
|
|
76
|
+
case 'implementation-error':
|
|
77
|
+
return `the implementation failed: ${reason.message}`;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const describeAssertion = (a, cwd) => {
|
|
81
|
+
const input = a.input ? `, against the ${a.input.kind} document ${shown(a.input.document, cwd)}` : '';
|
|
82
|
+
const count = a.matches === undefined ? '' : `, ${a.matches} ${a.matches === 1 ? 'match' : 'matches'}`;
|
|
83
|
+
const what = `${a.absent ? ':absent ' : ''}${a.expression}`;
|
|
84
|
+
const lines = [
|
|
85
|
+
` assertion ${a.index + 1} at ${at(a.place, cwd)}: ${what}`,
|
|
86
|
+
` ${a.held ? 'holds' : a.reason ? describeAssertionReason(a.reason, cwd) : 'does not hold'}${input}${count}`,
|
|
87
|
+
];
|
|
88
|
+
if (!a.held && a.absent) {
|
|
89
|
+
for (const e of a.evidence) {
|
|
90
|
+
const where = at({ file: e.file, location: e.location }, cwd);
|
|
91
|
+
lines.push(` found ${e.name} ${e.precision === 'section' ? `in the Markdown section at ${where}` : `at ${where}`}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return lines;
|
|
95
|
+
};
|
|
96
|
+
const describeTest = (t, cwd) => {
|
|
97
|
+
const name = t.id ?? t.caption ?? 'test';
|
|
98
|
+
const against = t.against ? ` against ${shown(t.against, cwd)}` : '';
|
|
99
|
+
const head = `${t.status.padEnd(7)} ${name} (${at(t.place, cwd)})${against}`;
|
|
100
|
+
if (t.status === 'passed')
|
|
101
|
+
return [head];
|
|
102
|
+
const reason = t.reason && t.reason.kind !== 'assertion' ? [` ${describeTestReason(t.reason, cwd)}`] : [];
|
|
103
|
+
return [head, ...reason, ...t.asserts.filter(a => !a.held).flatMap(a => describeAssertion(a, cwd))];
|
|
104
|
+
};
|
|
105
|
+
const describeProblem = (p, cwd) => {
|
|
106
|
+
switch (p.kind) {
|
|
107
|
+
case 'unreadable-source':
|
|
108
|
+
return `error: ${shown(p.source, cwd)}: cannot be read: ${p.message}`;
|
|
109
|
+
case 'implementation-error':
|
|
110
|
+
return `error: ${shown(p.source, cwd)}: the implementation failed: ${p.message}`;
|
|
111
|
+
case 'include': {
|
|
112
|
+
const step = p.problem.chain[p.problem.chain.length - 1];
|
|
113
|
+
const where = step ? at({ file: step.file, location: step.location }, cwd) : shown(p.source, cwd);
|
|
114
|
+
return `${p.severity}: ${where}: ${p.problem.message}`;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
/*
|
|
119
|
+
=begin pod :kind<export>
|
|
120
|
+
|
|
121
|
+
=head2 formatText
|
|
122
|
+
|
|
123
|
+
The report as lines for a terminal: a line per test, the failed assertions of a
|
|
124
|
+
test that did not pass with the document each read, and a count. Paths are shown
|
|
125
|
+
relative to C<cwd>.
|
|
126
|
+
|
|
127
|
+
=end pod
|
|
128
|
+
*/
|
|
129
|
+
const formatText = (report, cwd = process.cwd()) => {
|
|
130
|
+
const lines = [
|
|
131
|
+
...report.problems.map(p => describeProblem(p, cwd)),
|
|
132
|
+
...report.tests.flatMap(t => describeTest(t, cwd)),
|
|
133
|
+
];
|
|
134
|
+
const { tests, passed, failed, skipped } = report.counts;
|
|
135
|
+
const summary = tests === 0
|
|
136
|
+
? 'no tests were found: nothing was checked'
|
|
137
|
+
: `${tests} ${tests === 1 ? 'test' : 'tests'}: ${passed} passed, ${failed} failed, ${skipped} skipped`;
|
|
138
|
+
return `${[...lines, summary].join('\n')}\n`;
|
|
139
|
+
};
|
|
140
|
+
exports.formatText = formatText;
|
|
141
|
+
//# sourceMappingURL=text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../../src/test/formatters/text.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4B;AAK5B,oEAAoE;AACpE,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,GAAW,EAAU,EAAE;IAClD,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IAC9B,MAAM,IAAI,GAAG,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAA;IACrD,MAAM,IAAI,GAAG,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAChD,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,GAA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export { collectTests, planRuns } from './collect';
|
|
4
|
+
export { inputsFor } from './sources';
|
|
5
|
+
export { evaluateAssertion } from './evaluate';
|
|
6
|
+
export type { AssertionResult } from './evaluate';
|
|
7
|
+
export { coreProfile, schemaProfile } from './documents';
|
|
8
|
+
export type { Profile } from './documents';
|
|
9
|
+
export { formatText } from './formatters/text';
|
|
10
|
+
export { formatJson } from './formatters/json';
|
|
11
|
+
export type { TestSource } from './types';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatJson = exports.formatText = exports.schemaProfile = exports.coreProfile = exports.evaluateAssertion = exports.inputsFor = exports.planRuns = exports.collectTests = exports.runTests = void 0;
|
|
4
|
+
/*
|
|
5
|
+
=begin pod :kind<module>
|
|
6
|
+
|
|
7
|
+
=head1 podlite/test
|
|
8
|
+
|
|
9
|
+
Runs the tests written in Podlite files: C<=test> blocks with their C<=fixture>,
|
|
10
|
+
C<=assert> and C<=resource>. A run can also examine documents given from outside with
|
|
11
|
+
the same tests, which is how a set of assertions checks documents of a project.
|
|
12
|
+
|
|
13
|
+
=end pod
|
|
14
|
+
*/
|
|
15
|
+
var run_1 = require("./run");
|
|
16
|
+
Object.defineProperty(exports, "runTests", { enumerable: true, get: function () { return run_1.runTests; } });
|
|
17
|
+
var collect_1 = require("./collect");
|
|
18
|
+
Object.defineProperty(exports, "collectTests", { enumerable: true, get: function () { return collect_1.collectTests; } });
|
|
19
|
+
Object.defineProperty(exports, "planRuns", { enumerable: true, get: function () { return collect_1.planRuns; } });
|
|
20
|
+
var sources_1 = require("./sources");
|
|
21
|
+
Object.defineProperty(exports, "inputsFor", { enumerable: true, get: function () { return sources_1.inputsFor; } });
|
|
22
|
+
var evaluate_1 = require("./evaluate");
|
|
23
|
+
Object.defineProperty(exports, "evaluateAssertion", { enumerable: true, get: function () { return evaluate_1.evaluateAssertion; } });
|
|
24
|
+
var documents_1 = require("./documents");
|
|
25
|
+
Object.defineProperty(exports, "coreProfile", { enumerable: true, get: function () { return documents_1.coreProfile; } });
|
|
26
|
+
Object.defineProperty(exports, "schemaProfile", { enumerable: true, get: function () { return documents_1.schemaProfile; } });
|
|
27
|
+
var text_1 = require("./formatters/text");
|
|
28
|
+
Object.defineProperty(exports, "formatText", { enumerable: true, get: function () { return text_1.formatText; } });
|
|
29
|
+
var json_1 = require("./formatters/json");
|
|
30
|
+
Object.defineProperty(exports, "formatJson", { enumerable: true, get: function () { return json_1.formatJson; } });
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;EAUE;AACF,6BAAgC;AAAvB,+FAAA,QAAQ,OAAA;AAEjB,qCAAkD;AAAzC,uGAAA,YAAY,OAAA;AAAE,mGAAA,QAAQ,OAAA;AAC/B,qCAAqC;AAA5B,oGAAA,SAAS,OAAA;AAClB,uCAA8C;AAArC,6GAAA,iBAAiB,OAAA;AAE1B,yCAAwD;AAA/C,wGAAA,WAAW,OAAA;AAAE,0GAAA,aAAa,OAAA;AAEnC,0CAA8C;AAArC,kGAAA,UAAU,OAAA;AACnB,0CAA8C;AAArC,kGAAA,UAAU,OAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SourceProvider } from '../resolve-includes';
|
|
2
|
+
import type { ResourceDecl } from './types';
|
|
3
|
+
export declare const RESOURCE_ROOT: string;
|
|
4
|
+
export declare const resourceKey: (name: string) => string | undefined;
|
|
5
|
+
export declare const resourceProvider: (resources: ResourceDecl[]) => SourceProvider;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.resourceProvider = exports.resourceKey = exports.RESOURCE_ROOT = void 0;
|
|
37
|
+
const path = __importStar(require("path"));
|
|
38
|
+
// A directory no disk holds: a fixture reads its relative paths from here, and
|
|
39
|
+
// nothing outside the names a test declares is there to read.
|
|
40
|
+
exports.RESOURCE_ROOT = path.resolve(path.sep, 'podlite-test-resources');
|
|
41
|
+
// The form a resource is looked up by; undefined for a name that would leave
|
|
42
|
+
// the directory of the test.
|
|
43
|
+
const resourceKey = (name) => {
|
|
44
|
+
const slashed = name.replace(/\\/g, '/');
|
|
45
|
+
if (slashed.startsWith('/') || /^[a-zA-Z]:/.test(slashed))
|
|
46
|
+
return undefined;
|
|
47
|
+
const key = path.posix.normalize(slashed);
|
|
48
|
+
return key === '.' || key.startsWith('../') || key === '..' ? undefined : key;
|
|
49
|
+
};
|
|
50
|
+
exports.resourceKey = resourceKey;
|
|
51
|
+
const keyOfPath = (file) => {
|
|
52
|
+
const rel = path.relative(exports.RESOURCE_ROOT, file);
|
|
53
|
+
if (!rel || path.isAbsolute(rel))
|
|
54
|
+
return undefined;
|
|
55
|
+
return (0, exports.resourceKey)(rel.split(path.sep).join('/'));
|
|
56
|
+
};
|
|
57
|
+
const resourceProvider = (resources) => {
|
|
58
|
+
const files = new Map();
|
|
59
|
+
for (const r of resources) {
|
|
60
|
+
const key = (0, exports.resourceKey)(r.name);
|
|
61
|
+
if (key !== undefined && !files.has(key))
|
|
62
|
+
files.set(key, r.body);
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
read: file => {
|
|
66
|
+
const key = keyOfPath(file);
|
|
67
|
+
return key === undefined ? null : files.get(key) ?? null;
|
|
68
|
+
},
|
|
69
|
+
list: (dir, deep) => {
|
|
70
|
+
const rel = path.relative(exports.RESOURCE_ROOT, dir).split(path.sep).join('/');
|
|
71
|
+
if (rel.startsWith('..') || path.isAbsolute(rel))
|
|
72
|
+
return [];
|
|
73
|
+
const prefix = rel ? `${rel}/` : '';
|
|
74
|
+
return [...files.keys()]
|
|
75
|
+
.filter(key => key.startsWith(prefix))
|
|
76
|
+
.map(key => key.slice(prefix.length))
|
|
77
|
+
.filter(name => deep || !name.includes('/'))
|
|
78
|
+
.sort();
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
exports.resourceProvider = resourceProvider;
|
|
83
|
+
//# sourceMappingURL=resources.js.map
|
|
@@ -0,0 +1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AM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;iBAC3C,IAAI,EAAE,CAAA;QACX,CAAC;KACF,CAAA;AACH,CAAC,CAAA;AAtBY,QAAA,gBAAgB,oBAsB5B"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Profile } from './documents';
|
|
2
|
+
import type { AssertionResult } from './evaluate';
|
|
3
|
+
import type { CollectionProblem, Place, TestSource } from './types';
|
|
4
|
+
export type TestStatus = 'passed' | 'failed' | 'skipped';
|
|
5
|
+
export type TestReason = {
|
|
6
|
+
kind: 'assertion';
|
|
7
|
+
} | {
|
|
8
|
+
kind: 'no-assertions';
|
|
9
|
+
} | {
|
|
10
|
+
kind: 'malformed-test';
|
|
11
|
+
message: string;
|
|
12
|
+
place: Place;
|
|
13
|
+
} | {
|
|
14
|
+
kind: 'invalid-test';
|
|
15
|
+
message: string;
|
|
16
|
+
place: Place;
|
|
17
|
+
} | {
|
|
18
|
+
kind: 'unknown-child';
|
|
19
|
+
name: string;
|
|
20
|
+
place: Place;
|
|
21
|
+
};
|
|
22
|
+
export type TestResult = {
|
|
23
|
+
id?: string;
|
|
24
|
+
caption?: string;
|
|
25
|
+
place: Place;
|
|
26
|
+
obtainedFrom: string[];
|
|
27
|
+
against?: string;
|
|
28
|
+
status: TestStatus;
|
|
29
|
+
reason?: TestReason;
|
|
30
|
+
asserts: AssertionResult[];
|
|
31
|
+
};
|
|
32
|
+
export type RunReport = {
|
|
33
|
+
format: 'podlite-test-report';
|
|
34
|
+
version: 1;
|
|
35
|
+
profile: string;
|
|
36
|
+
tests: TestResult[];
|
|
37
|
+
problems: CollectionProblem[];
|
|
38
|
+
counts: {
|
|
39
|
+
tests: number;
|
|
40
|
+
passed: number;
|
|
41
|
+
failed: number;
|
|
42
|
+
skipped: number;
|
|
43
|
+
};
|
|
44
|
+
exitCode: 0 | 1 | 2;
|
|
45
|
+
};
|
|
46
|
+
export type RunOptions = {
|
|
47
|
+
tests: TestSource[];
|
|
48
|
+
against?: string[];
|
|
49
|
+
profile?: Profile;
|
|
50
|
+
allowSkipped?: boolean;
|
|
51
|
+
};
|
|
52
|
+
export declare const runTests: (opts: RunOptions) => RunReport;
|
package/lib/test/run.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runTests = void 0;
|
|
4
|
+
const collect_1 = require("./collect");
|
|
5
|
+
const documents_1 = require("./documents");
|
|
6
|
+
const evaluate_1 = require("./evaluate");
|
|
7
|
+
const sources_1 = require("./sources");
|
|
8
|
+
const statusOf = (test, asserts) => {
|
|
9
|
+
const { shape } = test;
|
|
10
|
+
switch (shape.kind) {
|
|
11
|
+
case 'unknown-child':
|
|
12
|
+
return { status: 'skipped', reason: { kind: 'unknown-child', name: shape.name, place: shape.place } };
|
|
13
|
+
case 'malformed':
|
|
14
|
+
return { status: 'failed', reason: { kind: 'malformed-test', message: shape.message, place: shape.place } };
|
|
15
|
+
case 'invalid':
|
|
16
|
+
return { status: 'failed', reason: { kind: 'invalid-test', message: shape.message, place: shape.place } };
|
|
17
|
+
case 'no-assertions':
|
|
18
|
+
return { status: 'failed', reason: { kind: 'no-assertions' } };
|
|
19
|
+
case 'runnable':
|
|
20
|
+
return asserts.every(a => a.held) ? { status: 'passed' } : { status: 'failed', reason: { kind: 'assertion' } };
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const isImplementationError = (problem) => problem.kind === 'implementation-error';
|
|
24
|
+
const losesTests = (problem) => problem.kind === 'unreadable-source' || (problem.kind === 'include' && problem.severity === 'error');
|
|
25
|
+
const exitCodeOf = (tests, problems, allowSkipped) => {
|
|
26
|
+
const broken = problems.some(isImplementationError) ||
|
|
27
|
+
tests.some(t => t.asserts.some(a => a.reason?.kind === 'implementation-error'));
|
|
28
|
+
if (broken)
|
|
29
|
+
return 2;
|
|
30
|
+
if (tests.length === 0 || problems.some(losesTests))
|
|
31
|
+
return 1;
|
|
32
|
+
if (tests.some(t => t.status === 'failed'))
|
|
33
|
+
return 1;
|
|
34
|
+
if (!allowSkipped && tests.some(t => t.status === 'skipped'))
|
|
35
|
+
return 1;
|
|
36
|
+
return 0;
|
|
37
|
+
};
|
|
38
|
+
/*
|
|
39
|
+
=begin pod :kind<export>
|
|
40
|
+
|
|
41
|
+
=head2 runTests
|
|
42
|
+
|
|
43
|
+
Collects the tests of the files given, runs each once or once per document it has to
|
|
44
|
+
read, and reports. Nothing is printed and the process exit code is not touched: the
|
|
45
|
+
code is in the report.
|
|
46
|
+
|
|
47
|
+
The exit code is 2 when the implementation failed, 1 when a test failed, a test was
|
|
48
|
+
skipped and that is not allowed, no test was found, or an include lost tests, and 0
|
|
49
|
+
otherwise.
|
|
50
|
+
|
|
51
|
+
=end pod
|
|
52
|
+
*/
|
|
53
|
+
const runTests = (opts) => {
|
|
54
|
+
const profile = opts.profile ?? documents_1.coreProfile;
|
|
55
|
+
const against = opts.against ?? [];
|
|
56
|
+
const collection = (0, collect_1.collectTests)(opts.tests, profile);
|
|
57
|
+
const supplied = against.map(file => (0, sources_1.prepareSupplied)(file, profile));
|
|
58
|
+
const env = {
|
|
59
|
+
profile,
|
|
60
|
+
supplied,
|
|
61
|
+
containing: (index) => collection.sources.find(s => s.index === index),
|
|
62
|
+
};
|
|
63
|
+
const sourceName = (index) => collection.sources.find(s => s.index === index)?.name ?? String(index);
|
|
64
|
+
const results = (0, collect_1.planRuns)(collection.tests, against.length).map((run) => {
|
|
65
|
+
const { test, context } = run;
|
|
66
|
+
const input = (0, sources_1.inputsFor)(test, context, env);
|
|
67
|
+
const asserts = test.shape.kind === 'runnable' ? test.asserts.map(a => (0, evaluate_1.evaluateAssertion)(a, input(a), profile)) : [];
|
|
68
|
+
return {
|
|
69
|
+
id: test.id,
|
|
70
|
+
caption: test.caption,
|
|
71
|
+
place: test.place,
|
|
72
|
+
obtainedFrom: run.obtained.map(t => sourceName(t.obtainedFrom)),
|
|
73
|
+
against: context.kind === 'supplied' ? against[context.document] : undefined,
|
|
74
|
+
...statusOf(test, asserts),
|
|
75
|
+
asserts,
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
const counts = {
|
|
79
|
+
tests: results.length,
|
|
80
|
+
passed: results.filter(t => t.status === 'passed').length,
|
|
81
|
+
failed: results.filter(t => t.status === 'failed').length,
|
|
82
|
+
skipped: results.filter(t => t.status === 'skipped').length,
|
|
83
|
+
};
|
|
84
|
+
return {
|
|
85
|
+
format: 'podlite-test-report',
|
|
86
|
+
version: 1,
|
|
87
|
+
profile: profile.name,
|
|
88
|
+
tests: results,
|
|
89
|
+
problems: collection.problems,
|
|
90
|
+
counts,
|
|
91
|
+
exitCode: exitCodeOf(results, collection.problems, opts.allowSkipped === true),
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
exports.runTests = runTests;
|
|
95
|
+
//# sourceMappingURL=run.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/test/run.ts"],"names":[],"mappings":";;;AAAA,uCAAkD;AAClD,2CAAyC;AAEzC,yCAA8C;AAE9C,uCAAsD;AAwFtD,MAAM,QAAQ,GAAG,CAAC,IAAmB,EAAE,OAA0B,EAAyC,EAAE;IAC1G,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAA;IACtB,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,eAAe;YAClB,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,EAAE,CAAA;QACvG,KAAK,WAAW;YACd,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO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CAAC,MAAM;QACzD,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,MAAM;QACzD,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,MAAM;KAC5D,CAAA;IACD,OAAO;QACL,MAAM,EAAE,qBAAqB;QAC7B,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,OAAO,CAAC,IAAI;QACrB,KAAK,EAAE,OAAO;QACd,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,MAAM;QACN,QAAQ,EAAE,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC,YAAY,KAAK,IAAI,CAAC;KAC/E,CAAA;AACH,CAAC,CAAA;AA1CY,QAAA,QAAQ,YA0CpB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { PodliteDocument, PodNode, SelectorDoc } from '@podlite/schema';
|
|
2
|
+
import type { IncludeProblem } from '../resolve-includes';
|
|
3
|
+
import type { PreparedDocument, Profile } from './documents';
|
|
4
|
+
import type { AssertDecl, CollectedTest, FixtureDecl, Result, RunContext } from './types';
|
|
5
|
+
export type InputKind = 'named' | 'supplied' | 'fixture' | 'containing';
|
|
6
|
+
export type AssertionInput = {
|
|
7
|
+
kind: InputKind;
|
|
8
|
+
document: PreparedDocument;
|
|
9
|
+
target: PodNode | PodliteDocument;
|
|
10
|
+
source?: string;
|
|
11
|
+
base?: string;
|
|
12
|
+
fixture?: FixtureDecl;
|
|
13
|
+
supplied?: number;
|
|
14
|
+
readFile?: (document: string) => SelectorDoc[] | undefined;
|
|
15
|
+
};
|
|
16
|
+
export type InputFailure = {
|
|
17
|
+
kind: 'source-unavailable';
|
|
18
|
+
input: InputKind;
|
|
19
|
+
source: string;
|
|
20
|
+
base: string;
|
|
21
|
+
message: string;
|
|
22
|
+
} | {
|
|
23
|
+
kind: 'address-unresolved';
|
|
24
|
+
input: InputKind;
|
|
25
|
+
source: string;
|
|
26
|
+
address: string;
|
|
27
|
+
} | {
|
|
28
|
+
kind: 'source-unsupported';
|
|
29
|
+
input: InputKind;
|
|
30
|
+
source: string;
|
|
31
|
+
message: string;
|
|
32
|
+
} | {
|
|
33
|
+
kind: 'input-error';
|
|
34
|
+
input: InputKind;
|
|
35
|
+
problems: IncludeProblem[];
|
|
36
|
+
} | {
|
|
37
|
+
kind: 'implementation-error';
|
|
38
|
+
input: InputKind;
|
|
39
|
+
message: string;
|
|
40
|
+
};
|
|
41
|
+
export type SuppliedDocument = Result<PreparedDocument, InputFailure>;
|
|
42
|
+
export type InputEnvironment = {
|
|
43
|
+
profile: Profile;
|
|
44
|
+
supplied: SuppliedDocument[];
|
|
45
|
+
containing: (source: number) => PreparedDocument | undefined;
|
|
46
|
+
};
|
|
47
|
+
export declare const prepareSupplied: (file: string, profile: Profile) => SuppliedDocument;
|
|
48
|
+
export declare const inputsFor: (test: CollectedTest, context: RunContext, env: InputEnvironment) => (assert: AssertDecl) => Result<AssertionInput, InputFailure>;
|