Skip to content

Commit 440044d

Browse files
committed
Add more debugging logic
Help understand why tests are failing.
1 parent 48468ff commit 440044d

File tree

1 file changed

+38
-16
lines changed

1 file changed

+38
-16
lines changed

extensions/ql-vscode/src/vscode-tests/cli-integration/run-remote-query.test.ts

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ describe('Remote queries', function() {
6767
const fileUri = getFile('data-remote-qlpack/in-pack.ql');
6868

6969
const queryPackRootDir = (await runRemoteQuery(cli, credentials, fileUri, true, progress, token))!;
70+
printDirectoryContents(queryPackRootDir);
7071

7172
// to retrieve the list of repositories
7273
expect(showQuickPickSpy).to.have.been.calledOnce;
@@ -77,25 +78,32 @@ describe('Remote queries', function() {
7778
expect(fs.readdirSync(queryPackRootDir).find(f => f.startsWith('qlpack-') && f.endsWith('-generated.tgz'))).not.to.be.undefined;
7879

7980
const queryPackDir = path.join(queryPackRootDir, 'query-pack');
81+
printDirectoryContents(queryPackDir);
82+
8083
// in-pack.ql renamed to query.ql
8184
expect(fs.existsSync(path.join(queryPackDir, 'query.ql'))).to.be.true;
8285
expect(fs.existsSync(path.join(queryPackDir, 'lib.qll'))).to.be.true;
8386
expect(fs.existsSync(path.join(queryPackDir, 'qlpack.yml'))).to.be.true;
84-
expect(fs.existsSync(
85-
// depending on the cli version, we should have one of these files
86-
path.join(queryPackDir, 'qlpack.lock.yml') || path.join(queryPackDir, 'codeql-pack.lock.yml')
87-
)).to.be.true;
87+
88+
// depending on the cli version, we should have one of these files
89+
expect(
90+
fs.existsSync(path.join(queryPackDir, 'qlpack.lock.yml')) ||
91+
fs.existsSync(path.join(queryPackDir, 'codeql-pack.lock.yml'))
92+
).to.be.true;
8893
expect(fs.existsSync(path.join(queryPackDir, 'not-in-pack.ql'))).to.be.false;
8994

9095
// the compiled pack
9196
const compiledPackDir = path.join(queryPackDir, '.codeql/pack/github/remote-query-pack/0.0.0/');
97+
printDirectoryContents(compiledPackDir);
98+
9299
expect(fs.existsSync(path.join(compiledPackDir, 'query.ql'))).to.be.true;
93100
expect(fs.existsSync(path.join(compiledPackDir, 'lib.qll'))).to.be.true;
94101
expect(fs.existsSync(path.join(compiledPackDir, 'qlpack.yml'))).to.be.true;
95-
expect(fs.existsSync(
96-
// depending on the cli version, we should have one of these files
97-
path.join(compiledPackDir, 'qlpack.lock.yml') || path.join(queryPackDir, 'codeql-pack.lock.yml')
98-
)).to.be.true;
102+
// depending on the cli version, we should have one of these files
103+
expect(
104+
fs.existsSync(path.join(compiledPackDir, 'qlpack.lock.yml')) ||
105+
fs.existsSync(path.join(compiledPackDir, 'codeql-pack.lock.yml'))
106+
).to.be.true;
99107
expect(fs.existsSync(path.join(compiledPackDir, 'not-in-pack.ql'))).to.be.false;
100108

101109
// dependencies
@@ -116,27 +124,32 @@ describe('Remote queries', function() {
116124
// check a few files that we know should exist and others that we know should not
117125

118126
// the tarball to deliver to the server
127+
printDirectoryContents(queryPackRootDir);
119128
expect(fs.readdirSync(queryPackRootDir).find(f => f.startsWith('qlpack-') && f.endsWith('-generated.tgz'))).not.to.be.undefined;
120129

121130
const queryPackDir = path.join(queryPackRootDir, 'query-pack');
131+
printDirectoryContents(queryPackDir);
122132
// in-pack.ql renamed to query.ql
123133
expect(fs.existsSync(path.join(queryPackDir, 'query.ql'))).to.be.true;
124134
expect(fs.existsSync(path.join(queryPackDir, 'qlpack.yml'))).to.be.true;
125-
expect(fs.existsSync(
126-
// depending on the cli version, we should have one of these files
127-
path.join(queryPackDir, 'qlpack.lock.yml') || path.join(queryPackDir, 'codeql-pack.lock.yml')
128-
)).to.be.true;
135+
// depending on the cli version, we should have one of these files
136+
expect(
137+
fs.existsSync(path.join(queryPackDir, 'qlpack.lock.yml')) ||
138+
fs.existsSync(path.join(queryPackDir, 'codeql-pack.lock.yml'))
139+
).to.be.true;
129140
expect(fs.existsSync(path.join(queryPackDir, 'lib.qll'))).to.be.false;
130141
expect(fs.existsSync(path.join(queryPackDir, 'not-in-pack.ql'))).to.be.false;
131142

132143
// the compiled pack
133144
const compiledPackDir = path.join(queryPackDir, '.codeql/pack/codeql-remote/query/1.0.0/');
145+
printDirectoryContents(compiledPackDir);
134146
expect(fs.existsSync(path.join(compiledPackDir, 'query.ql'))).to.be.true;
135147
expect(fs.existsSync(path.join(compiledPackDir, 'qlpack.yml'))).to.be.true;
136-
expect(fs.existsSync(
137-
// depending on the cli version, we should have one of these files
138-
path.join(compiledPackDir, 'qlpack.lock.yml') || path.join(queryPackDir, 'codeql-pack.lock.yml')
139-
)).to.be.true;
148+
// depending on the cli version, we should have one of these files
149+
expect(
150+
fs.existsSync(path.join(compiledPackDir, 'qlpack.lock.yml')) ||
151+
fs.existsSync(path.join(compiledPackDir, 'codeql-pack.lock.yml'))
152+
).to.be.true;
140153
expect(fs.existsSync(path.join(compiledPackDir, 'lib.qll'))).to.be.false;
141154
expect(fs.existsSync(path.join(compiledPackDir, 'not-in-pack.ql'))).to.be.false;
142155
// should have generated a correct qlpack file
@@ -147,6 +160,7 @@ describe('Remote queries', function() {
147160

148161
// dependencies
149162
const libraryDir = path.join(compiledPackDir, '.codeql/libraries/codeql');
163+
printDirectoryContents(libraryDir);
150164
const packNames = fs.readdirSync(libraryDir).sort();
151165
expect(packNames).to.deep.equal(['javascript-all', 'javascript-upgrades']);
152166
});
@@ -169,4 +183,12 @@ describe('Remote queries', function() {
169183
function getFile(file: string): Uri {
170184
return Uri.file(path.join(baseDir, file));
171185
}
186+
187+
function printDirectoryContents(dir: string) {
188+
console.log(`DIR ${dir}`);
189+
if (!fs.existsSync(dir)) {
190+
console.log(`DIR ${dir} does not exist`);
191+
}
192+
fs.readdirSync(dir).sort().forEach(f => console.log(` ${f}`));
193+
}
172194
});

0 commit comments

Comments
 (0)