Skip to content

Commit 0f7074b

Browse files
committed
Add query running test for computeDefaultStrings flag
1 parent 2f8a1f9 commit 0f7074b

2 files changed

Lines changed: 25 additions & 13 deletions

File tree

extensions/ql-vscode/src/vscode-tests/no-workspace/query-test.ts renamed to extensions/ql-vscode/src/vscode-tests/no-workspace/query.test.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ import { ColumnValue } from '../../pure/bqrs-cli-types';
1313
import { FindDistributionResultKind } from '../../distribution';
1414

1515

16-
declare module 'url' {
17-
export function pathToFileURL(urlStr: string): Url;
18-
}
16+
const baseDir = path.join(__dirname, '../../../test/data');
1917

2018
const tmpDir = tmp.dirSync({ prefix: 'query_test_', keep: false, unsafeCleanup: true });
2119

@@ -61,21 +59,27 @@ type QueryTestCase = {
6159
// Test cases: queries to run and their expected results.
6260
const queryTestCases: QueryTestCase[] = [
6361
{
64-
queryPath: path.join(__dirname, '../data/query.ql'),
62+
queryPath: path.join(baseDir, 'query.ql'),
6563
expectedResultSets: {
6664
'#select': [[42, 3.14159, 'hello world', true]]
6765
}
6866
},
6967
{
70-
queryPath: path.join(__dirname, '../data/multiple-result-sets.ql'),
68+
queryPath: path.join(baseDir, 'compute-default-strings.ql'),
69+
expectedResultSets: {
70+
'#select': [[{ label: '(no string representation)' }]]
71+
}
72+
},
73+
{
74+
queryPath: path.join(baseDir, 'multiple-result-sets.ql'),
7175
expectedResultSets: {
7276
'edges': [[1, 2], [2, 3]],
7377
'#select': [['s']]
7478
}
7579
}
7680
];
7781

78-
describe('using the query server', function() {
82+
describe.only('using the query server', function() {
7983
before(function() {
8084
if (process.env['CODEQL_PATH'] === undefined) {
8185
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() {
9296
let cliServer: cli.CodeQLCliServer;
9397
const queryServerStarted = new Checkpoint<void>();
9498
after(() => {
95-
if (qs) {
96-
qs.dispose();
97-
}
98-
if (cliServer) {
99-
cliServer.dispose();
100-
}
99+
qs?.dispose();
100+
cliServer?.dispose();
101101
});
102102

103103
it('should be able to start the query server', async function() {
@@ -156,7 +156,7 @@ describe('using the query server', function() {
156156
try {
157157
const qlProgram: messages.QlProgram = {
158158
libraryPath: [],
159-
dbschemePath: path.join(__dirname, '../data/test.dbscheme'),
159+
dbschemePath: path.join(baseDir, 'test.dbscheme'),
160160
queryPath: queryTestCase.queryPath
161161
};
162162
const params: messages.CompileQueryParams = {
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Test that computeDefaultStrings is set correctly.
2+
3+
newtype TUnit = MkUnit()
4+
5+
class Unit extends TUnit {
6+
Unit() { this = MkUnit() }
7+
8+
string toString() { none() }
9+
}
10+
11+
from Unit u
12+
select u

0 commit comments

Comments
 (0)