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

Scala 3.0.0-M3 #158

Merged
merged 19 commits into from
Jan 4, 2021
Merged
Show file tree
Hide file tree
Changes from 9 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
4 changes: 4 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ spaces {
}

project.git = true

project.excludeFilters = [
".*-scala-3.*"
]
54 changes: 31 additions & 23 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ ThisBuild / commands += Command.command("ci") { state =>
"test:scalafix --check" ::
"clean" ::
"test:compile" ::
"test:fastLinkJS" :: // do this separately as it's memory intensive
"test" ::
"docs/docusaurusCreateSite" ::
"core/publishLocal" :: state
}

ThisBuild / commands += Command.command("fix") { state =>
"scalafmtAll" ::
"scalafmtSbt" ::
"scalafix" ::
"test:scalafix" :: state
"scalafix" ::
"test:scalafix" ::
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because scalafix can actually change the formatting :-/

"scalafmtAll" ::
"scalafmtSbt" :: state
}

ThisBuild / commands += Command.command("release") { state =>
Expand All @@ -33,7 +34,6 @@ Global / (Test / testOptions) += Tests.Argument("--quickstart")

lazy val root = project
.in(file("."))
.enablePlugins(ScalafixPlugin)
.aggregate(allModules: _*)
.configure(WeaverPlugin.profile)
.settings(WeaverPlugin.doNotPublishArtifact)
Expand Down Expand Up @@ -75,17 +75,19 @@ lazy val core = projectMatrix
.configure(catsEffectDependencies)
.settings(
libraryDependencies ++= Seq(
"com.eed3si9n.expecty" %%% "expecty" % "0.14.1",
"org.portable-scala" %%% "portable-scala-reflect" % "1.0.0"
"com.eed3si9n.expecty" %%% "expecty" % "0.15.0",
("org.portable-scala" %%% "portable-scala-reflect" % "1.0.0").withDottyCompat(
scalaVersion.value)
),
libraryDependencies ++= {
if (virtualAxes.value.contains(VirtualAxis.jvm))
Seq(
"org.scala-js" %%% "scalajs-stubs" % "1.0.0" % "provided"
("org.scala-js" %%% "scalajs-stubs" % "1.0.0" % "provided").withDottyCompat(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this dep is like 2 annotations, may be we can copypaste it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmm not sure how we could do it without polluting the user's classpath tbh. I think having the dotty compat on this one is low risk for the time being, since it's a compile-only thing.

scalaVersion.value)
)
else {
Seq(
"io.github.cquiroz" %%% "scala-java-time" % "2.0.0"
"io.github.cquiroz" %%% "scala-java-time" % "2.1.0"
)
}
}
Expand All @@ -109,7 +111,7 @@ val allIntegrationsCoresFilter: ScopeFilter =

lazy val docs = projectMatrix
.in(file("modules/docs"))
.jvmPlatform(WeaverPlugin.supportedScalaVersions)
.jvmPlatform(WeaverPlugin.supportedScala2Versions)
.enablePlugins(DocusaurusPlugin, MdocPlugin)
.dependsOn(core, scalacheck, cats, zio, monix, monixBio, specs2)
.settings(
Expand Down Expand Up @@ -182,13 +184,15 @@ lazy val framework = projectMatrix
libraryDependencies ++= {
if (virtualAxes.value.contains(VirtualAxis.jvm))
Seq(
"org.scala-sbt" % "test-interface" % "1.0",
"org.scala-js" %%% "scalajs-stubs" % "1.0.0" % "provided"
"org.scala-sbt" % "test-interface" % "1.0",
("org.scala-js" %%% "scalajs-stubs" % "1.0.0" % "provided").withDottyCompat(
scalaVersion.value)
)
else
Seq(
"org.scala-js" %% "scalajs-test-interface" % scalaJSVersion,
"io.github.cquiroz" %%% "scala-java-time-tzdb" % "2.0.0" % Test
("org.scala-js" %% "scalajs-test-interface" % scalaJSVersion).withDottyCompat(
scalaVersion.value),
"io.github.cquiroz" %%% "scala-java-time-tzdb" % "2.1.0" % Test
)
}
)
Expand Down Expand Up @@ -217,7 +221,8 @@ lazy val specs2 = projectMatrix
name := "specs2",
testFrameworks := Seq(new TestFramework("weaver.framework.CatsEffect")),
libraryDependencies ++= Seq(
"org.specs2" %%% "specs2-matcher" % "4.10.5"
("org.specs2" %%% "specs2-matcher" % "4.10.5").withDottyCompat(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not seeing a 3.0.0-M3 release yet, so this might have to become onlyScala2 for the time being.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with that

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i.e. with making it scala 2 only?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i.e. with making it scala 2 only?

yes

scalaVersion.value)
)
)
.settings(WeaverPlugin.simpleLayout)
Expand All @@ -239,7 +244,7 @@ lazy val coreCats = projectMatrix

lazy val coreMonix = projectMatrix
.in(file("modules/core/monix"))
.onlyCatsEffect2()
.onlyCatsEffect2(onlyScala2 = true)
.dependsOn(core)
.configure(WeaverPlugin.profile)
.settings(WeaverPlugin.simpleLayout)
Expand All @@ -252,7 +257,7 @@ lazy val coreMonix = projectMatrix

lazy val coreMonixBio = projectMatrix
.in(file("modules/core/monixBio"))
.onlyCatsEffect2()
.onlyCatsEffect2(onlyScala2 = true)
.dependsOn(core)
.configure(WeaverPlugin.profile)
.settings(WeaverPlugin.simpleLayout)
Expand All @@ -265,7 +270,7 @@ lazy val coreMonixBio = projectMatrix

lazy val coreZio = projectMatrix
.in(file("modules/core/zio"))
.onlyCatsEffect2()
.onlyCatsEffect2(onlyScala2 = true)
.dependsOn(core)
.configure(WeaverPlugin.profile)
.settings(WeaverPlugin.simpleLayout)
Expand Down Expand Up @@ -296,12 +301,15 @@ lazy val cats = projectMatrix
.settings(
name := "cats",
testFrameworks := Seq(new TestFramework("weaver.framework.CatsEffect")),
libraryDependencies += "io.github.cquiroz" %%% "scala-java-time-tzdb" % "2.0.0" % Test
libraryDependencies += {
// if(virtualAxes.contains(VirtualAxis.js))
"io.github.cquiroz" %%% "scala-java-time-tzdb" % "2.1.0" % Test
}
)

lazy val monix = projectMatrix
.in(file("modules/framework/monix"))
.onlyCatsEffect2()
.onlyCatsEffect2(onlyScala2 = true)
.dependsOn(framework, coreMonix)
.configure(WeaverPlugin.profile)
.settings(WeaverPlugin.simpleLayout)
Expand All @@ -312,7 +320,7 @@ lazy val monix = projectMatrix

lazy val monixBio = projectMatrix
.in(file("modules/framework/monix-bio"))
.onlyCatsEffect2()
.onlyCatsEffect2(onlyScala2 = true)
.dependsOn(framework, coreMonixBio)
.configure(WeaverPlugin.profile)
.settings(WeaverPlugin.simpleLayout)
Expand All @@ -323,7 +331,7 @@ lazy val monixBio = projectMatrix

lazy val zio = projectMatrix
.in(file("modules/framework/zio"))
.onlyCatsEffect2()
.onlyCatsEffect2(onlyScala2 = true)
.dependsOn(framework, coreZio)
.configure(WeaverPlugin.profile)
.settings(WeaverPlugin.simpleLayout)
Expand All @@ -337,7 +345,7 @@ lazy val zio = projectMatrix
// #################################################################################################

lazy val intellijRunner = projectMatrix
.onlyCatsEffect2(withJs = false)
.onlyCatsEffect2(withJs = false, onlyScala2 = true)
.in(file("modules/intellij-runner"))
.dependsOn(core, framework, framework % "test->compile")
.configure(WeaverPlugin.profile)
Expand Down
7 changes: 4 additions & 3 deletions modules/core/cats/src-ce2/weaver/BaseIOSuite.scala
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package weaver

import cats.effect.IO
import cats.effect.{ ContextShift, IO, Timer }

trait BaseIOSuite extends RunnableSuite[IO] {
implicit protected def effectCompat: UnsafeRun[IO] = CatsUnsafeRun
final implicit protected def contextShift = effectCompat.contextShift
final implicit protected def timer = effectCompat.timer
final implicit protected def contextShift: ContextShift[IO] =
effectCompat.contextShift
final implicit protected def timer: Timer[IO] = effectCompat.timer
}
1 change: 0 additions & 1 deletion modules/core/src-ce2/weaver/CECompat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,4 @@ private[weaver] trait CECompat {
}
}
}

}
16 changes: 16 additions & 0 deletions modules/core/src-scala-2/Expect.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package weaver

