Skip to content

Commit 41d432e

Browse files
committed
Update test skipping logic.
- Allow test type skipping by type, processingMode option, or description regex.
1 parent 8f2a092 commit 41d432e

File tree

1 file changed

+42
-10
lines changed

1 file changed

+42
-10
lines changed

tests/test.js

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -296,16 +296,6 @@ function addManifest(manifest) {
296296
}
297297

298298
function addTest(manifest, test) {
299-
// skip unknown and explicitly skipped test types
300-
var testTypes = Object.keys(TEST_TYPES);
301-
if(!isJsonLdType(test, testTypes) || isJsonLdType(test, SKIP_TESTS)) {
302-
var type = [].concat(
303-
getJsonLdValues(test, '@type'),
304-
getJsonLdValues(test, 'type')
305-
);
306-
console.log('Skipping test "' + test.name + '" of type: ' + type);
307-
}
308-
309299
// expand @id and input base
310300
var test_id = test['@id'] || test['id'];
311301
//var number = test_id.substr(2);
@@ -317,8 +307,50 @@ function addTest(manifest, test) {
317307
// get appropriate API and run test
318308
var api = _nodejs ? jsonld : jsonld.promises;
319309
it(description, function(done) {
310+
var self = this;
320311
this.timeout(5000);
321312
var testInfo = TEST_TYPES[getJsonLdTestType(test)];
313+
314+
// skip unknown and explicitly skipped test types
315+
var testTypes = Object.keys(TEST_TYPES);
316+
if(!isJsonLdType(test, testTypes) || isJsonLdType(test, SKIP_TESTS)) {
317+
var type = [].concat(
318+
getJsonLdValues(test, '@type'),
319+
getJsonLdValues(test, 'type')
320+
);
321+
//console.log('Skipping test "' + test.name + '" of type: ' + type);
322+
self.skip();
323+
}
324+
325+
if(testInfo.skip && testInfo.skip.type) {
326+
//console.log('Skipping test "' + test.name + '" of type: ' + type);
327+
self.skip();
328+
}
329+
330+
if(testInfo.skip && testInfo.skip.regex) {
331+
testInfo.skip.regex.forEach(function(re) {
332+
if(re.test(description)) {
333+
//console.log('Skipping test "' + test.name + '" of description: ' + description);
334+
self.skip();
335+
}
336+
});
337+
}
338+
339+
var options = getJsonLdValues(test, 'option');
340+
options.forEach(function(opt) {
341+
var processingModes = getJsonLdValues(opt, 'processingMode');
342+
processingModes.forEach(function(pm) {
343+
var skipModes = [];
344+
if(testInfo.skip && testInfo.skip.processingMode) {
345+
skipModes = testInfo.skip.processingMode;
346+
}
347+
if(skipModes.indexOf(pm) !== -1) {
348+
//console.log('Skipping test "' + test.name + '" of processing mode: ' + pm);
349+
self.skip();
350+
}
351+
});
352+
});
353+
322354
var fn = testInfo.fn;
323355
var params = testInfo.params;
324356
params = params.map(function(param) {return param(test);});

0 commit comments

Comments
 (0)