forked from github/vscode-codeql
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun-cli.test.ts
More file actions
63 lines (55 loc) · 2.09 KB
/
run-cli.test.ts
File metadata and controls
63 lines (55 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { expect } from 'chai';
import { extensions } from 'vscode';
import { SemVer } from 'semver';
import { CodeQLCliServer } from '../../cli';
import { CodeQLExtensionInterface } from '../../extension';
import { skipIfNoCodeQL } from '../ensureCli';
import { getOnDiskWorkspaceFolders } from '../../helpers';
/**
* Perform proper integration tests by running the CLI
*/
describe('Use cli', function() {
this.timeout(60000);
let cli: CodeQLCliServer;
beforeEach(async () => {
const extension = await extensions.getExtension<CodeQLExtensionInterface | Record<string, never>>('GitHub.vscode-codeql')!.activate();
if ('cliServer' in extension) {
cli = extension.cliServer;
} else {
throw new Error('Extension not initialized. Make sure cli is downloaded and installed properly.');
}
});
if (process.env.CLI_VERSION !== 'nightly') {
it('should have the correct version of the cli', async () => {
expect(
(await cli.getVersion()).toString()
).to.eq(
new SemVer(process.env.CLI_VERSION || '').toString()
);
});
}
it('should resolve ram', async () => {
const result = await (cli as any).resolveRam(8192);
expect(result).to.deep.eq([
'-J-Xmx4096M',
'--off-heap-ram=4096'
]);
});
it('should resolve query packs', async function() {
skipIfNoCodeQL(this);
const qlpacks = await cli.resolveQlpacks(getOnDiskWorkspaceFolders());
// should have a bunch of qlpacks. just check that a few known ones exist
expect(qlpacks['codeql-cpp']).not.to.be.undefined;
expect(qlpacks['codeql-csharp']).not.to.be.undefined;
expect(qlpacks['codeql-java']).not.to.be.undefined;
expect(qlpacks['codeql-javascript']).not.to.be.undefined;
expect(qlpacks['codeql-python']).not.to.be.undefined;
});
it('should resolve languages', async function() {
skipIfNoCodeQL(this);
const languages = await cli.resolveLanguages();
for (const expectedLanguage of ['cpp', 'csharp', 'go', 'java', 'javascript', 'python']) {
expect(languages).to.have.property(expectedLanguage).that.is.not.undefined;
}
});
});