forked from cqframework/cql-tests-runner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
loadTests.js
37 lines (31 loc) · 865 Bytes
/
loadTests.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const fs = require('fs');
const path = require('path');
const { XMLParser } = require('fast-xml-parser');
// Load tests
const testsPath = 'cql-tests/tests/cql';
const alwaysArray = [
"tests.group",
"tests.group.test"
];
const options = {
ignoreAttributes : false,
attributeNamePrefix : '',
parseTagValue : false,
isArray: (name, jpath, isLeafNode, isAttribute) => {
if (alwaysArray.indexOf(jpath) !== -1) return true;
},
textNodeName : 'text'
};
const parser = new XMLParser(options);
function load() {
const tests = [];
fs.readdirSync(testsPath).forEach(file => {
console.log('Loading tests from ' + file);
let testsContainer = parser.parse(fs.readFileSync(path.join(testsPath, file)));
tests.push(testsContainer.tests);
});
return tests;
}
module.exports = {
load
}