Skip to content

Fix issue 19163: don't count declarations in coverage analysis#8997

Merged
PetarKirov merged 2 commits intodlang:stablefrom
FeepingCreature:fix/issue-19163-decls-counted-in-coverage-analysis
Nov 24, 2018
Merged

Fix issue 19163: don't count declarations in coverage analysis#8997
PetarKirov merged 2 commits intodlang:stablefrom
FeepingCreature:fix/issue-19163-decls-counted-in-coverage-analysis

Conversation

@FeepingCreature
Copy link
Copy Markdown
Contributor

@FeepingCreature FeepingCreature commented Nov 23, 2018

Consider this code:

module test;

void main()
{
    if (false)
    {
        static if (2 == 2)
        {
        }
        else
        {
        }
        alias type = int;
        enum k = 2;
        enum array = [1, 2];
        static foreach (i; array)
        {
        }
    }
}

When run with dmd -cov -run test.d, the alias, enum and static foreach are given coverage counts of 0, despite the fact that they contain no executable code.

This PR fixes that, by only counting coverage for expressions that actually do work at runtime.

@dlang-bot
Copy link
Copy Markdown
Contributor

dlang-bot commented Nov 23, 2018

Thanks for your pull request and interest in making D better, @FeepingCreature! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the annotated coverage diff directly on GitHub with CodeCov's browser extension
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Auto-close Bugzilla Severity Description
19163 minor static/tuple foreach counted incorrectly in coverage analysis

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub fetch digger
dub run digger -- build "stable + dmd#8997"

@FeepingCreature FeepingCreature changed the base branch from master to stable November 23, 2018 14:38
@RazvanN7
Copy link
Copy Markdown
Contributor

Is there any way we can test this?

@FeepingCreature
Copy link
Copy Markdown
Contributor Author

From looking at the test suite, not easily. Would have to make a script to check the generated .lst file after the rest has run, and I have basically no idea how to set that up.

@thewilsonator
Copy link
Copy Markdown
Contributor

This is an enhancement, please target master.

@FeepingCreature
Copy link
Copy Markdown
Contributor Author

It's not a new feature or new functionality, it's a correction of an error in existing functionality.

Lines of code that have no runtime behavior should not have coverage.

@wilzbach
Copy link
Copy Markdown
Contributor

From looking at the test suite, not easily. Would have to make a script to check the generated .lst file after the rest has run, and I have basically no idea how to set that up.

Have a look at the existing tests. You basically start with a shell script, invoke the compiler there, then compare the two files with diff. There are a few environment variables that can by used to set e.g. the output directory to the one of the testsuite.

@FeepingCreature FeepingCreature force-pushed the fix/issue-19163-decls-counted-in-coverage-analysis branch from 4ca5589 to 1e5d581 Compare November 24, 2018 00:31
@thewilsonator
Copy link
Copy Markdown
Contributor

dlang/dub is red. Is this expected on stable?

@FeepingCreature
Copy link
Copy Markdown
Contributor Author

I'm reasonably sure it's spurious.

@thewilsonator
Copy link
Copy Markdown
Contributor

Hmm, I hesitant to pull with such a critical piece of infrastructure failing, I restarted it once already and it failed again.

@FeepingCreature
Copy link
Copy Markdown
Contributor Author

FeepingCreature commented Nov 24, 2018

I'm not sure how I could logically be responsible for "Package dub not found for registry at https://code.dlang.org/".

Try restarting another PR. You should get this error everywhere.

@thewilsonator
Copy link
Copy Markdown
Contributor

Maybe it is a stable thing? I'll recheck tomorrow morning.

@PetarKirov
Copy link
Copy Markdown
Member

PetarKirov commented Nov 24, 2018

The dub interactive remove test has been fixed, but the latest tag (1.12.0) doesn't contain the fix. Compare:
https://github.com/dlang/dub/blob/v1.12.0/test/interactive-remove.sh#L10 with:
https://github.com/dlang/dub/blob/b4b8bf9e7fd5a820ecc79cb8bc8ed18d9f97daae/test/interactive-remove.sh#L10

@PetarKirov
Copy link
Copy Markdown
Member

Auto-merge toggled on

@PetarKirov PetarKirov merged commit 6307b3a into dlang:stable Nov 24, 2018
@PetarKirov
Copy link
Copy Markdown
Member

PetarKirov commented Nov 24, 2018

It looks like the github->bugzilla issue auto-close integration has not yet kicked in. If the issue is not auto-closed in several hours be sure to close it manually and provide a link to this PR.

Actually, I think it waits for the commit to be merged to master.

@FeepingCreature
Copy link
Copy Markdown
Contributor Author

yay

@FeepingCreature FeepingCreature deleted the fix/issue-19163-decls-counted-in-coverage-analysis branch November 24, 2018 13:30
@wilzbach
Copy link
Copy Markdown
Contributor

Actually, I think it waits for the commit to be merged to master.

Yup.

kinke added a commit to kinke/ldc that referenced this pull request Dec 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants