Use sarif parser for reopened results#1457
Conversation
|
Looks like there are some genuine unit test errors on the method I changed so this will need more 🕵️ work |
acb95db to
c37c5bf
Compare
extensions/ql-vscode/src/vscode-tests/no-workspace/query-results.test.ts
Outdated
Show resolved
Hide resolved
extensions/ql-vscode/src/vscode-tests/no-workspace/query-results.test.ts
Outdated
Show resolved
Hide resolved
| let res; | ||
| if (await fs.pathExists(interpretedResultsPath)) { | ||
| return { ...JSON.parse(await fs.readFile(interpretedResultsPath, 'utf8')), t: 'SarifInterpretationData' }; | ||
| res = await sarifParser(interpretedResultsPath); |
There was a problem hiding this comment.
Just a thought....if this function throws an error because the file is not parseable, should we delete the file and re-run cli.interpretBqrsSarif?
Possibly, we can do this as a followup.
There was a problem hiding this comment.
Hm, that's a good point 👍 I'll leave this comment up for now, while we work out the last invalid SARIF test issue..
extensions/ql-vscode/src/vscode-tests/no-workspace/query-results.test.ts
Outdated
Show resolved
Hide resolved
extensions/ql-vscode/src/vscode-tests/no-workspace/query-results.test.ts
Outdated
Show resolved
Hide resolved
| expect(results3).to.deep.eq({ a: 6, t: 'SarifInterpretationData' }); | ||
| afterEach(async () => { | ||
| sandbox.restore(); | ||
| await safeDel(interpretedResultsPath); |
There was a problem hiding this comment.
I'm actually seeing sometimes that safeDel isn't so safe. It might be causing some hangs in the cli-integration tests. Can you use the del function instead?
| await safeDel(interpretedResultsPath); | |
| await del(interpretedResultsPath); |
And add this import to the imports at the top of the file:
import * as del from 'del';
There was a problem hiding this comment.
Actually the test was failing in CI (not locally) when I used del — it said that the file wasn't found when it tried to delete it. See https://github.com/github/vscode-codeql/actions/runs/3285438706/jobs/5412531729
There was a problem hiding this comment.
1) query-results
interpretResultsSarif
"after each" hook for "should use sarifParser on a valid small SARIF file":
Error: Cannot delete files/directories outside the current working directory. Can be overridden with the `force` option.
at safeCheck (node_modules/del/index.js:37:9)
at mapper (node_modules/del/index.js:73:4)
at /home/runner/work/vscode-codeql/vscode-codeql/extensions/ql-vscode/node_modules/p-map/index.js:57:28
at processTicksAndRejections (node:internal/process/task_queues:96:5)
There was a problem hiding this comment.
I'm going to remove the del call entirely and see if it works, given that I am over-writing the existing file when the WriteStream is created.
There was a problem hiding this comment.
Removing del altogether worked on ubuntu. There is still a failure in this same test in Windows
[main 2022-10-20T17:11:53.979Z] Extension host with pid 6888 exited with code: 134, signal: null.
Test runner caught exception (Failed)
Exit code: 134
Done
Tried running suite 3 time(s), still failed, giving up.
Error: Process completed with exit code 1.
that isn't very descriptive. Exit code 134 seems to be a SIGABRT. I seem to remember there being some intricacies around Windows and file I/O — maybe I'm hitting one of them here?
|
|
||
| it('should interpretResultsSarif', async function() { | ||
| // up to 2 minutes per test | ||
| this.timeout(2 * 60 * 1000); |
There was a problem hiding this comment.
Can you move this (and the other) timeout to the describe block above? You only need to set the timeout once up there.
There was a problem hiding this comment.
I get an Object is possibly undefined error when I move it to the describe block or the beforeEach block — is there a way to get around that error?
There was a problem hiding this comment.
Figured out how move this to the beforeEach hook and pushed up.
There was a problem hiding this comment.
Nevermind, that didn't work... had to revert
extensions/ql-vscode/src/vscode-tests/no-workspace/query-results.test.ts
Outdated
Show resolved
Hide resolved
|
I can't tell why the windows tests are failing. It seems to be failing consistently. If you have access to a windows box, maybe try running the tests there. |
I don't have one, but will 🍐 with Dave tomorrow on this! |
f75f0b7 to
36e7a41
Compare
36e7a41 to
f75f0b7
Compare
|
Now, looks like the tests are failing because Not a pleasing solution, but perhaps, you can use a different name for interpreted results file for each test. This way, you won't need to delete it in |
Dave and I just came up with something like this in pairing too. It looked like there was a separate issue with Windows Defender that needed a sleep after the file was written (because it couldn't be opened while Windows Defender was scanning it), so we added 10s sleep as well. After that we discovered the problem in the final test where it wasn't able to be deleted/read. I've renamed the file for just the last test to see if it passes for now (can't reproduce locally without a Windows machine). I can also rename the others for consistency. |
This reverts commit 262fbee.
|
Not sure if you've tried this already, but you can launch the test version of vscode with |
|
Phew, renaming the path worked 😸 so this PR is finally ready for re-review |
aeisenberg
left a comment
There was a problem hiding this comment.
Great job sticking with this and working through all these frustrating details. It seemed like a simple task, but there was a lot of subtlety with it.
When we attempt to re-open query results, instead of using the streaming SARIF parser written in #1004, we used
JSON.parse(). This couldn't handle large SARIF files and we ran into an error.This change uses the streaming SARIF parser instead. Note that this is a draft pull request as it is untested locally. cc @aschackmull (sorry, wrong Anders tagged at first!)
Checklist
ready-for-doc-reviewlabel there.