From a3bf9f1c7155cffc80d8f3608be6f4af2e216fe6 Mon Sep 17 00:00:00 2001 From: Andrew Eisenberg Date: Mon, 13 Dec 2021 20:33:17 -0800 Subject: [PATCH] Handle different dependencies in remote queries tests Starting in CLI 2.7.5, there will no longer be any `codeql/javascript-upgrades` pack. Change the test so that it passes using both old and new packs. --- .../cli-integration/run-remote-query.test.ts | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/extensions/ql-vscode/src/vscode-tests/cli-integration/run-remote-query.test.ts b/extensions/ql-vscode/src/vscode-tests/cli-integration/run-remote-query.test.ts index 9ca627a3f..766c45b24 100644 --- a/extensions/ql-vscode/src/vscode-tests/cli-integration/run-remote-query.test.ts +++ b/extensions/ql-vscode/src/vscode-tests/cli-integration/run-remote-query.test.ts @@ -110,10 +110,14 @@ describe('Remote queries', function() { expect(fs.existsSync(path.join(compiledPackDir, 'not-in-pack.ql'))).to.be.false; verifyQlPack(path.join(compiledPackDir, 'qlpack.yml'), 'in-pack.ql', '0.0.0', await pathSerializationBroken()); - // dependencies const libraryDir = path.join(compiledPackDir, '.codeql/libraries/codeql'); const packNames = fs.readdirSync(libraryDir).sort(); - expect(packNames).to.deep.equal(['javascript-all', 'javascript-upgrades']); + + // check dependencies. + // 2.7.4 and earlier have ['javascript-all', 'javascript-upgrades'] + // later only have ['javascript-all']. ensure this test can handle eitehr + expect(packNames.length).to.be.lessThan(3).and.greaterThan(0); + expect(packNames[0]).to.deep.equal('javascript-all'); }); it('should run a remote query that is not part of a qlpack', async () => { @@ -166,11 +170,15 @@ describe('Remote queries', function() { expect(qlpackContents.version).to.equal('0.0.0'); expect(qlpackContents.dependencies?.['codeql/javascript-all']).to.equal('*'); - // dependencies const libraryDir = path.join(compiledPackDir, '.codeql/libraries/codeql'); printDirectoryContents(libraryDir); const packNames = fs.readdirSync(libraryDir).sort(); - expect(packNames).to.deep.equal(['javascript-all', 'javascript-upgrades']); + + // check dependencies. + // 2.7.4 and earlier have ['javascript-all', 'javascript-upgrades'] + // later only have ['javascript-all']. ensure this test can handle eitehr + expect(packNames.length).to.be.lessThan(3).and.greaterThan(0); + expect(packNames[0]).to.deep.equal('javascript-all'); }); it('should run a remote query that is nested inside a qlpack', async () => { @@ -222,11 +230,15 @@ describe('Remote queries', function() { expect(qlpackContents.version).to.equal('0.0.0'); expect(qlpackContents.dependencies?.['codeql/javascript-all']).to.equal('*'); - // dependencies const libraryDir = path.join(compiledPackDir, '.codeql/libraries/codeql'); printDirectoryContents(libraryDir); const packNames = fs.readdirSync(libraryDir).sort(); - expect(packNames).to.deep.equal(['javascript-all', 'javascript-upgrades']); + + // check dependencies. + // 2.7.4 and earlier have ['javascript-all', 'javascript-upgrades'] + // later only have ['javascript-all']. ensure this test can handle eitehr + expect(packNames.length).to.be.lessThan(3).and.greaterThan(0); + expect(packNames[0]).to.deep.equal('javascript-all'); }); it('should cancel a run before uploading', async () => {