From c30b853f64ef8986dbe99c45fe752ad301c7b253 Mon Sep 17 00:00:00 2001 From: Jarek Sacha Date: Mon, 5 Jun 2023 18:51:09 -0400 Subject: [PATCH] Add test for Scala Native #3293 that should be resolved in v.0.4.13 --- build.sbt | 9 +++--- .../ij_plugins/imagej_launcher/PathSpec.scala | 28 +++++++++++++++++++ 2 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 src/test/scala/ij_plugins/imagej_launcher/PathSpec.scala diff --git a/build.sbt b/build.sbt index a4b298a..6c6313b 100644 --- a/build.sbt +++ b/build.sbt @@ -1,4 +1,4 @@ -scalaVersion := "3.3.0" +scalaVersion := "3.3.0" //name := "IJP-ImageJ-Launcher" version := "0.1.1-SNAPSHOT" versionScheme := Some("early-semver") @@ -16,14 +16,15 @@ enablePlugins(ScalaNativePlugin) logLevel := Level.Info libraryDependencies ++= Seq( - "com.github.scopt" %%% "scopt" % "4.1.0", - "com.lihaoyi" %%% "os-lib" % "0.9.1" + "com.github.scopt" %%% "scopt" % "4.1.0", + "com.lihaoyi" %%% "os-lib" % "0.9.1", + "org.scalatest" %%% "scalatest" % "3.2.16" % Test ) Compile / run / mainClass := Some("ij_plugins.imagej_launcher.Main") // import to add Scala Native options -import scala.scalanative.build._ +import scala.scalanative.build.* // defaults set with common options shown nativeConfig ~= { c => diff --git a/src/test/scala/ij_plugins/imagej_launcher/PathSpec.scala b/src/test/scala/ij_plugins/imagej_launcher/PathSpec.scala new file mode 100644 index 0000000..36845bb --- /dev/null +++ b/src/test/scala/ij_plugins/imagej_launcher/PathSpec.scala @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2000-2023 Jarek Sacha. All Rights Reserved. + * Author's e-mail: jpsacha at gmail.com + */ + +package ij_plugins.imagej_launcher + +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should + +import java.nio.file.FileSystems +import scala.scalanative.runtime.Platform.isWindows + +class PathSpec extends AnyFlatSpec with should.Matchers: + + "A Path" should "should `relativize` jars on Windows (Scala Native #3293)" in { + if isWindows() then + // This to test that fix for Scala Native #3293 implemented, it should be part of Scala Native 0.4.13 + // See https://github.com/scala-native/scala-native/issues/3293 + + // val src = Path.of("C:\\a\\b\\c.jar") + val src = FileSystems.getDefault.getPath("C:\\a\\b\\c.jar") + // val base = Path.of("C:\\a") + val base = FileSystems.getDefault.getPath("C:\\a") + + val rel = base.relativize(src) + rel.toString should be("b\\c.jar") + }