Add query running test for computeDefaultStrings flag
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
## [UNRELEASED]
|
||||
|
||||
- Fix bug when removing databases where sometimes the source folder would not be removed from the workspace or the database files would not be removed from the workspace storage location. [#692](https://github.com/github/vscode-codeql/pull/692)
|
||||
- Always pass the `computeDefaultStrings` flag to query compilation commands. This will change the output of some queries. [#694](https://github.com/github/vscode-codeql/pull/694)
|
||||
- Query results with no string representation will now be displayed with placeholder text in query results. Previously, they were omitted. [#694](https://github.com/github/vscode-codeql/pull/694)
|
||||
|
||||
## 1.3.7 - 24 November 2020
|
||||
|
||||
|
||||
@@ -13,9 +13,7 @@ import { ColumnValue } from '../../pure/bqrs-cli-types';
|
||||
import { FindDistributionResultKind } from '../../distribution';
|
||||
|
||||
|
||||
declare module 'url' {
|
||||
export function pathToFileURL(urlStr: string): Url;
|
||||
}
|
||||
const baseDir = path.join(__dirname, '../../../test/data');
|
||||
|
||||
const tmpDir = tmp.dirSync({ prefix: 'query_test_', keep: false, unsafeCleanup: true });
|
||||
|
||||
@@ -61,13 +59,19 @@ type QueryTestCase = {
|
||||
// Test cases: queries to run and their expected results.
|
||||
const queryTestCases: QueryTestCase[] = [
|
||||
{
|
||||
queryPath: path.join(__dirname, '../data/query.ql'),
|
||||
queryPath: path.join(baseDir, 'query.ql'),
|
||||
expectedResultSets: {
|
||||
'#select': [[42, 3.14159, 'hello world', true]]
|
||||
}
|
||||
},
|
||||
{
|
||||
queryPath: path.join(__dirname, '../data/multiple-result-sets.ql'),
|
||||
queryPath: path.join(baseDir, 'compute-default-strings.ql'),
|
||||
expectedResultSets: {
|
||||
'#select': [[{ label: '(no string representation)' }]]
|
||||
}
|
||||
},
|
||||
{
|
||||
queryPath: path.join(baseDir, 'multiple-result-sets.ql'),
|
||||
expectedResultSets: {
|
||||
'edges': [[1, 2], [2, 3]],
|
||||
'#select': [['s']]
|
||||
@@ -75,7 +79,7 @@ const queryTestCases: QueryTestCase[] = [
|
||||
}
|
||||
];
|
||||
|
||||
describe('using the query server', function() {
|
||||
describe.only('using the query server', function() {
|
||||
before(function() {
|
||||
if (process.env['CODEQL_PATH'] === undefined) {
|
||||
console.log('The environment variable CODEQL_PATH is not set. The query server tests, which require the CodeQL CLI, will be skipped.');
|
||||
@@ -92,12 +96,8 @@ describe('using the query server', function() {
|
||||
let cliServer: cli.CodeQLCliServer;
|
||||
const queryServerStarted = new Checkpoint<void>();
|
||||
after(() => {
|
||||
if (qs) {
|
||||
qs.dispose();
|
||||
}
|
||||
if (cliServer) {
|
||||
cliServer.dispose();
|
||||
}
|
||||
qs?.dispose();
|
||||
cliServer?.dispose();
|
||||
});
|
||||
|
||||
it('should be able to start the query server', async function() {
|
||||
@@ -156,7 +156,7 @@ describe('using the query server', function() {
|
||||
try {
|
||||
const qlProgram: messages.QlProgram = {
|
||||
libraryPath: [],
|
||||
dbschemePath: path.join(__dirname, '../data/test.dbscheme'),
|
||||
dbschemePath: path.join(baseDir, 'test.dbscheme'),
|
||||
queryPath: queryTestCase.queryPath
|
||||
};
|
||||
const params: messages.CompileQueryParams = {
|
||||
12
extensions/ql-vscode/test/data/compute-default-strings.ql
Normal file
12
extensions/ql-vscode/test/data/compute-default-strings.ql
Normal file
@@ -0,0 +1,12 @@
|
||||
// Test that computeDefaultStrings is set correctly.
|
||||
|
||||
newtype TUnit = MkUnit()
|
||||
|
||||
class Unit extends TUnit {
|
||||
Unit() { this = MkUnit() }
|
||||
|
||||
string toString() { none() }
|
||||
}
|
||||
|
||||
from Unit u
|
||||
select u
|
||||
@@ -47,11 +47,12 @@ describe('files', () => {
|
||||
});
|
||||
|
||||
it('should scan a directory', async () => {
|
||||
const singleFile = path.join(dataDir, 'query.ql');
|
||||
const otherFile = path.join(dataDir, 'multiple-result-sets.ql');
|
||||
const file1 = path.join(dataDir, 'compute-default-strings.ql');
|
||||
const file2 = path.join(dataDir, 'multiple-result-sets.ql');
|
||||
const file3 = path.join(dataDir, 'query.ql');
|
||||
|
||||
const result = await gatherQlFiles([dataDir]);
|
||||
expect(result.sort()).to.deep.equal([[otherFile, singleFile], true]);
|
||||
expect(result.sort()).to.deep.equal([[file1, file2, file3], true]);
|
||||
});
|
||||
|
||||
it('should scan a directory and some files', async () => {
|
||||
@@ -64,10 +65,12 @@ describe('files', () => {
|
||||
});
|
||||
|
||||
it('should avoid duplicates', async () => {
|
||||
const singleFile = path.join(dataDir, 'query.ql');
|
||||
const otherFile = path.join(dataDir, 'multiple-result-sets.ql');
|
||||
const file1 = path.join(dataDir, 'compute-default-strings.ql');
|
||||
const file2 = path.join(dataDir, 'multiple-result-sets.ql');
|
||||
const file3 = path.join(dataDir, 'query.ql');
|
||||
|
||||
const result = await gatherQlFiles([singleFile, dataDir, otherFile]);
|
||||
expect(result.sort()).to.deep.equal([[singleFile, otherFile], true]);
|
||||
const result = await gatherQlFiles([file1, dataDir, file3]);
|
||||
result[0].sort();
|
||||
expect(result.sort()).to.deep.equal([[file1, file2, file3], true]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user