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

Restructure the tree in the Test Explorer View #624

Merged
merged 3 commits into from
Nov 9, 2020

Conversation

aeisenberg
Copy link
Contributor

@aeisenberg aeisenberg commented Oct 19, 2020

With this change we display the tree based on the file system not based
on ql-packs. We also merge test folders whose only child is another
test folder.

Resolves #595

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-dsp has been cc'd in all issues for UI or other user-facing changes made by this pull request.

extensions/ql-vscode/src/qltest-discovery.ts Show resolved Hide resolved
@@ -98,12 +110,12 @@ interface QLTestDiscoveryResults {
/**
* The root test directory for each QL pack that contains tests.
Copy link
Contributor

Choose a reason for hiding this comment

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

Update comment please :)

@@ -98,12 +110,12 @@ interface QLTestDiscoveryResults {
/**
* The root test directory for each QL pack that contains tests.
*/
testDirectories: QLTestDirectory[];
testDirectory: QLTestDirectory | undefined;
/**
* The list of file system paths to watch. If any of these paths changes, the discovery results
Copy link
Contributor

Choose a reason for hiding this comment

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

Update comment please :)

public get onDidChangeTests(): Event<void> { return this._onDidChangeTests.event; }
public get onDidChangeTests(): Event<void> {
return this._onDidChangeTests.event;
}

/**
* The root test directory for each QL pack that contains tests.
Copy link
Contributor

Choose a reason for hiding this comment

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

Update - I assume this is just the workspace folder, viewed as a QLTestDirectory.


return { testDirectories, watchPaths };
return {
testDirectory: await this.discoverTests(),
Copy link
Contributor

Choose a reason for hiding this comment

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

We now unconditionally run test discovery on all workspace folders. How does this scale/perform when we have a large workspace with many folders, or a single large repo (like our internal codebase)? Does it also attempt to search the source archives that we add to the workspace in the extension, and if so can we skip them?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll try this out on different repos to see.

@aeisenberg aeisenberg added the Complexity: Medium Requires a moderate level of detail in design or review. label Oct 23, 2020
Copy link
Contributor Author

@aeisenberg aeisenberg left a comment

Choose a reason for hiding this comment

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

Oh...never submitted these comments from days ago.

extensions/ql-vscode/src/qltest-discovery.ts Show resolved Hide resolved

return { testDirectories, watchPaths };
return {
testDirectory: await this.discoverTests(),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll try this out on different repos to see.

@adityasharad
Copy link
Contributor

Some outstanding doc comments, and changelog conflicts.

With this change we display the tree based on the file system not based
on ql-packs. We also merge test folders whose only child is another
test folder.

Resolves github#595
@aeisenberg aeisenberg force-pushed the aeisenberg/restructure-test-tree branch from ea3db03 to 5cc9f83 Compare November 5, 2020 06:03
@aeisenberg
Copy link
Contributor Author

Update here. I found a bug in how discovery works. QLTest discovery runs twice at startup. The reason is this:

  1. QLPack discovery starts
  2. QLTest discovery starts
  3. When QLPack discovery finishes, it triggers a new discovery for QLTest. Even though QLTest discovery just finished.

This is the case with the main branch right now. In the new setup we don't rely on QLPacks at all. It can be completely removed. And code is significantly simplified.

Now the bad news. Each initial discovery operation in the new way (from the root of the workspace folder takes between 500-1500ms. Under the current way, where we do discovery from the roots of the test qlpacks, initial discovery takes between 100-200ms.

For whatever reason, subsequent discoveries under the new way are quicker (700-800ms) and slower under the old way (400-500ms). This data was not captured very scientifically.

I personally think that this difference in time is not a deal breaker. Initial discovery being slow is less important since that happens during other initialization so, a little slowness for tests is not very noticeable. And the fact that it takes about 2x longer for subsequent discoveries is not noticeable either since this happens during a save, while editing.

With this in mind, I will refactor to remove the double discovery operations. This will mean that qlpack discovery will be removed.

We no longer rely on qlpacks for our ql test structure. For this reason,
we no longer need to do qlpack discovery.
@aeisenberg aeisenberg force-pushed the aeisenberg/restructure-test-tree branch from 0e9e2a9 to a7a582d Compare November 5, 2020 14:47
@aeisenberg
Copy link
Contributor Author

Ping! @github/docs-content-dsp This PR changes the layout structure of the QL test tree. Before this PR, the test tree was scoped by workspace folders, then by ql packs in those folders.

The new layout that the ql test tree matches the filesystem. This makes it easier to map tests back to their location in the filesystem.

@hubot
Copy link

hubot commented Nov 5, 2020

:octocat:📚 Thanks for the docs ping! 🛎️ This was added to our docs first-responder project board. A team member will be along shortly to review this for docs impact.

EDIT: No docs impact ✔️

Copy link
Contributor

@shati-patel shati-patel left a comment

Choose a reason for hiding this comment

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

Ping! @github/docs-content-dsp This PR changes the layout structure of the QL test tree. Before this PR, the test tree was scoped by workspace folders, then by ql packs in those folders.

The new layout that the ql test tree matches the filesystem. This makes it easier to map tests back to their location in the filesystem.

Thanks, makes sense! We don't go into detail about the structure of the Test Explorer view in the docs, so this doesn't need explicit documentation 😃

@@ -28,6 +28,7 @@
- Add a `View DIL` command on query history items. This opens a text editor containing the Datalog Intermediary Language representation of the compiled query.
- Remove feature flag for the AST Viewer. For more information on how to use the AST Viewer, [see the documentation](https://help.semmle.com/codeql/codeql-for-vscode/procedures/exploring-the-structure-of-your-source-code.html).
- The `codeQL.runningTests.numberOfThreads` setting is now used correctly when running tests.
- Alter structure of the _Test Explorer_ tree. It now follows the structure of the filesystem instead of the qlpacks.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- Alter structure of the _Test Explorer_ tree. It now follows the structure of the filesystem instead of the qlpacks.
- Alter structure of the _Test Explorer_ tree. It now follows the structure of the filesystem instead of the QL packs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Whoops I think this suggestion got omitted.

@aeisenberg aeisenberg merged commit 245496c into github:main Nov 9, 2020
@aeisenberg aeisenberg deleted the aeisenberg/restructure-test-tree branch November 24, 2020 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Complexity: Medium Requires a moderate level of detail in design or review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

QL Test Explorer should discover tests via codeql resolve tests
4 participants