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

Support for tests in separate project #43

Merged
merged 7 commits into from
Jul 5, 2015

Conversation

Kwestor
Copy link
Contributor

@Kwestor Kwestor commented Feb 17, 2015

To be reviewed and merged after #37 and #42 - it bases on those PRs.

Tests are written by me, solution to make them work by @maiflai - big thanks!

For my part, disclaimer required by the lawyers (it's covered by Apache 2, but they want me to include it in PR description):

THE FOLLOWING DISCLAIMER APPLIES TO ALL SOFTWARE CODE AND OTHER MATERIALS CONTRIBUTED IN CONNECTION WITH THIS SOFTWARE:
THIS SOFTWARE IS LICENSED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AND ANY WARRANTY OF NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THIS SOFTWARE MAY BE REDISTRIBUTED TO OTHERS ONLY BY EFFECTIVELY USING THIS OR ANOTHER EQUIVALENT DISCLAIMER IN ADDITION TO ANY OTHER REQUIRED LICENSE TERMS.
ONLY THE SOFTWARE CODE AND OTHER MATERIALS CONTRIBUTED IN CONNECTION WITH THIS SOFTWARE, IF ANY, THAT ARE ATTACHED TO (OR OTHERWISE ACCOMPANY) THIS SUBMISSION (AND ORDINARY COURSE CONTRIBUTIONS OF FUTURES PATCHES THERETO) ARE TO BE CONSIDERED A CONTRIBUTION. NO OTHER SOFTWARE CODE OR MATERIALS ARE A CONTRIBUTION.

Kwestor and others added 4 commits February 10, 2015 09:52
In sbt-scoverage plugin, report task is much more detailed. This commit
updates gradle version of report task to be on par with it's sbt
counterpart.

Updated version of task brings 4 new configuration parameters:

 - coverageOutputCobertura
 - coverageOutputXML
 - coverageOutputHTML
 - coverageDebug

All could be used to enable/disable different outputs. All but last one
defaults to true. Readme is updated with this information.

Code in `ScoverageWriter.java` is re-written from sbt-scoverage and
converted to Java. It could be moved to scalac-scoverage-runtime to be
used by all plugins. It's not inlined in `SingleReportApp.java` because
it'll be used also in ScoverageAggregate task (in next PR).

If there is no test data in project report task now only issues a warning
and not crash (it's important for multi-project setups without test
code/code to test in some sub-projects).
Aggregate task now use settings to configure which outputs should be
aggregated (HTML, XML, debug XML and cobertura).

Tests for aggregation added using dummy test project ('water').
Currently report is generated, but coverage is wrong, so tests fail.
Provide an instrumented jar for dependent projects.

Use closeTo to verify coverage.

Let 'a-test' address the published scoverage artifacts directly.

checkScoverage should also only be run on the a-test project.
@Kwestor
Copy link
Contributor Author

Kwestor commented Feb 17, 2015

Do not merge - last commit fails on windows and passes on Linux by accident (results are still incorrect).

@Kwestor Kwestor force-pushed the tests/separate-tests branch from 865dc70 to 0eeeb59 Compare February 18, 2015 13:15
@maiflai
Copy link
Contributor

maiflai commented Mar 1, 2015

Unfortunately the report is broken because the compilation of the class in a-tests/src/main/scala overwrites the measurement file created earlier during the instrumentation of a/src/main/scala.

The a main classes remain instrumented, so I expect that we will see a corrupted report where statements from a are attributed to statements from a-tests.

@sksamuel - I think this is related to the discussion earlier about multiple compilation runs? scoverage/scalac-scoverage-plugin#81 (comment)

@maiflai
Copy link
Contributor

maiflai commented Mar 1, 2015

From my perspective it's an uncommon project structure, but I think we should be able to support such a thing.

@Kwestor
Copy link
Contributor Author

Kwestor commented Mar 2, 2015

I was puzzled at first why it's structured this way, but it makes sense if you think about it:

  • a
    • main (code to test here)
  • a-tests (depends on a)
    • main (commons for testing a-related stuff)
    • test (tests for a)
  • b (depends on a)
  • b-tests (dependes on commons from a-tests)

This way you don't have to publish test artifacts from a-tests to use it in b-tests. And you do publish only the commons for tests, not everything.

@maiflai
Copy link
Contributor

maiflai commented Mar 4, 2015

I'll see if my git-fu improves overnight, but I think that adding the following to the test subproject configuration helps things:

  sourceSets {
    testScoverage {
      compileClasspath += sourceSets.main.output
      runtimeClasspath += sourceSets.main.output
    }
  }
  compileScoverageScala {
    onlyIf { false }
  }

This instructs gradle to not instrument a-tests/src/main/scala and use the un-instrumented classes instead.

@sksamuel
Copy link
Member

@maiflai what's the status with these PRs ?

maiflai added a commit that referenced this pull request Jul 5, 2015
Support for tests in separate project
@maiflai maiflai merged commit 1f23733 into scoverage:master Jul 5, 2015
@Kwestor
Copy link
Contributor Author

Kwestor commented Jul 5, 2015

Thanks!

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.

3 participants