diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 53772b8d..65d1f270 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,9 +38,6 @@ jobs: distribution: 'temurin' java-version: ${{ matrix.java }} - - name: Install JSDOM - run: npm install - - name: run tests run: sbt ++${{ matrix.scala.version }} plugin/test @@ -51,7 +48,7 @@ jobs: matrix: os: [ 'ubuntu-latest', 'windows-latest' ] java: ['8', '17' ] - module: ['runtime', 'runtimeJS', 'reporter', 'domain', 'serializer'] + module: ['runtime', 'runtimeJS', 'runtimeJSDOMTest', 'runtimeNative', 'reporter', 'domain', 'serializer'] steps: - name: checkout the repo uses: actions/checkout@v3 @@ -64,6 +61,10 @@ jobs: distribution: 'temurin' java-version: ${{ matrix.java }} + - name: Install JSDOM + run: npm install + if: matrix.module == 'runtimeJSDOMTest' + - name: run tests run: sbt +${{ matrix.module }}/test diff --git a/build.sbt b/build.sbt index a02ed416..f1c3b5e9 100644 --- a/build.sbt +++ b/build.sbt @@ -99,6 +99,7 @@ lazy val root = Project("scalac-scoverage", file(".")) plugin, runtime.jvm, runtime.js, + runtime.native, runtimeJSDOMTest, reporter, domain, @@ -109,7 +110,7 @@ lazy val root = Project("scalac-scoverage", file(".")) lazy val runtime = CrossProject( "runtime", file("runtime") -)(JVMPlatform, JSPlatform) +)(JVMPlatform, JSPlatform, NativePlatform) .crossType(CrossType.Full) .withoutSuffixFor(JVMPlatform) .settings( diff --git a/project/plugins.sbt b/project/plugins.sbt index f7e8a8e4..2fd15c72 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,5 +1,9 @@ addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.0") -addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.1.0") +addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.2.0") + +addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.4") +addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.2.0") + addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") diff --git a/runtime/native/src/main/scala/scoverage/Platform.scala b/runtime/native/src/main/scala/scoverage/Platform.scala new file mode 100644 index 00000000..fa3902d3 --- /dev/null +++ b/runtime/native/src/main/scala/scoverage/Platform.scala @@ -0,0 +1,31 @@ +package scoverage + +import java.io.{File => SupportFile} +import java.io.{FileFilter => SupportFileFilter} +import java.io.{FileWriter => SupportFileWriter} + +import scala.collection.mutable.HashMap +import scala.io.{Source => SupportSource} + +object Platform { + type ThreadSafeMap[A, B] = HashMap[A, B] + lazy val ThreadSafeMap = HashMap + + type File = SupportFile + type FileWriter = SupportFileWriter + type FileFilter = SupportFileFilter + + lazy val Source = SupportSource + + def insecureRandomUUID() = { + import scala.util.Random + var msb = Random.nextLong() + var lsb = Random.nextLong() + msb &= 0xffffffffffff0fffL // clear version + msb |= 0x0000000000004000L // set to version 4 + lsb &= 0x3fffffffffffffffL // clear variant + lsb |= 0x8000000000000000L // set to IETF variant + new java.util.UUID(msb, lsb) + } + +}