// import cats.data.{ NonEmptyList, ValidatedNel }
// import cats.syntax.all._

import com.eed3si9n.expecty._

class Expect
extends Recorder[Boolean, Expectations]
with UnaryRecorder[Boolean, Expectations] {

def all(recordings: Boolean*): Expectations =
macro VarargsRecorderMacro.apply[Boolean, Expectations]

override lazy val listener = new ExpectyListener
}
5 changes: 5 additions & 0 deletions modules/core/src-scala-2/ScalaCompat.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package weaver

object ScalaCompat {
def isScala3: Boolean = false
}
49 changes: 49 additions & 0 deletions modules/core/src-scala-2/SourceLocationMacro.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package weaver

// kudos to https://github.com/monix/minitest
// format: off
import scala.reflect.macros.whitebox

trait SourceLocationMacro {

import macros._

trait Here {
/**
* Pulls source location without being affected by implicit scope.
*/
def here: SourceLocation = macro Macros.fromContext
}

implicit def fromContext: SourceLocation =
macro Macros.fromContext


}

object macros {
class Macros(val c: whitebox.Context) {
import c.universe._

def fromContext: Tree = {
val (pathExpr, relPathExpr, lineExpr) = getSourceLocation
val SourceLocationSym = symbolOf[SourceLocation].companion
q"""$SourceLocationSym($pathExpr, $relPathExpr, $lineExpr)"""
}

private def getSourceLocation = {
val pwd = java.nio.file.Paths.get("").toAbsolutePath
val p = c.enclosingPosition.source.path
val abstractFile = c.enclosingPosition.source.file

val rp = if (!abstractFile.isVirtual){
pwd.relativize(abstractFile.file.toPath()).toString()
} else p

val line = c.Expr[Int](Literal(Constant(c.enclosingPosition.line)))
(p, rp, line)
}

}
}
// format: on
18 changes: 18 additions & 0 deletions modules/core/src-scala-3/ExpectMacro.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package weaver

