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

Pytest discovery using new Python test discovery adapter. #4695

Closed
wants to merge 30 commits into from

Conversation

d3r3kk
Copy link

@d3r3kk d3r3kk commented Mar 9, 2019

For #4035

Transform results from our new Python test adapter for discovery into the Tests struct we use throughout the extension.


  • 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!)
  • 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.

Copy link

@DonJayamanne DonJayamanne left a comment

Choose a reason for hiding this comment

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

I think the python API needa to be re-visited.
We are still parsing strings and building a tree, in the TS layer to build and identify parent child relationships.
This needs to be done in the Python layer where the entire structure of known and prescribed, i.e. it should simply return a strongly typed json structure = a tree, making it totally unnecessary to build a tree/parse again in TS.

/cc @ericsnowcurrently

src/client/unittests/common/discoveredTests.ts Outdated Show resolved Hide resolved
src/client/unittests/common/discoveredTests.ts Outdated Show resolved Hide resolved
src/client/unittests/common/runner.ts Outdated Show resolved Hide resolved
src/client/unittests/common/types.ts Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Mar 11, 2019

Codecov Report

Merging #4695 into master will decrease coverage by 16%.
The diff coverage is 76%.

@@           Coverage Diff            @@
##           master   #4695     +/-   ##
========================================
- Coverage      77%     62%    -15%     
========================================
  Files         447     372     -75     
  Lines       21472   14476   -6996     
  Branches     3527    1145   -2382     
========================================
- Hits        16444    8860   -7584     
- Misses       5024    5413    +389     
- Partials        4     203    +199
Flag Coverage Δ
#Linux ?
#Windows ?
#macOS ?

- first pass of the new test discovery API exec
- trying to not change anything outside of unittest
  - particularly outside of pytest
- Make the run_adapter placeholder return an array
- use JSON.Parse on the returned result in parser
- Add a script that just spits out test data
- Use python.pythonPath for the exe path
- Put the run_adapter.py script as the first arg to the process
- Add the rest of the necessary args to the script.
- Add `discover` method alongside `run` method
- Focusing on running discovery via the new Python adapter
- This will be the call for each test framework going forward
- New data type expected from Python `DiscoveredTestData`
- New class to transform from DiscoveredTestData to Tests
- Updated `pytest/parserService.ts` to use this new method of discovery
- A bit of a logic re-jig
- start testing to ensure the new discovery works the same as the old
- Fix up test data for path case variance.
- Fix bug with parser throwing on empty input
- Tests for the discoveredTests
- Tests fixed for the discoveryService
- simplify tests for the parserService
- remove a non-unit test from running during unit test runs
- Use `exec` over `execObservable` in running Python for test discovery.
- Create a new interface for test discovery runner.
- needs to be refactored for the new parser model
- tracked by GH microsoft#4735
- Many tests will need refactoring with the new discovery API
Copy link

@DonJayamanne DonJayamanne left a comment

Choose a reason for hiding this comment

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

Please do not merge:

As a result of this:

  • Code lenses will not work (line numbers returned by python code is not used, as user may have modified the code with auto test discover disabled)
  • Selection of tests for running will not display user friendly names

Summary:

Copy link

@DonJayamanne DonJayamanne left a comment

Choose a reason for hiding this comment

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

A lot of the code will change due to the data structure returned by the python code.
Best to wait until that's completed.

if parts.pop(0) != filename:
# TODO: What to do?
if os.path.normcase(parts.pop(0)) != filename:
# The filename of this node doesn't match the filename within the node id?

Choose a reason for hiding this comment

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

We need to file an issue about this and fix this accordingly.
/cc @ericsnowcurrently

pytestargs.insert(0, '-pno:terminal')
pytestargs.insert(0, '--collect-only')
pytestargs.insert(0, '--cache-clear')

Choose a reason for hiding this comment

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

@@ -0,0 +1,94 @@
import json

Choose a reason for hiding this comment

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

Where is this file being used?

@DonJayamanne
Copy link

@d3r3kk
Unfortunately I've got to create a branch from yours and start separately.
I just rebased master onto your branch, but I cannot force push upstream
Your commits won't be lost, so nothing lost, just that it'll end up as a new PR..hope thats ok.

@DonJayamanne
Copy link

@d3r3kk
Better yet, I'm going to create a new branch based off Erics branch and merge your changes on top of that.,, that way i have best of both worlds..

DonJayamanne added a commit that referenced this pull request Apr 11, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jul 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants