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

Virtualenv locator #13893

Merged
merged 4 commits into from
Sep 15, 2020
Merged

Virtualenv locator #13893

merged 4 commits into from
Sep 15, 2020

Conversation

kimadeline
Copy link

For #12020

  • Pull request represents a single change (i.e. not fixing disparate/unrelated things in a single PR).
  • Title summarizes what is changing.
  • Has a news entry file (remember to thank yourself!).
  • Appropriate comments and documentation strings in the code.
  • Has sufficient logging.
  • Has telemetry for enhancements.
  • Unit tests & system/integration tests are added/updated.
  • Test plan is updated as appropriate.
  • package-lock.json has been regenerated by running npm install (if dependencies have changed).
  • The wiki is updated with any design decisions/details.

@kimadeline kimadeline added the no-changelog No news entry required label Sep 11, 2020
@codecov-commenter
Copy link

codecov-commenter commented Sep 11, 2020

Codecov Report

Merging #13893 into main will decrease coverage by 0.01%.
The diff coverage is 90.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #13893      +/-   ##
==========================================
- Coverage   59.87%   59.86%   -0.02%     
==========================================
  Files         693      694       +1     
  Lines       38348    38358      +10     
  Branches     5515     5516       +1     
==========================================
+ Hits        22961    22962       +1     
- Misses      14207    14213       +6     
- Partials     1180     1183       +3     
Impacted Files Coverage Δ
...pythonEnvironments/common/environmentIdentifier.ts 86.66% <66.66%> (+3.33%) ⬆️
...s/discovery/locators/services/virtualenvLocator.ts 100.00% <100.00%> (ø)
src/client/datascience/crossProcessLock.ts 79.41% <0.00%> (-11.77%) ⬇️
src/client/common/utils/platform.ts 60.00% <0.00%> (-8.00%) ⬇️
src/client/linters/pydocstyle.ts 86.66% <0.00%> (-2.23%) ⬇️
src/client/datascience/debugLocationTracker.ts 76.56% <0.00%> (-1.57%) ⬇️
src/client/common/process/proc.ts 14.49% <0.00%> (-0.73%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8da0b92...143020e. Read the comment docs.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@kimadeline
Copy link
Author

kimadeline commented Sep 14, 2020

Single workspace and smoke tests are failing with [4817:0914/155221.715550:FATAL:gpu_data_manager_impl_private.cc(439)] GPU process isn't usable. Goodbye. (see microsoft/vscode-test#73), not related to the PR.

@kimadeline kimadeline marked this pull request as ready for review September 14, 2020 15:59
Copy link
Member

@ericsnowcurrently ericsnowcurrently left a comment

Choose a reason for hiding this comment

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

Everything looks correct. I have a few comments related to names and to the context of relevant code.

Comment on lines +11 to +12
const envRoot = path.join('path', 'to', 'env');
const interpreter = path.join(envRoot, 'python');
Copy link
Member

Choose a reason for hiding this comment

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

If it's a unit test then there should be no dependence on the behavior of the path module. Instead we would either stub that (or the functions) out or we would directly use one of the OS-specific implementations (path.posix or path.win32).

Copy link
Member

Choose a reason for hiding this comment

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

I don't see how this test depends on the behavior of the path module. If in the rest of the code we let path do what ever it does, then in the test we should let path do whatever it does. we are not testing path here, and the fact that path gets used anywhere at all is an internal implementation detail that this test should not care about.

Copy link
Member

@gramster gramster Sep 14, 2020

Choose a reason for hiding this comment

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

Actually, functional testing is testing that the system as a whole functions as intended. So acceptance tests for user stories would be functional tests. Unit tests can test at levels of abstraction that are not the same as functional tests. But that does not mean that all dependencies should be stubbed. Stub dependencies that are stateful or have performance implications. Don't stub things just because they are dependencies.

You should always be focused on outcomes. Are the tests hermetic? Are they fast? (Those two would be reasons to stub stateful or slow dependencies). Do they find bugs? (I'd argue here that stubbing path is not going to help you find more bugs - and in fact if a bug was introduced in path you'd want to know about it). Are they brittle? (Here, over-reliance on implementation details would make the test brittle - and stubbing path would be an example of that).

Copy link
Member

Choose a reason for hiding this comment

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

FWIW, these are the case that I believe are appropriate for stubbing:

  • stateful shared dependencies
  • slow dependencies
  • non-deterministic components
  • resource-intensive components
  • hard to initialize/configure components
  • components where you want to generate boundary test values that would be hard to create with the real code
  • in TDD, stubbing dependencies that don't yet exist (until they do)

Copy link
Member

Choose a reason for hiding this comment

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

Thanks. That's good info. My only concern is that, in general, we do not know if a dependency is stateful unless that project promises it is (and we trust them) or we inspect the code (and assume it doesn't become stateful later). FWIW, I agree that in the case of path we have a high level of confidence that it is neither stateful nor slow.

I guess my question is if it's more valuable to be consistent about strongly separating external dependencies or to allow exceptions. On the one hand, using test doubles adds complexity to tests, has a tendency to couple tests more tightly to code (making them more fragile), and moves them a step further from the actual runtime behavior. On the other hand, it means we don't have to spend the time to figure out (or guess) if a dependency needs to be stubbed out, nor do we have to worry about that behavior changing in the future.

So the way I see it, having a consistent separation from external dependencies allows us to always focus just on the logic of the unit under test, which from my perspective is the essential purpose of unit tests. For me, when we run into the downsides of test doubles (for external dependencies), it is almost always an indicator that the unit-under-test is trying to do too much, rather than the test doubles being the problem.

Regardless, I don't think this is a critical issue, especially since I doubt there will be many stateless+fast external dependencies. So this isn't something we need to spend much more time on. However, I do want to have a better sense of the actual tradeoffs. 😄

Copy link
Member

Choose a reason for hiding this comment

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

In case it wasn't clear, I'm not blocking the PR on this. 😄

Copy link
Member

@ericsnowcurrently ericsnowcurrently left a comment

Choose a reason for hiding this comment

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

LGTM

@kimadeline kimadeline merged commit b21b2e1 into microsoft:main Sep 15, 2020
@kimadeline kimadeline deleted the virtualenv-locator branch September 15, 2020 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog No news entry required
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants