Skip to content

Commit

Permalink
Run Scala 3 unit tests on CI (#2212)
Browse files Browse the repository at this point in the history
  • Loading branch information
xerial authored Jun 1, 2022
1 parent 8ef9535 commit 8004d8a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:
java-version: zulu@1.11
- name: Scala 3.x test
# Only use a limited number of tests until AirSpec and DI can support Scala 3
run: DOTTY=true ./sbt "projectDotty/compile; dottyTest/run"
run: DOTTY=true ./sbt "projectDotty/test; dottyTest/run"
- name: Publish Test Report
uses: mikepenz/action-junit-report@v2
if: always() # always run even if the previous step fails
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,10 @@ object PrimitiveCodec {
* Another option to implement AnyCodec is packing pairs of (type, value), but we will not take this approach as this
* will require many bytes to fully encode type names.
*/
class AnyCodec(knownSurfaces: Seq[Surface] = Seq.empty) extends MessageCodec[Any] {
class AnyCodec(
codecFactory: MessageCodecFactory = MessageCodecFactory.defaultFactoryForJSON,
knownSurfaces: Seq[Surface] = Seq.empty
) extends MessageCodec[Any] {

private val knownSurfaceTable = knownSurfaces.map(s => s.rawType -> s).toMap[Class[_], Surface]

Expand Down Expand Up @@ -992,10 +995,10 @@ object PrimitiveCodec {
val cl = v.getClass
knownSurfaceTable.get(cl) match {
case Some(surface) =>
val codec = MessageCodec.ofSurface(surface).asInstanceOf[MessageCodec[Any]]
val codec = codecFactory.ofSurface(surface).asInstanceOf[MessageCodec[Any]]
codec.pack(p, v)
case None =>
wvlet.airframe.codec.Compat.codecOfClass(cl) match {
wvlet.airframe.codec.Compat.codecOfClass(cl, codecFactory) match {
case Some(codec) =>
codec.asInstanceOf[MessageCodec[Any]].pack(p, v)
case None =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
package wvlet.airframe.codec

import org.scalacheck.util.Pretty
import wvlet.airframe.codec.PrimitiveCodec.LongCodec
import wvlet.airframe.codec.PrimitiveCodec.{AnyCodec, LongCodec}
import wvlet.airframe.json.JSON.JSONString
import wvlet.airframe.msgpack.spi.MessagePack
import wvlet.airframe.msgpack.spi.Value.StringValue
Expand Down Expand Up @@ -425,7 +425,7 @@ object PrimitiveCodecTest extends CodecSpec with PropertyCheck {
if (isScalaJS) {
pending("Scala.js doesn't support runtime reflection")
}
val anyCodec = MessageCodec.of[Any]
val anyCodec = new AnyCodec(knownSurfaces = Seq(Surface.of[Person]))
val json = anyCodec.toJson(Person(1, "leo"))
json shouldBe """{"id":1,"name":"leo"}"""
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ParquetRecordWriter(schema: MessageType, knownSurfaces: Seq[Surface] = Seq
ParquetWriteCodec.parquetCodecOf(schema, surface, ValueCodec).asRoot
}

private val codec = new AnyCodec(knownSurfaces)
private val codec = new AnyCodec(knownSurfaces = knownSurfaces)

def pack(obj: Any, recordConsumer: RecordConsumer): Unit = {
val msgpack =
Expand Down
1 change: 1 addition & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ lazy val projectDotty =
metricsJVM,
msgpackJVM,
jsonJVM,
parquet,
rxJVM,
// rx-html uses Scala Macros
rxHtmlJVM,
Expand Down

0 comments on commit 8004d8a

Please sign in to comment.