Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AST Viewer #949

Merged
merged 5 commits into from
Sep 8, 2021
Merged

Fix AST Viewer #949

merged 5 commits into from
Sep 8, 2021

Conversation

aeisenberg
Copy link
Contributor

@aeisenberg aeisenberg commented Sep 8, 2021

The previous synthetic query suite was not finding the ast query because
the qlpack directive in a query suite only matches queries from the
default suite, which printAST.ql is not part of.

This changes to using from and queries directives.

Also, adds an integration test to ensure we find the queries using
different CLIs. However, this only tests using the latest main from
the codeql repository. I wonder if we should start testing using
different versions of the repo.

Replace this with a description of the changes your pull request makes.

Checklist

  • CHANGELOG.md has been updated to incorporate all user visible changes made by this pull request.
  • Issues have been created for any UI or other user-facing changes made by this pull request.
  • @github/docs-content-codeql has been cc'd in all issues for UI or other user-facing changes made by this pull request.

The previous synthetic query suite was not finding the ast query because
the `qlpack` directive in a query suite only matches queries from the
default suite, which `printAST.ql` is not part of.

This changes to using `from` and `queries` directives.

Also, adds an integration test to ensure we find the queries using
different CLIs. However, this only tests using the latest `main` from
the codeql repository. I wonder if we should start testing using
different versions of the repo.
@aeisenberg aeisenberg requested a review from a team as a code owner September 8, 2021 16:26
@aeisenberg
Copy link
Contributor Author

We will probably need another release for this.

Also, I expect that some of the integration tests will fail, but not sure which ones. Let's see how far back we can still support print asts with the new formulation.

@@ -68,4 +70,16 @@ describe('Use cli', function() {
const queryInfo: QueryInfoByLanguage = await cli.resolveQueryByLanguage(getOnDiskWorkspaceFolders(), Uri.file(queryPath));
expect((Object.keys(queryInfo.byLanguage))[0]).to.eql('javascript');
});

it.only('should resolve printAST queries', async function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make this loop over all languages? The filenames may differ.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. I will change that.

skipIfNoCodeQL(this);

const result = await resolveQueries(cli, {
dbschemePack: 'codeql/javascript-all',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do these tests get the query repo checkout? If we're splitting over multiple CLI versions, we should use the corresponding codeql-cli/version tags from the query repos, as well as latest main for the last released CLI.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, the integration tests checks out the expected codeql version for each CLI version.

Go is not yet supported since we do not include the go submodule in the
integration tests.
This is old enough that we don't need to support it.
@aeisenberg
Copy link
Contributor Author

Works for all languages in github/codeql across all supported versions of the CLI. We only test that the core libraries version released with that version of the CLI are correct. We could add more matrix builds to test different versions of the CLI with different core libraries.

Also, not yet tested are go and ruby since these languages exist in other repos that are not yet being downloaded by the integration tests.

@aeisenberg aeisenberg linked an issue Sep 8, 2021 that may be closed by this pull request
Copy link
Contributor

@adityasharad adityasharad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. The missing test combination we discussed is latest stable CLI + github/codeql:main, but we can look into adding that separately.

@@ -3,6 +3,7 @@
## [UNRELEASED]

- Fix bug where a query is sometimes run before the file is saved. [#947](https://github.com/github/vscode-codeql/pull/947)
- Fix contextual queries that are broken due to a malformed synthetic query suite. [#949](https://github.com/github/vscode-codeql/pull/949)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mention the AST viewer here.

Copy link
Contributor

@dbartol dbartol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dbartol dbartol enabled auto-merge (rebase) September 8, 2021 20:53
@dbartol dbartol merged commit 3f22587 into main Sep 8, 2021
@dbartol dbartol deleted the aeisenberg/print-ast-fix branch September 8, 2021 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Cannot view the AST"
3 participants