Skip to content

Fixing tests on CI #300

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

Merged
merged 12 commits into from
Nov 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
java-version: 11

- name: run tests
run: sbt ++2.12.12 test
run: sbt ++2.12.10 test

scala-2_13:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
java-version: 11

- name: run tests
run: sbt ++2.12.12 test
run: sbt ++2.12.10 test

scala-2_13:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jdk:
- openjdk8

scala:
- 2.12.12
- 2.12.10
- 2.13.3

before_cache:
Expand Down
12 changes: 7 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ val ScalatestVersion = "3.1.1"

val appSettings = Seq(
organization := Org,
scalaVersion := "2.13.3",
crossScalaVersions := Seq("2.12.12", "2.13.3"),
scalaVersion := "2.12.10",
crossScalaVersions := Seq("2.12.10", "2.13.3"),
fork in Test := false,
publishMavenStyle := true,
publishArtifact in Test := false,
Expand All @@ -24,6 +24,9 @@ val appSettings = Seq(
else
Some("releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2")
},
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-compiler" % scalaVersion.value % Compile
),
pomExtra := {
<url>https://github.com/scoverage/scalac-scoverage-plugin</url>
<licenses>
Expand Down Expand Up @@ -89,11 +92,10 @@ lazy val plugin = Project("scalac-scoverage-plugin", file("scalac-scoverage-plug
.settings(
libraryDependencies ++= Seq(
"org.scala-lang.modules" %% "scala-xml" % "1.2.0",
"org.scalatest" %% "scalatest" % ScalatestVersion % Test,
"org.scala-lang" % "scala-compiler" % scalaVersion.value % Provided
"org.scalatest" %% "scalatest" % ScalatestVersion % Test
)
)
.settings(
unmanagedSourceDirectories in Test += (sourceDirectory in Test).value / "scala-2.11+"
unmanagedSourceDirectories in Test += (sourceDirectory in Test).value / "scala-2.12+"
)

Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ import java.io.{File, FileNotFoundException}
import java.net.URL

import scala.collection.mutable.ListBuffer
import scala.tools.nsc.{Settings, Global}
import scala.tools.nsc.{Global, Settings}
import scala.tools.nsc.plugins.PluginComponent
import scala.tools.nsc.transform.{Transform, TypingTransformers}

/** @author Stephen Samuel */
object ScoverageCompiler {

val ScalaVersion = scala.util.Properties.versionNumberString
val ShortScalaVersion = (ScalaVersion split "[.]").toList match {
val ScalaVersion: String = scala.util.Properties.versionNumberString
val ShortScalaVersion: String = (ScalaVersion split "[.]").toList match {
case init :+ last if last forall (_.isDigit) => init mkString "."
case _ => ScalaVersion
case _ => ScalaVersion
}

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

def settings: Settings = {
val s = new scala.tools.nsc.Settings
Expand Down Expand Up @@ -57,15 +57,25 @@ object ScoverageCompiler {

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

private def findScalaJar(artifactId: String): File = findIvyJar("org.scala-lang", artifactId, ScalaVersion)
private def findScalaJar(artifactId: String): File =
findIvyJar("org.scala-lang", artifactId, ScalaVersion)
.orElse(findCoursierJar(artifactId, ScalaVersion))
.getOrElse {
throw new FileNotFoundException(s"Could not locate $artifactId/$ScalaVersion")
}

private def findCoursierJar(artifactId: String, version: String): Option[File] = {
val userHome = System.getProperty("user.home")
val jarPath = s"$userHome/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/$artifactId/$version/$artifactId-$version.jar"
val file = new File(jarPath)
if (file.exists()) Some(file) else None
}

private def findIvyJar(groupId: String, artifactId: String, version: String, packaging: String = "jar"): File = {
private def findIvyJar(groupId: String, artifactId: String, version: String, packaging: String = "jar"): Option[File] = {
val userHome = System.getProperty("user.home")
val jarPath = s"$userHome/.ivy2/cache/$groupId/$artifactId/${packaging}s/$artifactId-$version.jar"
val file = new File(jarPath)
if (!file.exists)
throw new FileNotFoundException(s"Could not locate [$jarPath].")
file
if (file.exists()) Some(file) else None
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import scala.language.experimental.macros

object Tester {

def test: Unit = macro TesterMacro.test
// def test: Unit = macro TesterMacro.test

}