Skip to content

Commit 605b752

Browse files
authored
Fixing tests on CI (#300)
* Fixing tests on CI * Fixing tests on CI * Fixing tests on CI * Fixing tests on CI * Fixing tests on CI * Fixing tests on CI * Fixing tests on CI * Fixing tests on CI * Fixing tests on CI * Fixing tests on CI * Fixing tests on CI * Fixing tests on CI
1 parent 6d7da02 commit 605b752

File tree

6 files changed

+32
-20
lines changed

6 files changed

+32
-20
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
java-version: 11
2727

2828
- name: run tests
29-
run: sbt ++2.12.12 test
29+
run: sbt ++2.12.10 test
3030

3131
scala-2_13:
3232
runs-on: ubuntu-latest

.github/workflows/pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
java-version: 11
2323

2424
- name: run tests
25-
run: sbt ++2.12.12 test
25+
run: sbt ++2.12.10 test
2626

2727
scala-2_13:
2828
runs-on: ubuntu-latest

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jdk:
77
- openjdk8
88

99
scala:
10-
- 2.12.12
10+
- 2.12.10
1111
- 2.13.3
1212

1313
before_cache:

build.sbt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ val ScalatestVersion = "3.1.1"
1010

1111
val appSettings = Seq(
1212
organization := Org,
13-
scalaVersion := "2.13.3",
14-
crossScalaVersions := Seq("2.12.12", "2.13.3"),
13+
scalaVersion := "2.12.10",
14+
crossScalaVersions := Seq("2.12.10", "2.13.3"),
1515
fork in Test := false,
1616
publishMavenStyle := true,
1717
publishArtifact in Test := false,
@@ -24,6 +24,9 @@ val appSettings = Seq(
2424
else
2525
Some("releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2")
2626
},
27+
libraryDependencies ++= Seq(
28+
"org.scala-lang" % "scala-compiler" % scalaVersion.value % Compile
29+
),
2730
pomExtra := {
2831
<url>https://github.com/scoverage/scalac-scoverage-plugin</url>
2932
<licenses>
@@ -89,11 +92,10 @@ lazy val plugin = Project("scalac-scoverage-plugin", file("scalac-scoverage-plug
8992
.settings(
9093
libraryDependencies ++= Seq(
9194
"org.scala-lang.modules" %% "scala-xml" % "1.2.0",
92-
"org.scalatest" %% "scalatest" % ScalatestVersion % Test,
93-
"org.scala-lang" % "scala-compiler" % scalaVersion.value % Provided
95+
"org.scalatest" %% "scalatest" % ScalatestVersion % Test
9496
)
9597
)
9698
.settings(
97-
unmanagedSourceDirectories in Test += (sourceDirectory in Test).value / "scala-2.11+"
99+
unmanagedSourceDirectories in Test += (sourceDirectory in Test).value / "scala-2.12+"
98100
)
99101

scalac-scoverage-plugin/src/test/scala/scoverage/ScoverageCompiler.scala

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ import java.io.{File, FileNotFoundException}
44
import java.net.URL
55

66
import scala.collection.mutable.ListBuffer
7-
import scala.tools.nsc.{Settings, Global}
7+
import scala.tools.nsc.{Global, Settings}
88
import scala.tools.nsc.plugins.PluginComponent
99
import scala.tools.nsc.transform.{Transform, TypingTransformers}
1010

11-
/** @author Stephen Samuel */
1211
object ScoverageCompiler {
1312

14-
val ScalaVersion = scala.util.Properties.versionNumberString
15-
val ShortScalaVersion = (ScalaVersion split "[.]").toList match {
13+
val ScalaVersion: String = scala.util.Properties.versionNumberString
14+
val ShortScalaVersion: String = (ScalaVersion split "[.]").toList match {
1615
case init :+ last if last forall (_.isDigit) => init mkString "."
17-
case _ => ScalaVersion
16+
case _ => ScalaVersion
1817
}
1918

20-
def classPath = getScalaJars.map(_.getAbsolutePath) :+ sbtCompileDir.getAbsolutePath :+ runtimeClasses.getAbsolutePath
19+
def classPath: Seq[String] =
20+
getScalaJars.map(_.getAbsolutePath) :+ sbtCompileDir.getAbsolutePath :+ runtimeClasses.getAbsolutePath
2121

2222
def settings: Settings = {
2323
val s = new scala.tools.nsc.Settings
@@ -57,15 +57,25 @@ object ScoverageCompiler {
5757

5858
private def runtimeClasses: File = new File(s"./scalac-scoverage-runtime/jvm/target/scala-$ShortScalaVersion/classes")
5959

60-
private def findScalaJar(artifactId: String): File = findIvyJar("org.scala-lang", artifactId, ScalaVersion)
60+
private def findScalaJar(artifactId: String): File =
61+
findIvyJar("org.scala-lang", artifactId, ScalaVersion)
62+
.orElse(findCoursierJar(artifactId, ScalaVersion))
63+
.getOrElse {
64+
throw new FileNotFoundException(s"Could not locate $artifactId/$ScalaVersion")
65+
}
66+
67+
private def findCoursierJar(artifactId: String, version: String): Option[File] = {
68+
val userHome = System.getProperty("user.home")
69+
val jarPath = s"$userHome/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/$artifactId/$version/$artifactId-$version.jar"
70+
val file = new File(jarPath)
71+
if (file.exists()) Some(file) else None
72+
}
6173

62-
private def findIvyJar(groupId: String, artifactId: String, version: String, packaging: String = "jar"): File = {
74+
private def findIvyJar(groupId: String, artifactId: String, version: String, packaging: String = "jar"): Option[File] = {
6375
val userHome = System.getProperty("user.home")
6476
val jarPath = s"$userHome/.ivy2/cache/$groupId/$artifactId/${packaging}s/$artifactId-$version.jar"
6577
val file = new File(jarPath)
66-
if (!file.exists)
67-
throw new FileNotFoundException(s"Could not locate [$jarPath].")
68-
file
78+
if (file.exists()) Some(file) else None
6979
}
7080
}
7181

scalac-scoverage-plugin/src/test/scala/scoverage/macrosupport/Tester.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ import scala.language.experimental.macros
44

55
object Tester {
66

7-
def test: Unit = macro TesterMacro.test
7+
// def test: Unit = macro TesterMacro.test
88

99
}

0 commit comments

Comments
 (0)