Skip to content

Correct testlaunch python script to discover individual unit tests#2332

Merged
d3r3kk merged 8 commits into
microsoft:masterfrom
d3r3kk:issue2241
Aug 8, 2018
Merged

Correct testlaunch python script to discover individual unit tests#2332
d3r3kk merged 8 commits into
microsoft:masterfrom
d3r3kk:issue2241

Conversation

@d3r3kk
Copy link
Copy Markdown

@d3r3kk d3r3kk commented Aug 3, 2018

Do not break after discovering suite, still check for individual tests

Fix for issue #2241

  • Title summarizes what is changing
  • Includes a news entry file (remember to thank yourself!)
  • Unit tests & code coverage are not adversely affected (within reason)
  • Works on all actively maintained versions of Python (e.g. Python 2.7 & the latest Python 3 release)
  • Works on Windows 10, macOS, and Linux (e.g. considered file system case-sensitivity)

- do not break after discovering suite, still check for individual tests
- fix for issue microsoft#2241
@d3r3kk d3r3kk closed this Aug 3, 2018
@d3r3kk
Copy link
Copy Markdown
Author

d3r3kk commented Aug 3, 2018

Transient timeout during unit tests on VSTS for Unit Tests - argsService :: pytest?

@d3r3kk d3r3kk reopened this Aug 3, 2018
@codecov
Copy link
Copy Markdown

codecov Bot commented Aug 3, 2018

Codecov Report

Merging #2332 into master will increase coverage by 0.29%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2332      +/-   ##
==========================================
+ Coverage   75.69%   75.98%   +0.29%     
==========================================
  Files         309      309              
  Lines       14341    14341              
  Branches     2540     2540              
==========================================
+ Hits        10855    10897      +42     
+ Misses       3476     3434      -42     
  Partials       10       10
Flag Coverage Δ
#MacOS 74.21% <ø> (+0.31%) ⬆️
#Windows 74.29% <ø> (+0.33%) ⬆️
Impacted Files Coverage Δ
src/client/linters/baseLinter.ts 90.52% <0%> (+1.05%) ⬆️
src/client/unittests/unittest/socketServer.ts 82.19% <0%> (+56.16%) ⬆️

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 44486e5...b3a9ffc. Read the comment docs.

Copy link
Copy Markdown

@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.

Can we create some tests for this. We already have some system tests for unit tests, at least need one more with a different layout (folder structure) of a workspaces to cover this scenario.

@d3r3kk
Copy link
Copy Markdown
Author

d3r3kk commented Aug 8, 2018

Added some further system (not unit!) tests to ensure we've tested for this issue in the future.

Note: I also removed the use of mocha.ITestCallback.skip() throughout our unittests with this change. We probably shouldn't use skip() in this manner (if at all possible). Counting skipped tests/being aware of skipped tests and the reasons they were skipped for a useful quantity to have between releases.

Comment thread src/test/common.ts
return;
}
await settings.update(setting, value, configTarget);
await sleep(2000);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why are we removing this?

Copy link
Copy Markdown
Author

@d3r3kk d3r3kk Aug 8, 2018

Choose a reason for hiding this comment

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

Eric and I discussed this and we couldn't understand why was it there. When I took it out, the build machines as well as my local machine succeed when running the tests.

I will certainly put it back, but I think a comment would be helpful. What would that comment be?

Edit: Remove pre-caffeine abruptness from my original comment (apologies!)...

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This was added to ensure config changes took place and VSC had sufficient time to read to the changes. VSC broke there times (official regressions) in this space.
I.e. previously, even though we call VSC API to update settings, using the get methods we could see the changes were still stale!!!

Copy link
Copy Markdown

@DonJayamanne DonJayamanne Aug 8, 2018

Choose a reason for hiding this comment

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

I should have added comments.
Please add comments something along the lines of:
sometimes VSC returns stake data even after invoking the update method. This issue was reported and resoled numerous times in VSC. This delay is merely a backup to ensure it extension doesn't break the tests due to similar regressions in VSC

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I'll put it back the way it was and add the comment then, thanks for the clarification.

I'll open an issue about this and we can discuss as a team there. #2356.

expect(testDirs[0]).to.equal(dir);
expect(testDirs[1]).to.equal(dir2);
});
if (product === Product.unittest) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sometimes, having a skip inside the function is more readable, as in the way the code was earlier. Right now we have too many top level if blocks (outside the functions ) that reduces readability.

I.e. earlier code was better, as all functions were at one level and easy to read.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Please don't change this code.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Hmmm... I'm not entirely sure I agree on that being more readable, that is, I think we can make it more readable in other ways such as separating out the various high-level cases into their own test suites.

What I really didn't agree with was polluting the output of the CI automation with "Skipped Test" warnings.

Before my change:
image

After my change:
image

...so I reduced the count of skipped tests, but we still have work to do.

It's good to have Skipped Test warnings for tests that have been actually skipped for a legit test-related reason. I think a legitimate reason to skip a test is while we are waiting for a fix for some upstream bug, for instance.

I don't feel that skipping a test just to suit the logic of the test setup is a good use for this, which is why I changed it.

In this particular test class, there is not many tests that overlap - 5 common, 6 pytest, 4 unittest, and 2 for nosetest.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

We chatted about this in the standup today and came to the conclusion that the readability issue isn't improved by my change. However, we can improve on it further (and make our unit test suites even more succinct) by splitting out the test suites for each Python unit test type. I'll do this today.

@DonJayamanne thanks for the review, we'll get this nailed down!

d3r3kk added 2 commits August 8, 2018 11:24
- improve readability of our unit tests
- improve intent of our unit tests
- remove use of `.skip()` to suite test execution logic
- remove unnecessary tslint warning suppressions
@d3r3kk d3r3kk merged commit c3a04cd into microsoft:master Aug 8, 2018
@d3r3kk d3r3kk deleted the issue2241 branch August 8, 2018 23:38
@lock lock Bot locked as resolved and limited conversation to collaborators Jul 31, 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.

2 participants