import cats.data.{ NonEmptyList, ValidatedNel }
import cats.syntax.all._

import com.eed3si9n.expecty._

import scala.quoted._

class Expect
extends Recorder[Boolean, Expectations]
with UnaryRecorder[Boolean, Expectations] {

inline def all(inline recordings: Boolean*): Expectations =
${ RecorderMacro.varargs('recordings, 'listener) }

override lazy val listener = new ExpectyListener
}
5 changes: 5 additions & 0 deletions modules/core/src-scala-3/ScalaCompat.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package weaver

object ScalaCompat {
def isScala3: Boolean = true
}
37 changes: 37 additions & 0 deletions modules/core/src-scala-3/SourceLocationMacro.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package weaver

// kudos to https://github.com/monix/minitest
// format: off
// import scala.reflect.macros.whitebox

import scala.quoted._

trait SourceLocationMacro {
trait Here {
/**
* Pulls source location without being affected by implicit scope.
*/
inline def here: SourceLocation = ${macros.fromContextImpl}
}

implicit inline def fromContext: SourceLocation = ${macros.fromContextImpl}
}

object macros {
def fromContextImpl(using ctx: Quotes): Expr[SourceLocation] = {
import ctx.reflect.Position._
import ctx.reflect._

val pwd = java.nio.file.Paths.get("").toAbsolutePath

val position = Position.ofMacroExpansion

val rp = Expr(pwd.relativize(position.sourceFile.jpath).toString)
val absPath = Expr(position.sourceFile.jpath.toAbsolutePath.toString)
val l = Expr(position.startLine + 1)

'{new SourceLocation($absPath, $rp, $l) }
}
}

// format: on
50 changes: 0 additions & 50 deletions modules/core/src/weaver/Expect.scala

This file was deleted.

Loading