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

Sort by location doesn't work #317

Closed
Toxlen opened this issue Dec 22, 2021 · 5 comments
Closed

Sort by location doesn't work #317

Toxlen opened this issue Dec 22, 2021 · 5 comments

Comments

@Toxlen
Copy link

Toxlen commented Dec 22, 2021

Describe the bug

  • Set the sorting mechanism to "Sort by Location"
  • Expected: see the tests in the same order as the one I wrote them in the .cpp file they are into
  • Actual: The test suite are in the alphabetic order and the tests in them are sort by location (if I reload my VS Code)

image

Desktop

  • Extension Version: 4.0.16
  • VS Code Version: 1.63.2
  • OS Type and Version: Windows 10
  • Using remote-ssh/docker/wsl?: no

Log ?

Let me know if you'd like me to attach a log.

It's not a big deal for the user just a bit of a shame.

@stefanhaller
Copy link
Contributor

Sorting seems to be broken in other cases as well. For example, "Sort by status" often doesn't work right after running a test that fails. If you then switch the sort order to something else and then back to status, it does sort correctly.

Since I have seen this behavior also with the Python extension, I suspect it's a bug in VS Code, not in TestMate. I didn't get around to filing an issue yet, because I wanted to investigate a little more thoroughly first.

@stefanhaller
Copy link
Contributor

Here's the issue for the "Sort by status" problem mentioned above: microsoft/vscode#139648.

However, it is unrelated to this one ("Sort by Location"). For this one, the problem is that "Sort by location" sorts by URI and line range, but test suites in gtest don't have a line range (they don't have the little "go to test" icon). That's why test suites in gtest are sorted by name, and the tests within are sorted by location. A related VS Code issue is microsoft/vscode#130882.

It might be possible to improve this by setting a suite's URI and range to the URI and range of its first contained test (@matepek?). There could still be strange situations like the following:

TEST(FirstSuite, First1) {}

TEST(OtherSuite, Other1) {}

TEST(FirstSuite, First2) {}

TEST(OtherSuite, Other2) {}

but I don't think there's much you can do about these in any case.

@matepek
Copy link
Owner

matepek commented Dec 27, 2021

if only it were that easy..

vscode api is not that flexible:

		/**
		 * URI this `TestItem` is associated with. May be a file or directory.
		 */
		readonly uri: Uri | undefined;

Also the custom grouping feature introduces some limitation here.

The solution is not trivial

@matepek
Copy link
Owner

matepek commented Dec 27, 2021

It might be possible to improve this by setting a suite's URI and range to the URI and range of its first contained test

It might.. I will do a release and let's see how it works for everyone..

@matepek
Copy link
Owner

matepek commented Dec 27, 2021

Fixed in **v4.0.17**.

This issue was mentioned in CHANGELOG.md under a released entry so it is assumed to be fixed.
User verifications are always welcome.

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

No branches or pull requests

3 participants