From a9c71d6ec29048e1555ab79a507c4784f46da109 Mon Sep 17 00:00:00 2001 From: Ben De Meester Date: Mon, 25 Feb 2019 14:26:41 +0100 Subject: [PATCH] updated test --- dist/n3unit.pvm | Bin 1142114 -> 1142114 bytes reports/validatrr-rdfcv-earl.ttl | 72 ++++++++++++++++++++ test/ConstraintTypesTestSpec.js | 113 +++++++++++++++++++++++++++++++ 3 files changed, 185 insertions(+) create mode 100644 test/ConstraintTypesTestSpec.js diff --git a/dist/n3unit.pvm b/dist/n3unit.pvm index e751fdb880ef2f727865404167f8df37da8d7a1b..6180e01b1d4676b175593cbe05a0afc4dfdd577f 100644 GIT binary patch delta 126 zcmaEK%k|MM*M=6x7N!>F7M2#)Eo?PjY=#B~7G@^Xo4nX=LfP$!-fTe3zCF>Kasn|I5OV`D4-oSLF&_}~ N1F^vNc3r{S_5l6jE6V@? delta 126 zcmaEK%k|MM*M=6x7N!>F7M2#)Eo?PjYzCGFhDK)7o4nX=LfP$!-fTe3zCF>K{7fScD=^Nj3NVK=>asn|I5OV`D4-oSLF&_}~ N1F^vNc3r{S_5kk1D|-L{ diff --git a/reports/validatrr-rdfcv-earl.ttl b/reports/validatrr-rdfcv-earl.ttl index 75094ed..614bf5f 100644 --- a/reports/validatrr-rdfcv-earl.ttl +++ b/reports/validatrr-rdfcv-earl.ttl @@ -369,6 +369,46 @@ earl:test ] . +[ a earl:Assertion ; + earl:assertedBy ; + earl:result [ a earl:TestResult ; + earl:mode earl:automatic ; + earl:outcome earl:passed + ] ; + earl:subject ; + earl:test +] . + +[ a earl:Assertion ; + earl:assertedBy ; + earl:result [ a earl:TestResult ; + earl:mode earl:automatic ; + earl:outcome earl:passed + ] ; + earl:subject ; + earl:test +] . + +[ a earl:Assertion ; + earl:assertedBy ; + earl:result [ a earl:TestResult ; + earl:mode earl:automatic ; + earl:outcome earl:passed + ] ; + earl:subject ; + earl:test +] . + +[ a earl:Assertion ; + earl:assertedBy ; + earl:result [ a earl:TestResult ; + earl:mode earl:automatic ; + earl:outcome earl:passed + ] ; + earl:subject ; + earl:test +] . + [ a earl:Assertion ; earl:assertedBy ; earl:result [ a earl:TestResult ; @@ -417,3 +457,35 @@ earl:subject ; earl:test ] . + +[ a earl:Assertion ; + earl:assertedBy ; + earl:result [ a earl:TestResult ; + earl:mode earl:automatic ; + earl:outcome earl:passed + ] ; + earl:subject ; + earl:test +] . + +[ a earl:Assertion ; + earl:assertedBy ; + earl:result [ a earl:TestResult ; + earl:mode earl:automatic ; + earl:outcome earl:passed + ] ; + earl:subject ; + earl:test +] . + +[ a earl:Assertion ; + earl:assertedBy ; + earl:result [ a earl:TestResult ; + earl:mode earl:automatic ; + earl:outcome earl:passed + ] ; + earl:subject ; + earl:test +] . + + diff --git a/test/ConstraintTypesTestSpec.js b/test/ConstraintTypesTestSpec.js new file mode 100644 index 0000000..c600db2 --- /dev/null +++ b/test/ConstraintTypesTestSpec.js @@ -0,0 +1,113 @@ +/* global describe, run */ + +const fs = require('fs'), + path = require('path'), + async = require('async'), + TestHelper = require('../lib/TestHelper'), + Validator = require('../lib/Validator'); + +describe('all rules', function () { + const basePath = path.resolve(__dirname, '../resources/rules'); + const bugFiles = []; + fs.readdir(basePath, function (err, files) { + async.forEachLimit(files, 4, function (file, done) { + fs.stat(path.resolve(basePath, file), function (err, stat) { + if (err) { + return done(err); + } + if (stat.isDirectory()) { + const rulePath = path.resolve(basePath, file); + try { + fs.statSync(path.resolve(rulePath, 'constraint.ttl')); + const validator = createValidator(path.resolve(rulePath, 'constraint.ttl')); + bugFiles.push({ + name: file, + file: path.resolve(rulePath, 'data.ttl'), + output: path.resolve(basePath, '../../tests/owl-rdfunit/output_wrong_1.ttl'), + validator + }); + } catch (e) { + // nothing + } + } + done(); + }); + }, function (err) { + if (err) { + throw err; + } + describe('rule test cases', function () { + TestHelper.walkFiles(bugFiles, function (inputFile, out) { + console.log(out); + // fs.writeFileSync(inputFile.replace(/input-(\d+).ttl$/, 'out-$1.ttl'), out, 'utf8'); + }); + }); + run(); + }); + }); +}); + +describe.only('A42', function () { + validate('A42_Optional_Properties', 'correct'); +}); + +describe.only('A43', function () { + validate('A43_Repeatable_Properties', 'wrong_1'); +}); + +describe.only('A44', function () { + validate('A44_Conditional_Properties', 'wrong_1'); +}); + +describe.only('A45', function () { + validate('A45_Recommended_Properties', 'wrong_1'); +}); + +describe.only('A78', function () { + validate('A78_Conjunction', 'wrong_1'); +}); + +describe.only('A79', function () { + validate('A79_Disjunction', 'wrong_1'); +}); + +describe.only('A80', function () { + validate('A80_Negation', 'wrong_1'); +}); + +describe.only('A81', function () { + validate('A81_Default_Values', 'correct'); +}); + + +function validate(name, output) { + const basePath = path.resolve(__dirname, '../resources/rules'); + const rulePath = path.resolve(basePath, name); + const validator = createValidator(path.resolve(rulePath, 'constraint.ttl')); + const bugFiles = []; + bugFiles.push({ + name: name, + file: path.resolve(rulePath, 'data.ttl'), + output: path.resolve(basePath, `../../tests/owl-rdfunit/output_${output}.ttl`), + validator + }); + TestHelper.walkFiles(bugFiles, function (inputFile, out) { + console.log(out); + // fs.writeFileSync(inputFile.replace(/input-(\d+).ttl$/, 'out-$1.ttl'), out, 'utf8'); + }); +} + +function createValidator(constraintPath) { + let basePath = path.resolve(__dirname, '..'); + + let distPath = path.resolve(basePath, 'dist', 'n3unit.pvm'); + let queryPath = path.resolve(basePath, 'resources', 'rules', 'query_count.n3'); + const logCodes = path.resolve(__dirname, '../resources/rml/logCodes.ttl'); // TODO configurable + + let validationOpts = { + queryPath, + extraFiles: [distPath, constraintPath, logCodes] + }; + + return new Validator(validationOpts); +}