Add query running test for computeDefaultStrings flag
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
## [UNRELEASED]
|
## [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)
|
- 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
|
## 1.3.7 - 24 November 2020
|
||||||
|
|
||||||
|
|||||||
@@ -13,9 +13,7 @@ import { ColumnValue } from '../../pure/bqrs-cli-types';
|
|||||||
import { FindDistributionResultKind } from '../../distribution';
|
import { FindDistributionResultKind } from '../../distribution';
|
||||||
|
|
||||||
|
|
||||||
declare module 'url' {
|
const baseDir = path.join(__dirname, '../../../test/data');
|
||||||
export function pathToFileURL(urlStr: string): Url;
|
|
||||||
}
|
|
||||||
|
|
||||||
const tmpDir = tmp.dirSync({ prefix: 'query_test_', keep: false, unsafeCleanup: true });
|
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.
|
// Test cases: queries to run and their expected results.
|
||||||
const queryTestCases: QueryTestCase[] = [
|
const queryTestCases: QueryTestCase[] = [
|
||||||
{
|
{
|
||||||
queryPath: path.join(__dirname, '../data/query.ql'),
|
queryPath: path.join(baseDir, 'query.ql'),
|
||||||
expectedResultSets: {
|
expectedResultSets: {
|
||||||
'#select': [[42, 3.14159, 'hello world', true]]
|
'#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: {
|
expectedResultSets: {
|
||||||
'edges': [[1, 2], [2, 3]],
|
'edges': [[1, 2], [2, 3]],
|
||||||
'#select': [['s']]
|
'#select': [['s']]
|
||||||
@@ -75,7 +79,7 @@ const queryTestCases: QueryTestCase[] = [
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
describe('using the query server', function() {
|
describe.only('using the query server', function() {
|
||||||
before(function() {
|
before(function() {
|
||||||
if (process.env['CODEQL_PATH'] === undefined) {
|
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.');
|
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;
|
let cliServer: cli.CodeQLCliServer;
|
||||||
const queryServerStarted = new Checkpoint<void>();
|
const queryServerStarted = new Checkpoint<void>();
|
||||||
after(() => {
|
after(() => {
|
||||||
if (qs) {
|
qs?.dispose();
|
||||||
qs.dispose();
|
cliServer?.dispose();
|
||||||
}
|
|
||||||
if (cliServer) {
|
|
||||||
cliServer.dispose();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to start the query server', async function() {
|
it('should be able to start the query server', async function() {
|
||||||
@@ -156,7 +156,7 @@ describe('using the query server', function() {
|
|||||||
try {
|
try {
|
||||||
const qlProgram: messages.QlProgram = {
|
const qlProgram: messages.QlProgram = {
|
||||||
libraryPath: [],
|
libraryPath: [],
|
||||||
dbschemePath: path.join(__dirname, '../data/test.dbscheme'),
|
dbschemePath: path.join(baseDir, 'test.dbscheme'),
|
||||||
queryPath: queryTestCase.queryPath
|
queryPath: queryTestCase.queryPath
|
||||||
};
|
};
|
||||||
const params: messages.CompileQueryParams = {
|
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 () => {
|
it('should scan a directory', async () => {
|
||||||
const singleFile = path.join(dataDir, 'query.ql');
|
const file1 = path.join(dataDir, 'compute-default-strings.ql');
|
||||||
const otherFile = path.join(dataDir, 'multiple-result-sets.ql');
|
const file2 = path.join(dataDir, 'multiple-result-sets.ql');
|
||||||
|
const file3 = path.join(dataDir, 'query.ql');
|
||||||
|
|
||||||
const result = await gatherQlFiles([dataDir]);
|
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 () => {
|
it('should scan a directory and some files', async () => {
|
||||||
@@ -64,10 +65,12 @@ describe('files', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should avoid duplicates', async () => {
|
it('should avoid duplicates', async () => {
|
||||||
const singleFile = path.join(dataDir, 'query.ql');
|
const file1 = path.join(dataDir, 'compute-default-strings.ql');
|
||||||
const otherFile = path.join(dataDir, 'multiple-result-sets.ql');
|
const file2 = path.join(dataDir, 'multiple-result-sets.ql');
|
||||||
|
const file3 = path.join(dataDir, 'query.ql');
|
||||||
|
|
||||||
const result = await gatherQlFiles([singleFile, dataDir, otherFile]);
|
const result = await gatherQlFiles([file1, dataDir, file3]);
|
||||||
expect(result.sort()).to.deep.equal([[singleFile, otherFile], true]);
|
result[0].sort();
|
||||||
|
expect(result.sort()).to.deep.equal([[file1, file2, file3], true]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user