Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion cql-tests-runner.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/node

const os = require('os');
const fs = require('fs');
const path = require('path');
const { format } = require('date-fns');
Expand Down Expand Up @@ -117,9 +118,11 @@ async function main() {
//const onlyTestName = "CeilingNeg1D1";

let results = [];
let groupResults = [];
for (const ts of tests) {
if (typeof onlyTestsName === 'undefined' || onlyTestsName === ts.name) {
console.log('Tests: ' + ts.name);
let groupTests = [];
for (const group of ts.group) {
if (typeof onlyGroupName === 'undefined' || onlyGroupName === group.name) {
console.log(' Group: ' + group.name);
Expand All @@ -128,7 +131,9 @@ async function main() {
for (const t of test) {
if (typeof onlyTestName === 'undefined' || onlyTestName === t.name) {
console.log(' Test: ' + t.name);
results.push(new Result(ts.name, group.name, t));
var r = new Result(ts.name, group.name, t);
results.push(r);
groupTests.push(r);
}
}
}
Expand All @@ -137,21 +142,56 @@ async function main() {
}
}
}
groupResults.push(groupTests);

if (quickTest) {
break; // Only load 1 test set for testing
}
}
}

for (let g of groupResults) {
await runGroupTest(g, apiUrl, x);
}

/*
for (let r of results) {
await runTest(r, apiUrl, x);
}
*/

logResults(results, outputPath);
};

main();

async function runGroupTest(group, apiUrl, cvl) {
var testsName = '';
var body = '';
for (let r of group) {
if (testsName === '') {
testsName = r.testsName;
}
// TODO: Build a separate library for invalid semantic tests?
if (r.invalid !== 'semantic') {
body += 'define "' + r.groupName + '.' + r.testName + '": ' + r.expression + os.EOL + os.EOL;
}
}

var body = 'library ' + testsName + os.EOL + os.EOL + body;

const cqlOutputPath = './cql';
if (!fs.existsSync(cqlOutputPath)) {
fs.mkdirSync(cqlOutputPath, { recursive: true });
}

const fileName = testsName + '.cql';
const filePath = path.join(cqlOutputPath, fileName);
fs.writeFileSync(filePath, body, (error) => {
if (error) throw error;
});
}

async function runTest(result, apiUrl, cvl) {
if (result.testStatus !== 'skip') {
const data = {
Expand Down
80 changes: 80 additions & 0 deletions cql/CqlAggregateFunctionsTest.cql
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
library CqlAggregateFunctionsTest

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Bryn--just a question: Do we need to actually check in these derived artifacts into the cql-tests-runner repo, or can these be generated on the fly by the runner as needed from the "canonical" test definition XML at runtime only?

I'm wondering checking this opens up the potential for accidental skew if one of these files is modified but the canonicial test definition isn't, or confusion for users on what's the canonical definition. That said if we have some kind of presubmit checking that can say if the cql-tests submodule commit is updated, then all of these files must be re-generated (e.g. run the tests to refresh this definition), that would help prevent this skew.

Either way, the real question I have is--what's the main benefit of including these? Perhaps the main benefit is for users to be able to inspect/debug the intermediate artifacts?

(note I don't feel strongly, just curious)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @suyashkumar , 100% agree, these shouldn't be committed, I only committed them because some of the engines wanted the XML/JSON serialization of the libraries, so this was a stopgap to support that


define "AllTrue.AllTrueAllTrue": AllTrue({true,true})

define "AllTrue.AllTrueTrueFirst": AllTrue({true,false})

define "AllTrue.AllTrueFalseFirst": AllTrue({false,true})

define "AllTrue.AllTrueAllTrueFalseTrue": AllTrue({true,false,true})

define "AllTrue.AllTrueAllFalseTrueFalse": AllTrue({false,true,false})

define "AllTrue.AllTrueNullFirst": AllTrue({null,true,true})

define "AllTrue.AllTrueEmptyList": AllTrue({})

define "AnyTrue.AnyTrueAllTrue": AnyTrue({true,true})

define "AnyTrue.AnyTrueAllFalse": AnyTrue({false,false})

define "AnyTrue.AnyTrueAllTrueFalseTrue": AnyTrue({true,false,true})

define "AnyTrue.AnyTrueAllFalseTrueFalse": AnyTrue({false,true,false})

define "AnyTrue.AnyTrueTrueFirst": AnyTrue({true,false})

define "AnyTrue.AnyTrueFalseFirst": AnyTrue({false,true})

define "AnyTrue.AnyTrueNullFirstThenTrue": AnyTrue({null,true})

define "AnyTrue.AnyTrueNullFirstThenFalse": AnyTrue({null,false})

define "AnyTrue.AnyTrueEmptyList": AnyTrue({})

define "Avg.AvgTest1": Avg({ 1.0, 2.0, 3.0, 6.0 })

define "Count.CountTest1": Count({ 15, 5, 99, null, 1 })

define "Count.CountTestDateTime": Count({ DateTime(2014), DateTime(2001), DateTime(2010) })

define "Count.CountTestTime": Count({ @T15:59:59.999, @T05:59:59.999, @T20:59:59.999 })

define "Count.CountTestNull": Count({})

define "Max.MaxTestInteger": Max({ 5, 12, 1, 15, 0, 4, 90, 44 })

define "Max.MaxTestString": Max({ 'hi', 'bye', 'zebra' })

define "Max.MaxTestDateTime": Max({ DateTime(2012, 10, 5), DateTime(2012, 9, 5), DateTime(2012, 10, 6) })

define "Max.MaxTestTime": Max({ @T15:59:59.999, @T05:59:59.999, @T20:59:59.999 })

define "Median.MedianTestDecimal": Median({6.0, 5.0, 4.0, 3.0, 2.0, 1.0})

define "Min.MinTestInteger": Min({5, 12, 1, 15, 0, 4, 90, 44})

define "Min.MinTestString": Min({'hi', 'bye', 'zebra'})

define "Min.MinTestDateTime": Min({ DateTime(2012, 10, 5), DateTime(2012, 9, 5), DateTime(2012, 10, 6) })

define "Min.MinTestTime": Min({ @T15:59:59.999, @T05:59:59.999, @T20:59:59.999 })

define "Mode.ModeTestInteger": Mode({ 2, 1, 8, 2, 9, 1, 9, 9 })

define "Mode.ModeTestDateTime": Mode({ DateTime(2012, 10, 5), DateTime(2012, 9, 5), DateTime(2012, 10, 6), DateTime(2012, 9, 5) })

define "Mode.ModeTestTime": Mode({ @T15:59:59.999, @T05:59:59.999, @T20:59:59.999, @T05:59:59.999 })

define "PopulationStdDev.PopStdDevTest1": PopulationStdDev({ 1.0, 2.0, 3.0, 4.0, 5.0 })

define "PopulationVariance.PopVarianceTest1": PopulationVariance({ 1.0, 2.0, 3.0, 4.0, 5.0 })

define "StdDev.StdDevTest1": StdDev({ 1.0, 2.0, 3.0, 4.0, 5.0 })

define "Sum.SumTest1": Sum({ 6.0, 2.0, 3.0, 4.0, 5.0 })

define "Sum.SumTestNull": Sum({ null, 1, null })

define "Variance.VarianceTest1": Variance({ 1.0, 2.0, 3.0, 4.0, 5.0 })

Loading