eyeling 1.28.5 → 1.28.7
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.md +33 -1
- package/dist/browser/eyeling.browser.js +607 -1
- package/eyeling-builtins.ttl +28 -1
- package/eyeling.js +607 -1
- package/lib/builtins.js +604 -1
- package/lib/prelude.js +3 -0
- package/package.json +1 -1
- package/test/api.test.js +13 -29
- package/test/builtins.test.js +69 -22
- package/test/examples.test.js +27 -42
- package/test/extra.test.js +9 -25
- package/test/manifest.test.js +23 -28
- package/test/package.test.js +17 -24
- package/test/packlist.test.js +5 -14
- package/test/playground.test.js +6 -22
- package/test/rdf12.test.js +15 -54
- package/test/report.js +67 -0
- package/test/stream_messages.test.js +11 -25
package/test/api.test.js
CHANGED
|
@@ -66,29 +66,12 @@ function reasonQuiet(opt, input) {
|
|
|
66
66
|
throw err;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
const
|
|
70
|
-
const C = TTY
|
|
71
|
-
? { g: '\x1b[32m', r: '\x1b[31m', y: '\x1b[33m', dim: '\x1b[2m', n: '\x1b[0m' }
|
|
72
|
-
: { g: '', r: '', y: '', dim: '', n: '' };
|
|
73
|
-
|
|
74
|
-
function ok(msg) {
|
|
75
|
-
console.log(`${C.g}OK ${C.n} ${msg}`);
|
|
76
|
-
}
|
|
77
|
-
function info(msg) {
|
|
78
|
-
console.log(`${C.y}==${C.n} ${msg}`);
|
|
79
|
-
}
|
|
80
|
-
function fail(msg) {
|
|
81
|
-
console.error(`${C.r}FAIL${C.n} ${msg}`);
|
|
82
|
-
}
|
|
69
|
+
const { detail, failResult, info, pass } = require('./report');
|
|
83
70
|
|
|
84
71
|
function unnumberedName(name) {
|
|
85
72
|
return String(name).replace(/^\d+[a-z]*\s+/i, '');
|
|
86
73
|
}
|
|
87
74
|
|
|
88
|
-
function numberedName(index, name) {
|
|
89
|
-
return `${String(index + 1).padStart(3, '0')} ${unnumberedName(name)}`;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
75
|
function msNow() {
|
|
93
76
|
return Date.now();
|
|
94
77
|
}
|
|
@@ -3172,7 +3155,8 @@ let failed = 0;
|
|
|
3172
3155
|
info(`Running ${cases.length} API tests (independent of examples/)`);
|
|
3173
3156
|
|
|
3174
3157
|
for (const [index, tc] of cases.entries()) {
|
|
3175
|
-
const
|
|
3158
|
+
const testNr = index + 1;
|
|
3159
|
+
const testName = unnumberedName(tc.name);
|
|
3176
3160
|
const start = msNow();
|
|
3177
3161
|
try {
|
|
3178
3162
|
const out = typeof tc.run === 'function' ? await tc.run() : reasonQuiet(tc.opt, tc.input);
|
|
@@ -3187,19 +3171,19 @@ let failed = 0;
|
|
|
3187
3171
|
if (typeof tc.check === 'function') tc.check(out, tc);
|
|
3188
3172
|
|
|
3189
3173
|
const dur = msNow() - start;
|
|
3190
|
-
|
|
3174
|
+
pass(testNr, testName, dur);
|
|
3191
3175
|
passed++;
|
|
3192
3176
|
} catch (e) {
|
|
3193
3177
|
const dur = msNow() - start;
|
|
3194
3178
|
|
|
3195
3179
|
if (tc.expectErrorCode != null) {
|
|
3196
3180
|
if (e && typeof e === 'object' && 'code' in e && e.code === tc.expectErrorCode) {
|
|
3197
|
-
|
|
3181
|
+
pass(testNr, `${testName} (expected exit ${tc.expectErrorCode})`, dur);
|
|
3198
3182
|
passed++;
|
|
3199
3183
|
continue;
|
|
3200
3184
|
}
|
|
3201
|
-
|
|
3202
|
-
|
|
3185
|
+
failResult(testNr, testName, dur);
|
|
3186
|
+
detail(
|
|
3203
3187
|
`Expected exit code ${tc.expectErrorCode}, got: ${e && e.code != null ? e.code : 'unknown'}\n${
|
|
3204
3188
|
e && e.stderr ? e.stderr : e && e.stack ? e.stack : String(e)
|
|
3205
3189
|
}`,
|
|
@@ -3209,26 +3193,26 @@ let failed = 0;
|
|
|
3209
3193
|
}
|
|
3210
3194
|
|
|
3211
3195
|
if (tc.expectError) {
|
|
3212
|
-
|
|
3196
|
+
pass(testNr, `${testName} (expected error)`, dur);
|
|
3213
3197
|
passed++;
|
|
3214
3198
|
continue;
|
|
3215
3199
|
}
|
|
3216
3200
|
|
|
3217
|
-
|
|
3218
|
-
|
|
3201
|
+
failResult(testNr, testName, dur);
|
|
3202
|
+
detail(e && e.stack ? e.stack : String(e));
|
|
3219
3203
|
failed++;
|
|
3220
3204
|
}
|
|
3221
3205
|
}
|
|
3222
3206
|
|
|
3223
3207
|
console.log('');
|
|
3224
3208
|
const suiteMs = Date.now() - suiteStart;
|
|
3225
|
-
|
|
3209
|
+
info(`Total elapsed: ${suiteMs} ms (${(suiteMs / 1000).toFixed(2)} s)`);
|
|
3226
3210
|
|
|
3227
3211
|
if (failed === 0) {
|
|
3228
|
-
|
|
3212
|
+
info(`All API tests passed (${passed}/${cases.length})`);
|
|
3229
3213
|
process.exit(0);
|
|
3230
3214
|
} else {
|
|
3231
|
-
|
|
3215
|
+
info(`Some API tests failed (${passed}/${cases.length})`);
|
|
3232
3216
|
process.exit(1);
|
|
3233
3217
|
}
|
|
3234
3218
|
})();
|
package/test/builtins.test.js
CHANGED
|
@@ -2,23 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
const assert = require('node:assert/strict');
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
const C = TTY
|
|
7
|
-
? { g: '\x1b[32m', r: '\x1b[31m', y: '\x1b[33m', dim: '\x1b[2m', n: '\x1b[0m' }
|
|
8
|
-
: { g: '', r: '', y: '', dim: '', n: '' };
|
|
9
|
-
|
|
10
|
-
function ok(msg) {
|
|
11
|
-
console.log(`${C.g}OK ${C.n} ${msg}`);
|
|
12
|
-
}
|
|
13
|
-
function info(msg) {
|
|
14
|
-
console.log(`${C.y}==${C.n} ${msg}`);
|
|
15
|
-
}
|
|
16
|
-
function fail(msg) {
|
|
17
|
-
console.error(`${C.r}FAIL${C.n} ${msg}`);
|
|
18
|
-
}
|
|
5
|
+
const { detail, failResult, info, pass } = require('./report');
|
|
19
6
|
|
|
20
7
|
const builtins = require('../lib/builtins');
|
|
21
8
|
require('../lib/engine');
|
|
9
|
+
const { reason } = require('../index');
|
|
22
10
|
|
|
23
11
|
const expectedApiKeys = [
|
|
24
12
|
'registerBuiltin',
|
|
@@ -61,7 +49,7 @@ const expectedTermsKeys = [
|
|
|
61
49
|
'Rule',
|
|
62
50
|
].sort();
|
|
63
51
|
|
|
64
|
-
const expectedNsKeys = ['RDF_NS', 'XSD_NS', 'CRYPTO_NS', 'MATH_NS', 'TIME_NS', 'LIST_NS', 'LOG_NS', 'STRING_NS'].sort();
|
|
52
|
+
const expectedNsKeys = ['RDF_NS', 'XSD_NS', 'CRYPTO_NS', 'MATH_NS', 'TIME_NS', 'LIST_NS', 'LOG_NS', 'STRING_NS', 'DT_NS'].sort();
|
|
65
53
|
|
|
66
54
|
function makeOkMapModule() {
|
|
67
55
|
return {
|
|
@@ -97,6 +85,11 @@ function makeBadExportModule() {
|
|
|
97
85
|
return 42;
|
|
98
86
|
}
|
|
99
87
|
|
|
88
|
+
|
|
89
|
+
function runReason(input) {
|
|
90
|
+
return reason({ proof: false }, input);
|
|
91
|
+
}
|
|
92
|
+
|
|
100
93
|
const cases = [
|
|
101
94
|
{
|
|
102
95
|
name: 'builtin helper API stays stable and frozen',
|
|
@@ -157,6 +150,60 @@ const cases = [
|
|
|
157
150
|
);
|
|
158
151
|
},
|
|
159
152
|
},
|
|
153
|
+
|
|
154
|
+
{
|
|
155
|
+
name: 'datatype builtins inspect literals, validate XSD value spaces, compare values, and canonicalize',
|
|
156
|
+
run() {
|
|
157
|
+
const out = runReason(`
|
|
158
|
+
@prefix : <http://example.org/datatype-tests#> .
|
|
159
|
+
@prefix dt: <https://eyereasoner.github.io/eyeling/datatype#> .
|
|
160
|
+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
|
161
|
+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
|
|
162
|
+
|
|
163
|
+
{ "01"^^xsd:integer dt:datatype ?d . } => { :integer :datatype ?d } .
|
|
164
|
+
{ "001"^^xsd:integer dt:lexicalForm ?lex . } => { :integer :lexicalForm ?lex } .
|
|
165
|
+
{ "hello"@en dt:language ?lang . } => { :language :tag ?lang } .
|
|
166
|
+
{ "plain" dt:datatype ?d . } => { :plain :datatype ?d } .
|
|
167
|
+
{ "hello"@EN dt:datatype ?d . } => { :langString :datatype ?d } .
|
|
168
|
+
|
|
169
|
+
{ "1"^^xsd:integer dt:validForDatatype xsd:integer . } => { :valid :integer true } .
|
|
170
|
+
{ "2147483648"^^xsd:int dt:invalidForDatatype xsd:int . } => { :invalid :int true } .
|
|
171
|
+
{ "2"^^xsd:boolean dt:invalidForDatatype xsd:boolean . } => { :invalid :boolean true } .
|
|
172
|
+
{ "2026-02-31T00:00:00Z"^^xsd:dateTime dt:invalidForDatatype xsd:dateTime . } => { :invalid :dateTime true } .
|
|
173
|
+
|
|
174
|
+
{ "01"^^xsd:integer dt:sameValueAs "1.0"^^xsd:decimal . } => { :same :numeric true } .
|
|
175
|
+
{ "true"^^xsd:boolean dt:sameValueAs "1"^^xsd:boolean . } => { :same :boolean true } .
|
|
176
|
+
{ "2026-06-10T12:00:00Z"^^xsd:dateTime dt:sameValueAs "2026-06-10T14:00:00+02:00"^^xsd:dateTime . } => { :same :dateTime true } .
|
|
177
|
+
{ "AQID"^^xsd:base64Binary dt:sameValueAs "010203"^^xsd:hexBinary . } => { :same :binary true } .
|
|
178
|
+
{ "11"^^xsd:integer dt:differentValueFrom "12"^^xsd:integer . } => { :different :numeric true } .
|
|
179
|
+
|
|
180
|
+
{ "01"^^xsd:integer dt:canonicalLiteral ?ci . } => { :canonical :integer ?ci } .
|
|
181
|
+
{ "1"^^xsd:boolean dt:canonicalLiteral ?cb . } => { :canonical :boolean ?cb } .
|
|
182
|
+
{ " a\t b "^^xsd:token dt:canonicalLiteral ?ct . } => { :canonical :token ?ct } .
|
|
183
|
+
{ "2026-06-10T14:00:00+02:00"^^xsd:dateTime dt:canonicalLiteral ?cd . } => { :canonical :dateTime ?cd } .
|
|
184
|
+
`);
|
|
185
|
+
|
|
186
|
+
assert.match(out, /:integer :datatype xsd:integer \./);
|
|
187
|
+
assert.match(out, /:integer :lexicalForm "001" \./);
|
|
188
|
+
assert.match(out, /:language :tag "en" \./);
|
|
189
|
+
assert.match(out, /:plain :datatype xsd:string \./);
|
|
190
|
+
assert.match(out, /:langString :datatype rdf:langString \./);
|
|
191
|
+
assert.match(out, /:valid :integer true \./);
|
|
192
|
+
assert.match(out, /:invalid :int true \./);
|
|
193
|
+
assert.match(out, /:invalid :boolean true \./);
|
|
194
|
+
assert.match(out, /:invalid :dateTime true \./);
|
|
195
|
+
assert.match(out, /:same :numeric true \./);
|
|
196
|
+
assert.match(out, /:same :boolean true \./);
|
|
197
|
+
assert.match(out, /:same :dateTime true \./);
|
|
198
|
+
assert.match(out, /:same :binary true \./);
|
|
199
|
+
assert.match(out, /:different :numeric true \./);
|
|
200
|
+
assert.match(out, /:canonical :integer "1"\^\^xsd:integer \./);
|
|
201
|
+
assert.match(out, /:canonical :boolean true \./);
|
|
202
|
+
assert.match(out, /:canonical :token "a b"\^\^xsd:token \./);
|
|
203
|
+
assert.match(out, /:canonical :dateTime "2026-06-10T12:00:00Z"\^\^xsd:dateTime \./);
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
|
|
160
207
|
];
|
|
161
208
|
|
|
162
209
|
let passed = 0;
|
|
@@ -166,25 +213,25 @@ let failed = 0;
|
|
|
166
213
|
const suiteStart = Date.now();
|
|
167
214
|
info(`Running ${cases.length} builtin contract tests`);
|
|
168
215
|
|
|
169
|
-
for (const tc of cases) {
|
|
216
|
+
for (const [index, tc] of cases.entries()) {
|
|
170
217
|
const start = Date.now();
|
|
171
218
|
try {
|
|
172
219
|
tc.run();
|
|
173
|
-
|
|
220
|
+
pass(index + 1, tc.name, Date.now() - start);
|
|
174
221
|
passed++;
|
|
175
222
|
} catch (e) {
|
|
176
|
-
|
|
177
|
-
|
|
223
|
+
failResult(index + 1, tc.name, Date.now() - start);
|
|
224
|
+
detail(e && e.stack ? e.stack : String(e));
|
|
178
225
|
failed++;
|
|
179
226
|
}
|
|
180
227
|
}
|
|
181
228
|
|
|
182
229
|
console.log('');
|
|
183
|
-
|
|
230
|
+
info(`Total elapsed: ${Date.now() - suiteStart} ms`);
|
|
184
231
|
if (failed === 0) {
|
|
185
|
-
|
|
232
|
+
info(`All builtin contract tests passed (${passed}/${cases.length})`);
|
|
186
233
|
process.exit(0);
|
|
187
234
|
}
|
|
188
|
-
|
|
235
|
+
info(`Some builtin contract tests failed (${passed}/${cases.length})`);
|
|
189
236
|
process.exit(1);
|
|
190
237
|
})();
|
package/test/examples.test.js
CHANGED
|
@@ -6,21 +6,7 @@ const os = require('node:os');
|
|
|
6
6
|
const path = require('node:path');
|
|
7
7
|
const cp = require('node:child_process');
|
|
8
8
|
|
|
9
|
-
const
|
|
10
|
-
const C = TTY
|
|
11
|
-
? { g: '\x1b[32m', r: '\x1b[31m', y: '\x1b[33m', dim: '\x1b[2m', n: '\x1b[0m' }
|
|
12
|
-
: { g: '', r: '', y: '', dim: '', n: '' };
|
|
13
|
-
const msTag = (ms) => `${C.dim}(${ms} ms)${C.n}`;
|
|
14
|
-
|
|
15
|
-
function ok(msg) {
|
|
16
|
-
console.log(`${C.g}OK${C.n} ${msg}`);
|
|
17
|
-
}
|
|
18
|
-
function fail(msg) {
|
|
19
|
-
console.error(`${C.r}FAIL${C.n} ${msg}`);
|
|
20
|
-
}
|
|
21
|
-
function info(msg) {
|
|
22
|
-
console.log(`${C.y}==${C.n} ${msg}`);
|
|
23
|
-
}
|
|
9
|
+
const { C, detail, failResult, info, pass } = require('./report');
|
|
24
10
|
|
|
25
11
|
function run(cmd, args, opts = {}) {
|
|
26
12
|
return cp.spawnSync(cmd, args, {
|
|
@@ -224,11 +210,11 @@ function main() {
|
|
|
224
210
|
const nodePath = process.execPath;
|
|
225
211
|
|
|
226
212
|
if (!fs.existsSync(examplesDir)) {
|
|
227
|
-
|
|
213
|
+
failResult(1, `Cannot find examples directory: ${examplesDir}`, 0);
|
|
228
214
|
process.exit(1);
|
|
229
215
|
}
|
|
230
216
|
if (!fs.existsSync(eyelingJsPath)) {
|
|
231
|
-
|
|
217
|
+
failResult(1, `Cannot find eyeling.js: ${eyelingJsPath}`, 0);
|
|
232
218
|
process.exit(1);
|
|
233
219
|
}
|
|
234
220
|
|
|
@@ -252,21 +238,19 @@ function main() {
|
|
|
252
238
|
console.log(`${C.dim}${getEyelingVersion(nodePath, eyelingJsPath, root)}; node ${process.version}${C.n}`);
|
|
253
239
|
|
|
254
240
|
if (totalTests === 0) {
|
|
255
|
-
|
|
241
|
+
info(proofOnly ? 'No proof goldens found in examples/proof/' : 'No .n3 files found in examples/');
|
|
256
242
|
process.exit(0);
|
|
257
243
|
}
|
|
258
244
|
|
|
259
245
|
let passed = 0;
|
|
260
246
|
let failed = 0;
|
|
261
247
|
|
|
262
|
-
|
|
263
|
-
const idxWidth = String(files.length).length;
|
|
264
|
-
const proofIdxWidth = String(Math.max(proofFiles.length, 1)).length;
|
|
265
|
-
const proofLabel = proofOnly ? '' : 'proof ';
|
|
248
|
+
let sequence = 0;
|
|
266
249
|
|
|
267
250
|
for (let i = 0; i < files.length; i++) {
|
|
268
|
-
const
|
|
251
|
+
const testNr = ++sequence;
|
|
269
252
|
const file = files[i];
|
|
253
|
+
const testName = file;
|
|
270
254
|
|
|
271
255
|
const start = Date.now();
|
|
272
256
|
|
|
@@ -278,8 +262,8 @@ function main() {
|
|
|
278
262
|
n3Text = fs.readFileSync(filePath, 'utf8');
|
|
279
263
|
} catch (e) {
|
|
280
264
|
const ms = Date.now() - start;
|
|
281
|
-
|
|
282
|
-
|
|
265
|
+
failResult(testNr, testName, ms);
|
|
266
|
+
detail(`Cannot read input: ${e.message}`);
|
|
283
267
|
failed++;
|
|
284
268
|
continue;
|
|
285
269
|
}
|
|
@@ -291,8 +275,8 @@ function main() {
|
|
|
291
275
|
// comparable across environments.
|
|
292
276
|
if (!fs.existsSync(expectedPath)) {
|
|
293
277
|
const ms = Date.now() - start;
|
|
294
|
-
|
|
295
|
-
|
|
278
|
+
failResult(testNr, testName, ms);
|
|
279
|
+
detail(`Missing expected output for ${path.basename(file, path.extname(file))}.*`);
|
|
296
280
|
failed++;
|
|
297
281
|
continue;
|
|
298
282
|
}
|
|
@@ -324,18 +308,18 @@ function main() {
|
|
|
324
308
|
|
|
325
309
|
if (diffOk && rcOk) {
|
|
326
310
|
if (expectedRc === 0) {
|
|
327
|
-
|
|
311
|
+
pass(testNr, testName, ms);
|
|
328
312
|
} else {
|
|
329
|
-
|
|
313
|
+
pass(testNr, `${testName} (expected exit ${expectedRc})`, ms);
|
|
330
314
|
}
|
|
331
315
|
passed++;
|
|
332
316
|
} else {
|
|
333
|
-
|
|
317
|
+
failResult(testNr, testName, ms);
|
|
334
318
|
if (!rcOk) {
|
|
335
|
-
|
|
319
|
+
detail(`Exit code ${rc}, expected ${expectedRc}`);
|
|
336
320
|
}
|
|
337
321
|
if (!diffOk) {
|
|
338
|
-
|
|
322
|
+
detail('Output differs');
|
|
339
323
|
}
|
|
340
324
|
|
|
341
325
|
// Show diffs, because this is a test runner
|
|
@@ -353,8 +337,9 @@ function main() {
|
|
|
353
337
|
|
|
354
338
|
|
|
355
339
|
for (let i = 0; i < proofFiles.length; i++) {
|
|
356
|
-
const
|
|
340
|
+
const testNr = ++sequence;
|
|
357
341
|
const file = proofFiles[i];
|
|
342
|
+
const testName = proofOnly ? file : `proof ${file}`;
|
|
358
343
|
const start = Date.now();
|
|
359
344
|
const filePath = path.join(examplesDir, file);
|
|
360
345
|
const expectedPath = path.join(proofDir, file);
|
|
@@ -364,8 +349,8 @@ function main() {
|
|
|
364
349
|
n3Text = fs.readFileSync(filePath, 'utf8');
|
|
365
350
|
} catch (e) {
|
|
366
351
|
const ms = Date.now() - start;
|
|
367
|
-
|
|
368
|
-
|
|
352
|
+
failResult(testNr, testName, ms);
|
|
353
|
+
detail(`Cannot read proof input: ${e.message}`);
|
|
369
354
|
failed++;
|
|
370
355
|
continue;
|
|
371
356
|
}
|
|
@@ -388,18 +373,18 @@ function main() {
|
|
|
388
373
|
|
|
389
374
|
if (diffOk && rcOk) {
|
|
390
375
|
if (expectedRc === 0) {
|
|
391
|
-
|
|
376
|
+
pass(testNr, testName, ms);
|
|
392
377
|
} else {
|
|
393
|
-
|
|
378
|
+
pass(testNr, `${testName} (expected exit ${expectedRc})`, ms);
|
|
394
379
|
}
|
|
395
380
|
passed++;
|
|
396
381
|
} else {
|
|
397
|
-
|
|
382
|
+
failResult(testNr, testName, ms);
|
|
398
383
|
if (!rcOk) {
|
|
399
|
-
|
|
384
|
+
detail(`Exit code ${rc}, expected ${expectedRc}`);
|
|
400
385
|
}
|
|
401
386
|
if (!diffOk) {
|
|
402
|
-
|
|
387
|
+
detail('Proof output differs');
|
|
403
388
|
}
|
|
404
389
|
showDiff({
|
|
405
390
|
examplesDir,
|
|
@@ -417,12 +402,12 @@ function main() {
|
|
|
417
402
|
info(`Total elapsed: ${suiteMs} ms (${(suiteMs / 1000).toFixed(2)} s)`);
|
|
418
403
|
|
|
419
404
|
if (failed === 0) {
|
|
420
|
-
|
|
405
|
+
info(proofOnly
|
|
421
406
|
? `All proof golden tests passed (${passed}/${totalTests})`
|
|
422
407
|
: `All examples tests passed (${passed}/${totalTests})`);
|
|
423
408
|
process.exit(0);
|
|
424
409
|
} else {
|
|
425
|
-
|
|
410
|
+
info(proofOnly
|
|
426
411
|
? `Some proof golden tests failed (${passed}/${totalTests})`
|
|
427
412
|
: `Some examples tests failed (${passed}/${totalTests})`);
|
|
428
413
|
// keep exit code 2 (matches historical behavior of examples/test)
|
package/test/extra.test.js
CHANGED
|
@@ -5,21 +5,7 @@ const fs = require('node:fs');
|
|
|
5
5
|
const path = require('node:path');
|
|
6
6
|
const cp = require('node:child_process');
|
|
7
7
|
|
|
8
|
-
const
|
|
9
|
-
const C = TTY
|
|
10
|
-
? { g: '\x1b[32m', r: '\x1b[31m', y: '\x1b[33m', dim: '\x1b[2m', n: '\x1b[0m' }
|
|
11
|
-
: { g: '', r: '', y: '', dim: '', n: '' };
|
|
12
|
-
const msTag = (ms) => `${C.dim}(${ms} ms)${C.n}`;
|
|
13
|
-
|
|
14
|
-
function ok(msg) {
|
|
15
|
-
console.log(`${C.g}OK${C.n} ${msg}`);
|
|
16
|
-
}
|
|
17
|
-
function fail(msg) {
|
|
18
|
-
console.error(`${C.r}FAIL${C.n} ${msg}`);
|
|
19
|
-
}
|
|
20
|
-
function info(msg) {
|
|
21
|
-
console.log(`${C.y}==${C.n} ${msg}`);
|
|
22
|
-
}
|
|
8
|
+
const { C, detail, failResult, info, pass } = require('./report');
|
|
23
9
|
|
|
24
10
|
function main() {
|
|
25
11
|
const suiteStart = Date.now();
|
|
@@ -29,7 +15,7 @@ function main() {
|
|
|
29
15
|
const nodePath = process.execPath;
|
|
30
16
|
|
|
31
17
|
if (!fs.existsSync(extraDir)) {
|
|
32
|
-
|
|
18
|
+
failResult(1, `Cannot find examples/extra directory: ${extraDir}`, 0);
|
|
33
19
|
process.exit(1);
|
|
34
20
|
}
|
|
35
21
|
|
|
@@ -44,16 +30,14 @@ function main() {
|
|
|
44
30
|
console.log(`${C.dim}node ${process.version}${C.n}`);
|
|
45
31
|
|
|
46
32
|
if (files.length === 0) {
|
|
47
|
-
|
|
33
|
+
info('No .js files found in examples/extra/');
|
|
48
34
|
process.exit(0);
|
|
49
35
|
}
|
|
50
36
|
|
|
51
37
|
let passed = 0;
|
|
52
38
|
let failed = 0;
|
|
53
|
-
const idxWidth = String(files.length).length;
|
|
54
|
-
|
|
55
39
|
for (let i = 0; i < files.length; i += 1) {
|
|
56
|
-
const
|
|
40
|
+
const testNr = i + 1;
|
|
57
41
|
const file = files[i];
|
|
58
42
|
const start = Date.now();
|
|
59
43
|
|
|
@@ -74,11 +58,11 @@ function main() {
|
|
|
74
58
|
const ms = Date.now() - start;
|
|
75
59
|
|
|
76
60
|
if (rc === 0) {
|
|
77
|
-
|
|
61
|
+
pass(testNr, `${file} -> output/${path.basename(outputPath)}`, ms);
|
|
78
62
|
passed += 1;
|
|
79
63
|
} else {
|
|
80
|
-
|
|
81
|
-
|
|
64
|
+
failResult(testNr, file, ms);
|
|
65
|
+
detail(`Exit code ${rc}`);
|
|
82
66
|
if (r.stderr) process.stderr.write(r.stderr);
|
|
83
67
|
failed += 1;
|
|
84
68
|
}
|
|
@@ -89,11 +73,11 @@ function main() {
|
|
|
89
73
|
info(`Total elapsed: ${suiteMs} ms (${(suiteMs / 1000).toFixed(2)} s)`);
|
|
90
74
|
|
|
91
75
|
if (failed === 0) {
|
|
92
|
-
|
|
76
|
+
info(`All extra examples passed (${passed}/${files.length})`);
|
|
93
77
|
process.exit(0);
|
|
94
78
|
}
|
|
95
79
|
|
|
96
|
-
|
|
80
|
+
info(`Some extra examples failed (${passed}/${files.length})`);
|
|
97
81
|
process.exit(2);
|
|
98
82
|
}
|
|
99
83
|
|
package/test/manifest.test.js
CHANGED
|
@@ -25,21 +25,7 @@ const cp = require('node:child_process');
|
|
|
25
25
|
|
|
26
26
|
const ROOT = path.resolve(__dirname, '..');
|
|
27
27
|
|
|
28
|
-
const
|
|
29
|
-
const C = TTY
|
|
30
|
-
? { g: '\x1b[32m', r: '\x1b[31m', y: '\x1b[33m', dim: '\x1b[2m', n: '\x1b[0m' }
|
|
31
|
-
: { g: '', r: '', y: '', dim: '', n: '' };
|
|
32
|
-
|
|
33
|
-
function ok(msg) {
|
|
34
|
-
console.log(`${C.g}OK${C.n} ${msg}`);
|
|
35
|
-
}
|
|
36
|
-
function warn(msg) {
|
|
37
|
-
console.log(`${C.y}SKIP${C.n} ${msg}`);
|
|
38
|
-
}
|
|
39
|
-
function fail(msg) {
|
|
40
|
-
console.error(`${C.r}FAIL${C.n} ${msg}`);
|
|
41
|
-
process.exitCode = 1;
|
|
42
|
-
}
|
|
28
|
+
const { C, failResult, pass, warn } = require('./report');
|
|
43
29
|
|
|
44
30
|
function run(cmd, args, opts = {}) {
|
|
45
31
|
const t0 = Date.now();
|
|
@@ -70,17 +56,20 @@ function rmrf(p) {
|
|
|
70
56
|
}
|
|
71
57
|
|
|
72
58
|
(async function main() {
|
|
59
|
+
let sequence = 0;
|
|
73
60
|
if (process.env.CI && process.env.EYELING_RUN_NOTATION3TESTS !== '1') {
|
|
74
61
|
warn('CI detected; set EYELING_RUN_NOTATION3TESTS=1 to run Notation3 tests');
|
|
75
62
|
return;
|
|
76
63
|
}
|
|
77
64
|
|
|
78
65
|
if (!has('git')) {
|
|
79
|
-
|
|
66
|
+
failResult(++sequence, 'git not found in PATH', 0);
|
|
67
|
+
process.exitCode = 1;
|
|
80
68
|
return;
|
|
81
69
|
}
|
|
82
70
|
if (!has('npm')) {
|
|
83
|
-
|
|
71
|
+
failResult(++sequence, 'npm not found in PATH', 0);
|
|
72
|
+
process.exitCode = 1;
|
|
84
73
|
return;
|
|
85
74
|
}
|
|
86
75
|
|
|
@@ -94,11 +83,12 @@ function rmrf(p) {
|
|
|
94
83
|
// 1) Clone suite
|
|
95
84
|
let r = run('git', ['clone', '--depth', '1', 'https://codeberg.org/phochste/notation3tests', suiteDir]);
|
|
96
85
|
if (r.status !== 0) {
|
|
97
|
-
|
|
86
|
+
failResult(++sequence, `git clone failed (exit ${r.status})`, r.ms);
|
|
87
|
+
process.exitCode = 1;
|
|
98
88
|
rmrf(workDir);
|
|
99
89
|
return;
|
|
100
90
|
}
|
|
101
|
-
|
|
91
|
+
pass(++sequence, 'cloned notation3tests', r.ms);
|
|
102
92
|
|
|
103
93
|
// 2) Install suite dependencies
|
|
104
94
|
// Notation3tests can carry vulnerabilities in its transient dependency tree.
|
|
@@ -106,11 +96,12 @@ function rmrf(p) {
|
|
|
106
96
|
// Disable audit/funding output for this integration test install.
|
|
107
97
|
r = run('npm', ['ci', '--audit=false', '--fund=false'], { cwd: suiteDir });
|
|
108
98
|
if (r.status !== 0) {
|
|
109
|
-
|
|
99
|
+
failResult(++sequence, `npm ci failed (exit ${r.status})`, r.ms);
|
|
100
|
+
process.exitCode = 1;
|
|
110
101
|
rmrf(workDir);
|
|
111
102
|
return;
|
|
112
103
|
}
|
|
113
|
-
|
|
104
|
+
pass(++sequence, 'npm ci', r.ms);
|
|
114
105
|
|
|
115
106
|
// 3) Pack local Eyeling
|
|
116
107
|
const pack = runCapture('npm', ['pack', '--silent'], {
|
|
@@ -120,29 +111,32 @@ function rmrf(p) {
|
|
|
120
111
|
});
|
|
121
112
|
if (pack.status !== 0) {
|
|
122
113
|
console.error(pack.stderr || '');
|
|
123
|
-
|
|
114
|
+
failResult(++sequence, `npm pack failed (exit ${pack.status})`, pack.ms);
|
|
115
|
+
process.exitCode = 1;
|
|
124
116
|
rmrf(workDir);
|
|
125
117
|
return;
|
|
126
118
|
}
|
|
127
119
|
const tgzName = String(pack.stdout).trim().split(/\r?\n/).pop();
|
|
128
120
|
const tgzPath = path.join(ROOT, tgzName);
|
|
129
121
|
if (!fs.existsSync(tgzPath)) {
|
|
130
|
-
|
|
122
|
+
failResult(++sequence, `npm pack did not produce expected tarball: ${tgzPath}`, pack.ms);
|
|
123
|
+
process.exitCode = 1;
|
|
131
124
|
rmrf(workDir);
|
|
132
125
|
return;
|
|
133
126
|
}
|
|
134
|
-
|
|
127
|
+
pass(++sequence, `packed ${tgzName}`, pack.ms);
|
|
135
128
|
|
|
136
129
|
// 4) Install local tarball into suite
|
|
137
130
|
// Keep the install output focused on the actual test run.
|
|
138
131
|
r = run('npm', ['install', '--no-save', '--audit=false', '--fund=false', tgzPath], { cwd: suiteDir });
|
|
139
132
|
if (r.status !== 0) {
|
|
140
|
-
|
|
133
|
+
failResult(++sequence, `npm install eyeling tarball failed (exit ${r.status})`, r.ms);
|
|
134
|
+
process.exitCode = 1;
|
|
141
135
|
rmrf(tgzPath);
|
|
142
136
|
rmrf(workDir);
|
|
143
137
|
return;
|
|
144
138
|
}
|
|
145
|
-
|
|
139
|
+
pass(++sequence, 'installed local eyeling', r.ms);
|
|
146
140
|
|
|
147
141
|
// 5) Run suite test target
|
|
148
142
|
const t0 = Date.now();
|
|
@@ -153,7 +147,7 @@ function rmrf(p) {
|
|
|
153
147
|
rmrf(tgzPath);
|
|
154
148
|
|
|
155
149
|
if (r.status === 0) {
|
|
156
|
-
|
|
150
|
+
pass(++sequence, 'notation3tests:eyeling passed', totalMs);
|
|
157
151
|
if (process.env.EYELING_KEEP_NOTATION3TESTS === '1') {
|
|
158
152
|
console.log(`${C.dim}Keeping workdir (EYELING_KEEP_NOTATION3TESTS=1):${C.n} ${workDir}`);
|
|
159
153
|
} else {
|
|
@@ -162,7 +156,8 @@ function rmrf(p) {
|
|
|
162
156
|
return;
|
|
163
157
|
}
|
|
164
158
|
|
|
165
|
-
|
|
159
|
+
failResult(++sequence, `notation3tests:eyeling failed (exit ${r.status})`, totalMs);
|
|
160
|
+
process.exitCode = 1;
|
|
166
161
|
if (process.env.EYELING_KEEP_NOTATION3TESTS === '1') {
|
|
167
162
|
console.log(`${C.dim}Keeping workdir (EYELING_KEEP_NOTATION3TESTS=1):${C.n} ${workDir}`);
|
|
168
163
|
} else {
|