Skip to content

Remove 'com.typesafe.scala-logging:scala-logging' dependency #252

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 1 commit into from
Apr 28, 2019
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
36 changes: 23 additions & 13 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,27 @@ lazy val plugin = Project("scalac-scoverage-plugin", file("scalac-scoverage-plug
.dependsOn(`scalac-scoverage-runtimeJVM` % "test")
.settings(name := "scalac-scoverage-plugin")
.settings(appSettings: _*)
.settings(libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % ScalatestVersion % "test",
"org.scala-lang" % "scala-compiler" % scalaVersion.value % "provided"
)).settings(libraryDependencies ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, scalaMajor)) if scalaMajor > 10 => Seq(
"org.scala-lang.modules" %% "scala-xml" % "1.1.1",
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.0" % "test"
.settings(
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % ScalatestVersion % "test",
"org.scala-lang" % "scala-compiler" % scalaVersion.value % "provided"
)
case _ => Seq(
"com.typesafe.scala-logging" %% "scala-logging-slf4j" % "2.1.2" % "test"
)
}
})
)
.settings(
unmanagedSourceDirectories in Test ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, scalaMajor)) if scalaMajor > 10 =>
Seq((sourceDirectory in Test).value / "scala-2.11+")
case _ =>
Seq()
}
},
libraryDependencies ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, scalaMajor)) if scalaMajor > 10 =>
Seq("org.scala-lang.modules" %% "scala-xml" % "1.1.1")
case _ =>
Seq()
}
}
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package scoverage.macrosupport

import scala.reflect.macros.Context

private object TesterMacro {

type TesterContext = Context { type PrefixType = Tester.type }

def test(c: TesterContext) =
c.universe.reify(
println("macro test")
)

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package scoverage.macrosupport

import scala.reflect.macros.blackbox.Context

private object TesterMacro {

type TesterContext = Context { type PrefixType = Tester.type }

def test(c: TesterContext) = {
import c.universe._
q"""println("macro test")"""
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package scoverage

import java.io.File

trait MacroSupport {

val macroSupportDeps = Seq(testClasses)

private def testClasses: File = new File(s"./scalac-scoverage-plugin/target/scala-${ScoverageCompiler.ShortScalaVersion}/test-classes")

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class PluginASTSupportTest
extends FunSuite
with OneInstancePerTest
with BeforeAndAfterEachTestData
with ScalaLoggingSupport {
with MacroSupport {

override protected def afterEach(testData: TestData): Unit = {
val compiler = ScoverageCompiler.default
Expand Down Expand Up @@ -145,12 +145,11 @@ class PluginASTSupportTest
// https://github.com/skinny-framework/skinny-framework/issues/97
test("macro range positions should not break plugin") {
val compiler = ScoverageCompiler.default
scalaLoggingDeps.foreach(compiler.addToClassPath(_))
compiler.compileCodeSnippet( s"""import ${scalaLoggingPackageName}.StrictLogging
macroSupportDeps.foreach(compiler.addToClassPath(_))
compiler.compileCodeSnippet( s"""import scoverage.macrosupport.Tester
|
|object MacroTest extends StrictLogging {
| println("Hello")
| logger.info("will break")
|object MacroTest {
| Tester.test
|} """.stripMargin)
assert(!compiler.reporter.hasErrors)
assert(!compiler.reporter.hasWarnings)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class PluginCoverageTest
extends FunSuite
with OneInstancePerTest
with BeforeAndAfterEachTestData
with ScalaLoggingSupport {
with MacroSupport {

test("scoverage should instrument default arguments with methods") {
val compiler = ScoverageCompiler.default
Expand Down Expand Up @@ -285,12 +285,13 @@ class PluginCoverageTest
compiler.assertNoCoverage()
}

test("plugin should not instrument expanded macro code github.com/skinny-framework/skinny-framework/issues/97") {
test("plugin should not instrument expanded macro code http://github.com/skinny-framework/skinny-framework/issues/97") {
val compiler = ScoverageCompiler.default
scalaLoggingDeps.foreach(compiler.addToClassPath(_))
compiler.compileCodeSnippet( s"""import ${scalaLoggingPackageName}.StrictLogging
|class MacroTest extends StrictLogging {
| logger.info("will break")
macroSupportDeps.foreach(compiler.addToClassPath(_))
compiler.compileCodeSnippet( s"""import scoverage.macrosupport.Tester
|
|class MacroTest {
| Tester.test
|} """.stripMargin)
assert(!compiler.reporter.hasErrors)
assert(!compiler.reporter.hasWarnings)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package scoverage.macrosupport

import scala.language.experimental.macros

object Tester {

def test: Unit = macro TesterMacro.test

}