From f64a275abeb31d99fcb2eea4f88916f0c1f5fc04 Mon Sep 17 00:00:00 2001 From: Andy Jayne Date: Thu, 30 Nov 2023 13:00:13 +0000 Subject: [PATCH] Add test for semver metadata in version string This test checks whether the plugin correctly handles dependencies where the version contains a + character. The character is commonly used in semver version strings to add build metadata to the version. Per https://semver.org/ Currently this test fails as the plugin is comparing the following version strings that do not match: 7.2.27+33-04a1ea9e-SNAPSHOT 7.2.27%2B33-04a1ea9e-SNAPSHOT Reproduces: https://github.com/cb372/sbt-explicit-dependencies/issues/110 --- src/sbt-test/basic/semver-metadata/build.sbt | 5 +++++ src/sbt-test/basic/semver-metadata/project/plugins.sbt | 1 + .../basic/semver-metadata/src/main/scala/Main.scala | 10 ++++++++++ src/sbt-test/basic/semver-metadata/test | 2 ++ 4 files changed, 18 insertions(+) create mode 100644 src/sbt-test/basic/semver-metadata/build.sbt create mode 100644 src/sbt-test/basic/semver-metadata/project/plugins.sbt create mode 100644 src/sbt-test/basic/semver-metadata/src/main/scala/Main.scala create mode 100644 src/sbt-test/basic/semver-metadata/test diff --git a/src/sbt-test/basic/semver-metadata/build.sbt b/src/sbt-test/basic/semver-metadata/build.sbt new file mode 100644 index 0000000..6724785 --- /dev/null +++ b/src/sbt-test/basic/semver-metadata/build.sbt @@ -0,0 +1,5 @@ +scalaVersion := sys.props("scala.version") +resolvers ++= Seq("Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots") +libraryDependencies ++= Seq( + "org.scalaz" %% "scalaz-core" % "7.2.27+33-04a1ea9e-SNAPSHOT" +) diff --git a/src/sbt-test/basic/semver-metadata/project/plugins.sbt b/src/sbt-test/basic/semver-metadata/project/plugins.sbt new file mode 100644 index 0000000..40f24a3 --- /dev/null +++ b/src/sbt-test/basic/semver-metadata/project/plugins.sbt @@ -0,0 +1 @@ +addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % sys.props("plugin.version")) diff --git a/src/sbt-test/basic/semver-metadata/src/main/scala/Main.scala b/src/sbt-test/basic/semver-metadata/src/main/scala/Main.scala new file mode 100644 index 0000000..132b030 --- /dev/null +++ b/src/sbt-test/basic/semver-metadata/src/main/scala/Main.scala @@ -0,0 +1,10 @@ +import scalaz._ +import scalaz.std.anyVal._ +import scalaz.std.list._ +import scalaz.std.option._ +import scalaz.syntax.equal._ + +object Main { + val list1: List[Option[Int]] = List(Some(1), Some(2), Some(3), Some(4)) + assert(Traverse[List].sequence(list1) === Some(List(1,2,3,4))) +} diff --git a/src/sbt-test/basic/semver-metadata/test b/src/sbt-test/basic/semver-metadata/test new file mode 100644 index 0000000..a465c04 --- /dev/null +++ b/src/sbt-test/basic/semver-metadata/test @@ -0,0 +1,2 @@ +> unusedCompileDependenciesTest +> undeclaredCompileDependenciesTest