Skip to content

-coverage-out generates wrong source paths on java 1.8 runtime #15233

Closed
@pikinier20

Description

@pikinier20

Compiler version

3.2.0-RC1-bin-20220517-e5abec0-NIGHTLY

8bae490

Minimized code

Let's create a file GoodCoverage.scala:

object GoodCoverage {

  def sum(num1: Int, num2: Int) = {
    if (0 == num1) num2 else if (0 == num2) num1 else num1 + num2
  }

}

then let's try to compile it using java 1.8 runtime (I've used jenv for that) and set the coverage flag:

 ~/dotty/dist/target/pack/bin/scalac -coverage-out:scoverage.coverage GoodCoverage.scala

Output

The generated coverage file contains wrong paths to sources:

../GoodCoverage.scala

The .. part is wrong because this file is present in the cwd.

Expectation

The path should be the same as when using java 11+ runtime:

GoodCoverage.scala

This issue is blocking addition of support for Scala 3 in sbt-scoverage: scoverage/sbt-scoverage#429

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:coverageCode coverage, see https://dotty.epfl.ch/docs/internals/coverage.htmlitype:bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions