Skip to content

Commit

Permalink
Upgraded dependencies and adapting instrumentation to new ajv version…
Browse files Browse the repository at this point in the history
… (7). Making it a little simpler overall, but requiring a seperate code generation step before running the actual unit tests
  • Loading branch information
FrederikP committed Jan 5, 2021
1 parent 6ebe08a commit 1f4f90b
Show file tree
Hide file tree
Showing 7 changed files with 616 additions and 773 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ xarf_deref*.schema.json
.nyc_output
coverage
*.lcov
.ajv_istanbul
gen_validate_schema*.js
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,29 @@
"license": "MIT",
"scripts": {
"bundle-xarf": "node bundle_xarf.js",
"test-xarf": "nyc --reporter=lcov mocha test/test_xarf.js",
"report-coverage-codecov": "codecov",
"report-coverage-coveralls": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
"clean-coverage": "rm -rf .nyc_output .ajv_istanbul coverage"
"clean-coverage": "rm -rf .nyc_output coverage .generated_code",
"generate-code": "ajv compile -c ajv-formats -s xarf.schema.json -r 'schemas/**/*.schema.json' -o gen_validate_schema.js && js-beautify gen_validate_schema.js > gen_validate_schema_pretty.js",
"test-xarf": "yarn clean-coverage && yarn generate-code && nyc --reporter=lcov mocha test/test_xarf.js"
},
"dependencies": {
"@apidevtools/json-schema-ref-parser": "^9.0.1",
"jsonfile": "^6.0.1"
},
"devDependencies": {
"ajv": "^6.12.2",
"ajv": "^7.0.3",
"ajv-cli": "^4.0.1",
"ajv-formats": "^1.5.1",
"codecov": "^3.7.1",
"coveralls": "^3.1.0",
"eslint": "^7.0.0",
"eslint-plugin-mocha": "^7.0.0",
"eslint-plugin-mocha": "^8.0.0",
"husky": ">=4",
"istanbul-lib-instrument": "^4.0.3",
"js-beautify": "^1.11.0",
"js-beautify": "^1.13.0",
"lint-staged": ">=10",
"mocha": "^7.1.2",
"mocha": "^8.2.1",
"nyc": "^15.0.1",
"prettier": "2.0.5",
"prettier": "2.2.1",
"uuid": "^8.0.0"
},
"husky": {
Expand Down
32 changes: 6 additions & 26 deletions test/test_xarf.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
"use strict";
var validate;
try {
validate = require("../gen_validate_schema_pretty.js");
} catch (error) {
console.error("Did you run yarn generate-code?", error);
}

const Ajv = require("ajv");
const ajvIstanbul = require("../util/schema_instrumenter");
const assert = require("assert");

const path = require("path");
Expand All @@ -22,30 +26,6 @@ async function* getFiles(dir) {

describe("xarf", function () {
this.timeout(40000);
var validate;

before(function () {
console.log("Instrumenting schema code ...");
var ajv = new Ajv({ allErrors: true });
ajvIstanbul(ajv);
var rootSchema = require("../xarf.schema.json");

const schemaDir = "./schemas";
return new Promise((resolve) => {
(async () => {
for await (const f of getFiles(schemaDir)) {
if (f.endsWith(".schema.json")) {
//console.log(`Adding sub schema: ${f}`);
ajv.addSchema(require(f));
}
}
console.log("Compiling schema ...");
validate = ajv.compile(rootSchema);
console.log("Done instrumenting schema code ...");
resolve();
})();
});
});

it("all positive samples should validate", function () {
const samplesDir = "samples/positive";
Expand Down
21 changes: 0 additions & 21 deletions util/ajv-istanbul-LICENSE

This file was deleted.

44 changes: 0 additions & 44 deletions util/schema_instrumenter.js

This file was deleted.

Loading

0 comments on commit 1f4f90b

Please sign in to comment.