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

Update logic used to parse the args passed into the test frameworks #1917

Merged

Conversation

DonJayamanne
Copy link

Fixes #1070

This pull request:

  • Has a title summarizes what is changing
  • Includes a news entry file (remember to thank yourself!)
  • Has unit tests & code coverage is 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)

@codecov
Copy link

codecov bot commented Jun 9, 2018

Codecov Report

Merging #1917 into master will increase coverage by 0.28%.
The diff coverage is 90.8%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1917      +/-   ##
==========================================
+ Coverage   74.74%   75.03%   +0.28%     
==========================================
  Files         302      307       +5     
  Lines       13721    14058     +337     
  Branches     2436     2493      +57     
==========================================
+ Hits        10256    10548     +292     
- Misses       3330     3373      +43     
- Partials      135      137       +2
Impacted Files Coverage Δ
src/client/common/platform/types.ts 100% <ø> (ø) ⬆️
...lient/unittests/nosetest/services/parserService.ts 86.41% <100%> (+0.16%) ⬆️
...nt/unittests/nosetest/services/discoveryService.ts 100% <100%> (+8.33%) ⬆️
.../application/diagnostics/applicationDiagnostics.ts 100% <100%> (ø) ⬆️
src/client/unittests/serviceRegistry.ts 97.72% <100%> (+0.66%) ⬆️
.../client/unittests/pytest/services/parserService.ts 75.72% <100%> (ø) ⬆️
src/client/unittests/common/runner.ts 91.17% <100%> (+0.85%) ⬆️
src/client/unittests/types.ts 100% <100%> (ø) ⬆️
...ient/unittests/pytest/services/discoveryService.ts 100% <100%> (+4.34%) ⬆️
...lient/unittests/unittest/services/parserService.ts 97.67% <100%> (-0.06%) ⬇️
... and 30 more

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 23da67a...4d600ec. Read the comment docs.

@DonJayamanne DonJayamanne changed the title WIP - Update logic used to parse the args passed into the test frameworks Update logic used to parse the args passed into the test frameworks Jun 11, 2018
@DonJayamanne DonJayamanne force-pushed the issueWIPUnitTestArgsService branch 2 times, most recently from 5ccafa5 to 0bd432e Compare June 18, 2018 19:55
Copy link

@d3r3kk d3r3kk left a comment

Choose a reason for hiding this comment

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

Looks pretty good, sorry it took me so long to complete my review. I have a few things that should be looked at, but for the most part it looks just fine (and I love the doi being added here!).

On the subject of dependency of injection, I see a common pattern where we simply inject the entire ServiceContainer into the constructor of our classes.

Question for you here:
Wouldn't we want to inject the exact containers we need for this class and no more?

For instance:

constructor(
  @inject(IArgumentsHelper) private argsHelper: IArgumentsHelper,
  @inject(ITestRunner) private testRunner: ITestRunner,
  ...etc...
  )

?

@@ -58,14 +58,14 @@ export class AnalysisEngineDownloader {
private async downloadFile(location: string, fileName: string, title: string): Promise<string> {
const uri = `${location}/${fileName}`;
this.output.append(`Downloading ${uri}... `);
const tempFile = await createTemporaryFile(downloadFileExtension);
const tempFile = await this.fs.createTemporaryFile(downloadFileExtension);
Copy link

Choose a reason for hiding this comment

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

Love it - temp file that can be disposed to clean itself up, great.

import { IArgumentsHelper } from '../types';

@injectable()
export class ArgumentsHelper implements IArgumentsHelper {
Copy link

Choose a reason for hiding this comment

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

Is this a bespoke version of something akin to getopt? Could we just make use of a known library that would do this for us? Something that would be extensible enough to add whatever custom processing we need to apply perhaps.

Copy link
Author

Choose a reason for hiding this comment

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

  • Too late in the game to add new deps
  • I don't see the need to create nor use something generic, as this approach of parsing args is a bad approach. But this is what we have today in terms of running tests.

if (Array.isArray(argumentToRemoveOrFilter)) {
argumentToRemoveOrFilter.forEach(item => {
if (OptionsWithArguments.indexOf(item) >= 0) {
optionsWithoutArgsToRemove.push(item);
Copy link

Choose a reason for hiding this comment

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

Did you mean to push the value into optionsWithArgsToRemove here?

Copy link

Choose a reason for hiding this comment

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

(Might want to make the names less similar here to avoid this in future, nonArgOptions, argOptions, something like that).

if (Array.isArray(argumentToRemoveOrFilter)) {
argumentToRemoveOrFilter.forEach(item => {
if (OptionsWithArguments.indexOf(item) >= 0) {
optionsWithoutArgsToRemove.push(item);
Copy link

Choose a reason for hiding this comment

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

optionsWithArgsToRemove again?

@DonJayamanne
Copy link
Author

@d3r3kk Please re-review.

Copy link

@d3r3kk d3r3kk 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 that covers everything, we can discuss the ServiceContainer/DependencyInjection comment I made separately as a team at the onset of an upcoming sprint (see issue #1999).

@DonJayamanne DonJayamanne force-pushed the issueWIPUnitTestArgsService branch from ac5ee79 to b33180b Compare June 19, 2018 15:33
@DonJayamanne DonJayamanne reopened this Jun 19, 2018
@DonJayamanne DonJayamanne merged commit e585a15 into microsoft:master Jun 19, 2018
@DonJayamanne DonJayamanne deleted the issueWIPUnitTestArgsService branch June 20, 2018 03:13
@lock lock bot locked as resolved and limited conversation to collaborators Jul 31, 2019
@lock lock bot unassigned d3r3kk 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.

Many pytest options fails when running specific tests
2 participants