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

Tests and project in two modules #39

Open
Kwestor opened this issue Feb 9, 2015 · 12 comments
Open

Tests and project in two modules #39

Kwestor opened this issue Feb 9, 2015 · 12 comments

Comments

@Kwestor
Copy link
Contributor

Kwestor commented Feb 9, 2015

I think we should move conversation from scoverage/scalac-scoverage-plugin#79, here, as it's more about gradle configuration now, and not about changes to plugin.

@maiflai I tested sample project from gradle samples and while it seems to work (report is generated and classes in report are ok), I believe this report is invalid, as it states 0% coverage.

I included separate-tests in my fork of gradle-scoverage and wrote an acceptance test for it, could you please take a look?

@maiflai
Copy link
Contributor

maiflai commented Feb 9, 2015

Thanks - yes, from running with --info it seems that gradle thinks testScoverage has no inputs and therefore does not need to be run.

I agree that even if I add some inputs to make it run, it still doesn't work. I'll take a closer look at this tomorrow if that's ok?

@Kwestor
Copy link
Contributor Author

Kwestor commented Feb 10, 2015

👍

@Kwestor
Copy link
Contributor Author

Kwestor commented Feb 13, 2015

I have different message:

:a-tests:testScoverage
file or directory 'C:\Users\Jerzy\Workspaces\GitHub\scoverage\gradle-scoverage\src\test\separate-tests\a-tests\build\classes\testScoverage', not found
Skipping task ':a-tests:testScoverage' as it has no source files

@Kwestor
Copy link
Contributor Author

Kwestor commented Feb 13, 2015

It seems like testScoverage source set is not configured properly, but my gradle-fu is not strong enough to deduce how to fix it.

@maiflai
Copy link
Contributor

maiflai commented Feb 13, 2015

Sorry, I've been away the past few days.

Yes, there's something strange going on. I think that we see the testScoverage task being linked to the testScoverage sourceset, which is empty.

I wonder if this occurs because we configure the build twice, once for all subprojects and then again for the test subprojects.

A workaround might be to manually set the testClassesDir:

testScoverage {
testClassesDir = project.sourceSets.test.output.classesDir
}

I think this runs the tests, I'll try to put together a pull request with a better fix for your branch over the weekend.

@Kwestor
Copy link
Contributor Author

Kwestor commented Feb 16, 2015

Thanks, I'll check this workaround for now.

@Kwestor
Copy link
Contributor Author

Kwestor commented Feb 16, 2015

Where should I apply this config for testClassesDir?

@maiflai
Copy link
Contributor

maiflai commented Feb 16, 2015

On review I think that the testClassesDir is insufficient to achieve coverage - it's also necessary to include the instrumented classes from project 'a'.

I've updated Kwestor#1 to add an additional task supporting this.

I can merge this to the main repository if you agree that it's ok?

@Kwestor
Copy link
Contributor Author

Kwestor commented Feb 17, 2015

I will test it, squash into 2 commits and create a PR for it.

Be aware my branch with those tests are based on #37 and #42. I can rebase it on master if you don't want to merge them right now.

@Kwestor
Copy link
Contributor Author

Kwestor commented Feb 17, 2015

Unfortunately I have another issue: if you have a source files in a/src/main report generation fails.

This time it's a problem with scalac-scoverage HTML reporter, I'll try to fix it.

Travis tests passes because if you join two absolute paths on Linux it creates correct path to non-existing file. On windows this path is incorrect, as it have a drive letter in the middle.

@Kwestor
Copy link
Contributor Author

Kwestor commented Feb 18, 2015

@maiflai do you know an easy way of excluding files in a/src/main from coverage?

@maiflai
Copy link
Contributor

maiflai commented Feb 23, 2015

Sorry for the lack of comms, I've been away from the computer for the past week or so.

re: the HTML path issue, I thought this was resolved, I'll take a closer look this week.

I think excluding files from coverage can be done either at the file or the class level:

// behaviour of scalac plugin is detailed in scoverage.RegexCoverageFilterTest
scoverage {
  excludedFiles = [ 'path/to/file.scala', 'path/to/another/file.scala' ] 
  excludedPackages = [ 'path.to.* ] 
}

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

No branches or pull requests

2 participants