From c9e7590f3a994faa5052cef138ffa812f1629dc4 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Thu, 9 Jun 2022 16:08:03 +0000 Subject: [PATCH 1/5] Publish native runtime --- build.sbt | 3 +- project/plugins.sbt | 6 +++- .../src/main/scala/scoverage/Platform.scala | 31 +++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 runtime/native/src/main/scala/scoverage/Platform.scala 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..a2e8974d --- /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) + } + +} From c3c93198b5bf5a0770c0bbfb4a73b6f5c50d758a Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Thu, 9 Jun 2022 16:13:10 +0000 Subject: [PATCH 2/5] Formatting --- runtime/native/src/main/scala/scoverage/Platform.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/native/src/main/scala/scoverage/Platform.scala b/runtime/native/src/main/scala/scoverage/Platform.scala index a2e8974d..fa3902d3 100644 --- a/runtime/native/src/main/scala/scoverage/Platform.scala +++ b/runtime/native/src/main/scala/scoverage/Platform.scala @@ -8,7 +8,7 @@ import scala.collection.mutable.HashMap import scala.io.{Source => SupportSource} object Platform { - type ThreadSafeMap[A, B] = HashMap[A, B] + type ThreadSafeMap[A, B] = HashMap[A, B] lazy val ThreadSafeMap = HashMap type File = SupportFile From 9b03deb5e98737a3102120c8df5e8424192e14a2 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Thu, 9 Jun 2022 16:14:36 +0000 Subject: [PATCH 3/5] Add Native to CI matrix --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 53772b8d..f8d0b9e3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,7 +51,7 @@ jobs: matrix: os: [ 'ubuntu-latest', 'windows-latest' ] java: ['8', '17' ] - module: ['runtime', 'runtimeJS', 'reporter', 'domain', 'serializer'] + module: ['runtime', 'runtimeJS', 'runtimeNative', 'reporter', 'domain', 'serializer'] steps: - name: checkout the repo uses: actions/checkout@v3 From ad9abeb7038b37b4fa0cae92692f5ade935eb236 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Thu, 9 Jun 2022 16:18:33 +0000 Subject: [PATCH 4/5] Add JSDOM to CI matrix --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f8d0b9e3..d3cebdca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,7 +51,7 @@ jobs: matrix: os: [ 'ubuntu-latest', 'windows-latest' ] java: ['8', '17' ] - module: ['runtime', 'runtimeJS', 'runtimeNative', 'reporter', 'domain', 'serializer'] + module: ['runtime', 'runtimeJS', 'runtimeJSDOMTest', 'runtimeNative', 'reporter', 'domain', 'serializer'] steps: - name: checkout the repo uses: actions/checkout@v3 From 2916f7db055cf388445776f291ddc4982d99efb3 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Thu, 9 Jun 2022 16:29:44 +0000 Subject: [PATCH 5/5] Fix JSDOM CI --- .github/workflows/ci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d3cebdca..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 @@ -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