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

Enable more detailed coverage #923

Merged
merged 3 commits into from
Nov 23, 2021
Merged

Conversation

m42e
Copy link
Contributor

@m42e m42e commented Nov 22, 2021

This enables branch based coverage elimination.
Please check if this matches your expectation. I would suggest to have an additional switch to enable the line based coverage as it is quite a break in the behaviour compared to the current one.

Let me know what you think.

@AlexDenisov
Copy link
Member

It's ok to break the current behavior, but I'd strongly recommend adding/extending the suite to reflect the changes.

@m42e
Copy link
Contributor Author

m42e commented Nov 23, 2021

For sure, but just wanted some ok before doing so.

@AlexDenisov
Copy link
Member

For sure, but just wanted some ok before doing so.

That's certainly an improvement, so yes - go for it :)

@m42e
Copy link
Contributor Author

m42e commented Nov 23, 2021

I had something prepared (manual testing so far). Migrated to lit and should confirm it is working as expected. Even works fine on partially covered lines.

@m42e
Copy link
Contributor Author

m42e commented Nov 23, 2021

while scrolling through the code, would you consider something like this more clear @AlexDenisov:

bool FunctionUnderTest::isCovered(const SourceLocation& location) const {
  if (linecoverage.size() == 0){
    return covered;
  }
  bool iscovered = true;
  auto after_start = [&location](auto LineStart, auto ColumnStart){
    return (LineStart < location.line || (LineStart == location.line && ColumnStart <= location.column));
  };
  auto before_end = [&location](auto LineEnd, auto ColumnEnd){
    return (LineEnd > location.line || (LineEnd == location.line && ColumnEnd >= location.column));
  };
  for_each(linecoverage.begin(), linecoverage.end(), [&](const auto & cov){
    if (after_start(cov.LineStart, cov.ColumnStart) && before_end(cov.LineEnd, cov.ColumnEnd)){
      iscovered &= cov.ExecutionCount > 0;
    }
  });
  return iscovered;
}

@AlexDenisov AlexDenisov merged commit f1c4872 into mull-project:main Nov 23, 2021
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