Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
18 changes: 17 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,25 @@ jobs:
npm run build-ci
shell: bash

- name: Run unit tests
- name: Install CodeQL
run: |
mkdir codeql-home
curl -L --silent https://github.com/github/codeql-cli-binaries/releases/latest/download/codeql.zip -o codeql-home/codeql.zip
unzip -q -o codeql-home/codeql.zip -d codeql-home
rm codeql-home/codeql.zip
shell: bash

- name: Run unit tests (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
cd extensions/ql-vscode
CODEQL_PATH=$GITHUB_WORKSPACE/codeql-home/codeql/codeql npm run test

- name: Run unit tests (Windows)
if: matrix.os == 'windows-latest'
run: |
cd extensions/ql-vscode
$env:CODEQL_PATH=$(Join-Path $env:GITHUB_WORKSPACE -ChildPath 'codeql-home/codeql/codeql.cmd')
npm run test

- name: Run integration tests (Linux)
Expand Down
6 changes: 6 additions & 0 deletions extensions/ql-vscode/test/pure-tests/query-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ describe('using the query server', function () {
const codeQlPath = process.env["CODEQL_PATH"]!;
let qs: qsClient.QueryServerClient;
let cliServer: cli.CodeQLCliServer;
const queryServerStarted = new Checkpoint<void>();
after(() => {
if (qs) {
qs.dispose();
Expand Down Expand Up @@ -122,6 +123,7 @@ describe('using the query server', function () {
task => task(consoleProgressReporter, token)
);
await qs.startQueryServer();
queryServerStarted.resolve();
});

// Note this does not work with arrow functions as the test case bodies:
Expand All @@ -132,8 +134,10 @@ describe('using the query server', function () {
const queryName = path.basename(queryTestCase.queryPath);
const compilationSucceeded = new Checkpoint<void>();
const evaluationSucceeded = new Checkpoint<void>();
const parsedResults = new Checkpoint<void>();

it(`should be able to compile query ${queryName}`, async function () {
await queryServerStarted.done();
expect(fs.existsSync(queryTestCase.queryPath)).to.be.true;
try {
const qlProgram: messages.QlProgram = {
Expand Down Expand Up @@ -209,6 +213,7 @@ describe('using the query server', function () {
}
actualResultSets[reader.schema.name] = actualRows;
}
parsedResults.resolve();
} finally {
if (fileReader) {
fileReader.dispose();
Expand All @@ -217,6 +222,7 @@ describe('using the query server', function () {
});

it(`should have correct results for query ${queryName}`, async function () {
await parsedResults.done();
expect(actualResultSets!).not.to.be.empty;
expect(Object.keys(actualResultSets!).sort()).to.eql(Object.keys(queryTestCase.expectedResultSets).sort());
for (const name in queryTestCase.expectedResultSets) {
Expand Down