@@ -6,14 +6,16 @@ import { SemVer } from 'semver';
66import { CodeQLCliServer , QueryInfoByLanguage } from '../../cli' ;
77import { CodeQLExtensionInterface } from '../../extension' ;
88import { skipIfNoCodeQL } from '../ensureCli' ;
9- import { getOnDiskWorkspaceFolders } from '../../helpers' ;
9+ import { getOnDiskWorkspaceFolders , getQlPackForDbscheme , languageToDbScheme } from '../../helpers' ;
1010import { resolveQueries } from '../../contextual/queryResolver' ;
1111import { KeyType } from '../../contextual/keyType' ;
1212
1313/**
1414 * Perform proper integration tests by running the CLI
1515 */
1616describe ( 'Use cli' , function ( ) {
17+ const supportedLanguages = [ 'cpp' , 'csharp' , 'go' , 'java' , 'javascript' , 'python' ] ;
18+
1719 this . timeout ( 60000 ) ;
1820
1921 let cli : CodeQLCliServer ;
@@ -51,15 +53,15 @@ describe('Use cli', function() {
5153 // Depending on the version of the CLI, the qlpacks may have different names
5254 // (e.g. "codeql/javascript-all" vs "codeql-javascript"),
5355 // so we just check that the expected languages are included.
54- for ( const expectedLanguage of [ 'cpp' , 'csharp' , 'go' , 'java' , 'javascript' , 'python' ] ) {
56+ for ( const expectedLanguage of supportedLanguages ) {
5557 expect ( ( Object . keys ( qlpacks ) ) . includes ( expectedLanguage ) ) ;
5658 }
5759 } ) ;
5860
5961 it ( 'should resolve languages' , async function ( ) {
6062 skipIfNoCodeQL ( this ) ;
6163 const languages = await cli . resolveLanguages ( ) ;
62- for ( const expectedLanguage of [ 'cpp' , 'csharp' , 'go' , 'java' , 'javascript' , 'python' ] ) {
64+ for ( const expectedLanguage of supportedLanguages ) {
6365 expect ( languages ) . to . have . property ( expectedLanguage ) . that . is . not . undefined ;
6466 }
6567 } ) ;
@@ -71,15 +73,26 @@ describe('Use cli', function() {
7173 expect ( ( Object . keys ( queryInfo . byLanguage ) ) [ 0 ] ) . to . eql ( 'javascript' ) ;
7274 } ) ;
7375
74- it . only ( 'should resolve printAST queries' , async function ( ) {
75- skipIfNoCodeQL ( this ) ;
7676
77- const result = await resolveQueries ( cli , {
78- dbschemePack : 'codeql/javascript-all' ,
79- dbschemePackIsLibraryPack : true ,
80- queryPack : 'codeql/javascript-queries'
81- } , KeyType . PrintAstQuery ) ;
82- expect ( result . length ) . to . eq ( 1 ) ;
83- expect ( result [ 0 ] . endsWith ( 'javascript/ql/src/printAst.ql' ) ) . to . be . true ;
77+ supportedLanguages . forEach ( lang => {
78+ if ( lang === 'go' ) {
79+ // The codeql-go submodule is not available in the integration tests.
80+ return ;
81+ }
82+ it ( `should resolve printAST queries for ${ lang } ` , async function ( ) {
83+ skipIfNoCodeQL ( this ) ;
84+
85+ const pack = await getQlPackForDbscheme ( cli , languageToDbScheme [ lang ] ) ;
86+ expect ( pack . dbschemePack ) . to . contain ( lang ) ;
87+ if ( pack . dbschemePackIsLibraryPack ) {
88+ expect ( pack . queryPack ) . to . contain ( lang ) ;
89+ }
90+
91+ const result = await resolveQueries ( cli , pack , KeyType . PrintAstQuery ) ;
92+
93+ // It doesn't matter what the name or path of the query is, only
94+ // that we have found exactly one query.
95+ expect ( result . length ) . to . eq ( 1 ) ;
96+ } ) ;
8497 } ) ;
8598} ) ;
0 commit comments