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

Increase Code Quality By Increasing Code Coverage: lib/parse-args.js #447

Closed
wants to merge 1 commit into from

Conversation

mcknasty
Copy link
Contributor

@mcknasty mcknasty commented Jan 17, 2023

Pull Request 447

Increase code quality by increasing code coverage: lib/parse-args.js

refactor: bumping code coverage to 100% for lib/parse-args.js. (#447)
test: Adding a test case for NODE_V8_COVERAGE and changing the describe block title. (#447)
test: Early exit branch test for hideInstrumenteeArgs function. (#447)
test: Adding test for relative paths for relative report directory cli option. (#447)
test: Adding test case for relative paths for temporary directory cli option. (#447)
test: Adding test for passing node.js arguments to c8. (#447)

Following the Contributions Recommendations here.

  1. Make sure you have installed the latest version of Node.js
  2. Fork this project on GitHub and clone your fork locally
  3. Create local branches to work within. These should also be created directly from the main branch. Local Fork here.
  4. Make your changes.
  5. Run tests to make sure all is okay (everything should pass except the snapshot).
    1. A complete log of initial test results.
    2. As instructed, ignore snapshot failures. 0 failures
    3. 100 passing in 48 seconds
  6. Now update the snapshot.
    1. A complete log of snapshot test results.
    2. 100 passing in 48 seconds
  7. If all is passing, commit your changes. The log of the commit can be found here.
  8. As a best practice, once you have committed your changes, it is a good idea to use git rebase (not git merge) to synchronize your work with the main repository.
  9. Run tests again to make sure all is okay.
    1. A complete log of the final test results.
    2. 100 passing in 48 seconds
  10. Push
  11. Open the pull request, see details in the template.
  12. Make any necessary changes after review.

File Code Coverage Matrix Report

Test Type File Statement Branch Function Lines
Final Test lib/parse-args.js 100% 100% 100% 100%
Node 14.21.3 lib/parse-args.js 100% 100% 100% 100%
Node 16.20.2 lib/parse-args.js 100% 100% 100% 100%
Node 18.19.0 lib/parse-args.js 100% 100% 100% 100%
Node 20.11.0 lib/parse-args.js 100% 100% 100% 100%

Unit Tests Results

All tests run on Node version 18.19.0

Test Type PASS Tests Passed Tests Failed Time
Initial Test ✔️ 100 passing 0 failures 48 seconds
Snapshot Test ✔️ 100 passing 0 failures 48 seconds
Final Test ✔️ 100 passing 0 failures 48 seconds

Node Version Testing Matrix

Node Version PASS Tests Passed Tests Failed Time
14.21.3 ✔️ 100 passing 0 failures 55 seconds
16.20.2 ✔️ 100 passing 0 failures 1 minutes
18.19.0 ✔️ 100 passing 0 failures 55 seconds
20.11.0 ✔️ 100 passing 0 failures 1 minutes

Referencing Issue #448

Updated 2023-07-29 7:59 PM EST
Updated 2023-07-30 11:25 AM EST
Updated 2024-01-14 9:03 PM EST

@mcknasty mcknasty force-pushed the parse-args-code-coverage branch from 8978fe1 to 175d031 Compare January 17, 2023 16:06
@mcknasty mcknasty changed the title Parse args code coverage lib/parse-args.js improved code coverage Jan 17, 2023
Copy link
Owner

@bcoe bcoe left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution, I'm excited to improve the coverage of c8.

In this PR specifically, I don't like that it changes the behaviour in subtle ways:

  • default will no longer give a hint in the UI that shows that we've defaulted to NODE_V8_COVERAGE.
  • The path of tempDirectory will no longer be an absolute path (./tmp, vs., /full/path/to/tmp).

I think you should be able to get coverage up without making these changes, one option would be just adding some ignore lines if necessary (since the logic is part of the setup of yargs, and not really part of the application logic).

mcknasty added a commit to mcknasty/c8 that referenced this pull request Jan 28, 2023
…e#447)

Test: Adding a test case for NODE_V8_COVERAGE and changing the describe block title. (bcoe#447)
@mcknasty mcknasty force-pushed the parse-args-code-coverage branch from 175d031 to ba0acbc Compare January 28, 2023 07:09
mcknasty

This comment was marked as outdated.

mcknasty added a commit to mcknasty/c8 that referenced this pull request Jan 28, 2023
…e#447)

test: Adding a test case for NODE_V8_COVERAGE and changing the describe block title. (bcoe#447)
@mcknasty mcknasty force-pushed the parse-args-code-coverage branch from 704bce3 to fbe5d72 Compare January 28, 2023 22:57
lib/parse-args.js Outdated Show resolved Hide resolved
mcknasty added a commit to mcknasty/c8 that referenced this pull request Jan 29, 2023
…e#447)

test: Adding a test case for NODE_V8_COVERAGE and changing the describe block title. (bcoe#447)
test: Ealry exit branch test for hideInstrumenteeArgs function. (bcoe#447)
test: Adding test for relative paths for relative report directories. (bcoe#447)
@mcknasty mcknasty force-pushed the parse-args-code-coverage branch from fbe5d72 to 0eef52a Compare January 29, 2023 22:46
lib/parse-args.js Outdated Show resolved Hide resolved
mcknasty added a commit to mcknasty/c8 that referenced this pull request Feb 1, 2023
refactor: bumping code coverage to 100% for lib/parse-args.js. (bcoe#447)
test: Adding a test case for NODE_V8_COVERAGE and changing the describe block title. (bcoe#447)
test: Ealry exit branch test for hideInstrumenteeArgs function. (bcoe#447)
test: Adding test for relative paths for relative report directory cli option. (bcoe#447)
test: Adding test case for relative paths for temporary directory cli
option. (bcoe#447)
test: Adding test for passing node.js arguments to c8. (bcoe#447)
@mcknasty mcknasty force-pushed the parse-args-code-coverage branch from 0eef52a to 692ec75 Compare February 1, 2023 22:24
@mcknasty mcknasty requested a review from bcoe February 1, 2023 23:47
@mcknasty mcknasty changed the title lib/parse-args.js improved code coverage Increase Code Quality By Increasing Code Coverage: lib/parse-args.js improved code coverage Feb 4, 2023
@mcknasty mcknasty changed the title Increase Code Quality By Increasing Code Coverage: lib/parse-args.js improved code coverage Increase Code Quality By Increasing Code Coverage: lib/parse-args.js Feb 4, 2023
test/parse-args.js Outdated Show resolved Hide resolved
lib/parse-args.js Outdated Show resolved Hide resolved
Copy link
Owner

@bcoe bcoe left a comment

Choose a reason for hiding this comment

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

Left a couple nits, I'd rather avoid changing behaviour around path resolution. The reason being that people have complicated setups with c8, where they run it in different directories, run it against output from web browsers (which may have files within them that are not relative to the director that c8 is running in, etc).

tldr; it might be okay to resolve the reportsDir/tmpDir, but it may have unintended consequences upstream.

Perhaps I'm being too cautious, but I'd rather not change this part of the library (unless we're trying to address outstanding bugs, and have a regression test).

@mcknasty
Copy link
Contributor Author

mcknasty commented Jul 29, 2023

The issue of the check function mentioned above has come up a few times as I have been working on yargs related feature requests and code coverage reports. I outlined the issue as I saw it in #489. Furthermore, merging pull request #436 could change the delta of this pull request a fair amount. I suggest that I outline the various ways of setting the temp directory and then write unit tests against those scenarios. I think we can revisit this issue once these few dependencies are complete.

@bcoe

mcknasty added a commit to mcknasty/c8 that referenced this pull request Jul 29, 2023
refactor: bumping code coverage to 100% for lib/parse-args.js. (bcoe#447)
test: Adding a test case for NODE_V8_COVERAGE and changing the describe block title. (bcoe#447)
test: Ealry exit branch test for hideInstrumenteeArgs function. (bcoe#447)
test: Adding test for relative paths for relative report directory cli option. (bcoe#447)
test: Adding test case for relative paths for temporary directory cli
option. (bcoe#447)
test: Adding test for passing node.js arguments to c8. (bcoe#447)
@mcknasty mcknasty force-pushed the parse-args-code-coverage branch from 692ec75 to 2c7bd7e Compare July 29, 2023 21:09
mcknasty added a commit to mcknasty/c8 that referenced this pull request Jul 30, 2023
refactor: bumping code coverage to 100% for lib/parse-args.js. (bcoe#447)
test: Adding a test case for NODE_V8_COVERAGE and changing the describe block title. (bcoe#447)
test: Early exit branch test for hideInstrumenteeArgs function. (bcoe#447)
test: Adding test for relative paths for relative report directory cli option. (bcoe#447)
test: Adding test case for relative paths for temporary directory cli option. (bcoe#447)
test: Adding test for passing node.js arguments to c8. (bcoe#447)
@mcknasty mcknasty force-pushed the parse-args-code-coverage branch from 2c7bd7e to 909e209 Compare July 30, 2023 00:09
mcknasty added a commit to mcknasty/c8 that referenced this pull request Jul 30, 2023
refactor: bumping code coverage to 100% for lib/parse-args.js. (bcoe#447)
test: Adding a test case for NODE_V8_COVERAGE and changing the describe block title. (bcoe#447)
test: Early exit branch test for hideInstrumenteeArgs function. (bcoe#447)
test: Adding test for relative paths for relative report directory cli option. (bcoe#447)
test: Adding test case for relative paths for temporary directory cli option. (bcoe#447)
test: Adding test for passing node.js arguments to c8. (bcoe#447)
@mcknasty mcknasty force-pushed the parse-args-code-coverage branch from 909e209 to 04b0e61 Compare July 30, 2023 14:33
mcknasty added a commit to mcknasty/c8 that referenced this pull request Jul 30, 2023
refactor: bumping code coverage to 100% for lib/parse-args.js. (bcoe#447)
test: Adding a test case for NODE_V8_COVERAGE and changing the describe block title. (bcoe#447)
test: Early exit branch test for hideInstrumenteeArgs function. (bcoe#447)
test: Adding test for relative paths for relative report directory cli option. (bcoe#447)
test: Adding test case for relative paths for temporary directory cli option. (bcoe#447)
test: Adding test for passing node.js arguments to c8. (bcoe#447)
@mcknasty mcknasty force-pushed the parse-args-code-coverage branch from 04b0e61 to 80fe2ac Compare July 30, 2023 14:39
@mcknasty mcknasty marked this pull request as draft July 30, 2023 16:16
mcknasty added a commit to mcknasty/c8 that referenced this pull request Jan 14, 2024
refactor: bumping code coverage to 100% for lib/parse-args.js. (bcoe#447)
test: Adding a test case for NODE_V8_COVERAGE and changing the describe block title. (bcoe#447)
test: Early exit branch test for hideInstrumenteeArgs function. (bcoe#447)
test: Adding test for relative paths for relative report directory cli option. (bcoe#447)
test: Adding test case for relative paths for temporary directory cli option. (bcoe#447)
test: Adding test for passing node.js arguments to c8. (bcoe#447)
test: relative directories for tempDirectoy and reportDir
@mcknasty mcknasty force-pushed the parse-args-code-coverage branch from 80fe2ac to eada810 Compare January 14, 2024 23:35
mcknasty added a commit to mcknasty/c8 that referenced this pull request Jan 14, 2024
refactor: bumping code coverage to 100% for lib/parse-args.js. (bcoe#447)
test: Adding a test case for NODE_V8_COVERAGE and changing the describe block title. (bcoe#447)
test: Early exit branch test for hideInstrumenteeArgs function. (bcoe#447)
test: Adding test for relative paths for relative report directory cli option. (bcoe#447)
test: Adding test case for relative paths for temporary directory cli option. (bcoe#447)
test: Adding test for passing node.js arguments to c8. (bcoe#447)
test: relative directories for tempDirectoy and reportDir
@mcknasty mcknasty force-pushed the parse-args-code-coverage branch from eada810 to 977cead Compare January 14, 2024 23:47
mcknasty added a commit to mcknasty/c8 that referenced this pull request Jan 15, 2024
refactor: bumping code coverage to 100% for lib/parse-args.js. (bcoe#447)
test: Adding a test case for NODE_V8_COVERAGE and changing the describe block title. (bcoe#447)
test: Early exit branch test for hideInstrumenteeArgs function. (bcoe#447)
test: Adding test for relative paths for relative report directory cli option. (bcoe#447)
test: Adding test case for relative paths for temporary directory cli option. (bcoe#447)
test: Adding test for passing node.js arguments to c8. (bcoe#447)
test: relative directories for tempDirectoy and reportDir
@mcknasty mcknasty force-pushed the parse-args-code-coverage branch from 977cead to 5ca85f9 Compare January 15, 2024 00:14
mcknasty added a commit to mcknasty/c8 that referenced this pull request Jan 15, 2024
refactor: bumping code coverage to 100% for lib/parse-args.js. (bcoe#447)
test: Adding a test case for NODE_V8_COVERAGE and changing the describe block title. (bcoe#447)
test: Early exit branch test for hideInstrumenteeArgs function. (bcoe#447)
test: Adding test for relative paths for relative report directory cli option. (bcoe#447)
test: Adding test case for relative paths for temporary directory cli option. (bcoe#447)
test: Adding test for passing node.js arguments to c8. (bcoe#447)
test: relative directories for tempDirectoy and reportDir
@mcknasty mcknasty force-pushed the parse-args-code-coverage branch from 5ca85f9 to 7e61196 Compare January 15, 2024 02:05
mcknasty added a commit to mcknasty/c8 that referenced this pull request Jan 15, 2024
refactor: bumping code coverage to 100% for lib/parse-args.js. (bcoe#447)
test: Adding a test case for NODE_V8_COVERAGE and changing the describe block title. (bcoe#447)
test: Early exit branch test for hideInstrumenteeArgs function. (bcoe#447)
test: Adding test for relative paths for relative report directory cli option. (bcoe#447)
test: Adding test case for relative paths for temporary directory cli option. (bcoe#447)
test: Adding test for passing node.js arguments to c8. (bcoe#447)
test: relative directories for tempDirectoy and reportDir
@mcknasty mcknasty force-pushed the parse-args-code-coverage branch from 7e61196 to 29d3e1a Compare January 15, 2024 03:23
mcknasty added a commit to mcknasty/c8 that referenced this pull request Jan 15, 2024
refactor: bumping code coverage to 100% for lib/parse-args.js. (bcoe#447)
test: Adding a test case for NODE_V8_COVERAGE and changing the describe block title. (bcoe#447)
test: Early exit branch test for hideInstrumenteeArgs function. (bcoe#447)
test: Adding test for relative paths for relative report directory cli option. (bcoe#447)
test: Adding test case for relative paths for temporary directory cli option. (bcoe#447)
test: Adding test for passing node.js arguments to c8. (bcoe#447)
test: relative directories for tempDirectoy and reportDir
@mcknasty mcknasty force-pushed the parse-args-code-coverage branch from 29d3e1a to ba84f60 Compare January 15, 2024 05:16
@mcknasty mcknasty marked this pull request as ready for review January 15, 2024 05:21
@mcknasty mcknasty requested a review from bcoe January 15, 2024 05:21
mcknasty added a commit to mcknasty/c8 that referenced this pull request Jan 20, 2024
refactor: bumping code coverage to 100% for lib/parse-args.js. (bcoe#447)
test: Adding a test case for NODE_V8_COVERAGE and changing the describe block title. (bcoe#447)
test: Early exit branch test for hideInstrumenteeArgs function. (bcoe#447)
test: Adding test for relative paths for relative report directory cli option. (bcoe#447)
test: Adding test case for relative paths for temporary directory cli option. (bcoe#447)
test: Adding test for passing node.js arguments to c8. (bcoe#447)
@mcknasty mcknasty force-pushed the parse-args-code-coverage branch from 92d9ab4 to 2c5f1b2 Compare January 20, 2024 09:48
refactor: removing / testing lines of code for lib/parse-args.js to increase coverage. (bcoe#447)
test: Adding a test case for NODE_V8_COVERAGE and changing the describe block title. (bcoe#447)
test: Early exit branch test for hideInstrumenteeArgs function. (bcoe#447)
test: Adding test for relative paths for relative report directory cli option. (bcoe#447)
test: Adding test case for relative paths for temporary directory cli option. (bcoe#447)
test: Adding test for passing node.js arguments to c8. (bcoe#447)
@mcknasty mcknasty force-pushed the parse-args-code-coverage branch from 2c5f1b2 to dcd63a5 Compare January 20, 2024 17:33
Comment on lines +52 to +62
/** Commenting out till the print config PR is ready * /
it('should set it if undefined', () => {
const NODE_V8_COVERAGE = process.env.NODE_V8_COVERAGE
process.env.NODE_V8_COVERAGE = undefined
process.argv = ['node', 'c8', '--foo=99', 'my-app', '--help']
const argv = buildYargs().parse(hideInstrumenteeArgs())
argv.tempDirectory.endsWith('/coverage/tmp').should.be.equal(true)
delete process.env.NODE_V8_COVERAGE
process.env.NODE_V8_COVERAGE = NODE_V8_COVERAGE
})
/** */
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another candidate for updating unit tests as it relates to (#516)

Comment on lines +52 to +62
/** Commenting out till the print config PR is ready * /
it('should set it if undefined', () => {
const NODE_V8_COVERAGE = process.env.NODE_V8_COVERAGE
process.env.NODE_V8_COVERAGE = undefined
process.argv = ['node', 'c8', '--foo=99', 'my-app', '--help']
const argv = buildYargs().parse(hideInstrumenteeArgs())
argv.tempDirectory.endsWith('/coverage/tmp').should.be.equal(true)
delete process.env.NODE_V8_COVERAGE
process.env.NODE_V8_COVERAGE = NODE_V8_COVERAGE
})
/** */
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Need to uncomment and skip this test.

@mcknasty mcknasty marked this pull request as draft January 22, 2024 00:17
@bcoe bcoe closed this Jun 9, 2024
mcknasty added a commit to mcknasty/c8 that referenced this pull request Jul 17, 2024
refactor: removing / testing lines of code for lib/parse-args.js to increase coverage. (bcoe#447)
test: Adding a test case for NODE_V8_COVERAGE and changing the describe block title. (bcoe#447)
test: Early exit branch test for hideInstrumenteeArgs function. (bcoe#447)
test: Adding test for relative paths for relative report directory cli option. (bcoe#447)
test: Adding test case for relative paths for temporary directory cli option. (bcoe#447)
test: Adding test for passing node.js arguments to c8. (bcoe#447)
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

Successfully merging this pull request may close these issues.

2 participants