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

Adding DataDir to classpath in Scoverage #265

Open
sammy-1234 opened this issue Jun 26, 2019 · 1 comment
Open

Adding DataDir to classpath in Scoverage #265

sammy-1234 opened this issue Jun 26, 2019 · 1 comment
Milestone

Comments

@sammy-1234
Copy link

Currently, the dataDir option is used to specify the path that the instruments and the measurements files are written to.

It would be beneficial to add an option in scoverage to include the dataDir in the classpath. This would provide more flexibility in systems that do not guarantee a local filesystem but a distributed one. For example, in #249, Pants compiles may happen in a remote machine. Classpaths are well-known and would provide a better and more stable future extensibility for the scalac-scoverage-plugin for generating reports in a distributed compilation.

@stuhood
Copy link

stuhood commented Jun 27, 2019

Thanks for opening this @sammy-1234.

To expand on the purpose for this change: in a remote execution environment that uses the Bazel remoting API (so, Bazel, Pants, a few other soon most likely) each 1) compiler invoke, 2) test run, will happen in an anonymous working directory on an unknown machine.

In particular, this means that:

  1. compiler invokes should not have configuration that tries to write to any global shared directories (as with how all compiler invokes with scoverage write to a global dataDir)
  2. test runs should allow configuring where their coverage output is written to at runtime (rather than relying on something that was set at compile time, as scoverage does now with the dataDir).

This ticket proposes to fix both 1 and 2 by changing where the scoverage compiler plugin writes the xml it generates to be written in the compiler's output directory (ie, on the output classpath for the compiled sources). There is a convention of using subdirectories of the META-INF directory for this, meaning that the result in the output directory after compilation would be something like:

/com/example/MyClass.class
/META-INF/scoverage/com/example/MyClass.xml

Then, you would need to change the runtime behaviour of scoverage to consume the XML from the classpath, and to write its outputs to one of:

  1. an environment variable or jvm property specifying a path to write outputs to
  2. a subdirectory of the current working directory if the env/property isn't set

These changes allow for remote execution, but they also allow for caching, as with sbt's hoarder plugin (which would currently break with scoverage, afaict).

@sammy-1234 sammy-1234 changed the title Adding DataDir to classpath in Scoverage for Pants Adding DataDir to classpath in Scoverage Jun 27, 2019
@ckipp01 ckipp01 added this to the 2.0 milestone Sep 27, 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

No branches or pull requests

3 participants