From c3c8848d479bee7f0c9004c505e08631f2575a8a Mon Sep 17 00:00:00 2001 From: OlegYch Date: Mon, 14 May 2018 20:21:37 +0300 Subject: [PATCH] Fix tests on windows, closes #52 --- .../scala/sbt/internal/io/SourceSpec.scala | 2 +- io/src/test/scala/sbt/io/IOSpec.scala | 12 ++++---- io/src/test/scala/sbt/io/PathMapperSpec.scala | 28 +++++++++---------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/io/src/test/scala/sbt/internal/io/SourceSpec.scala b/io/src/test/scala/sbt/internal/io/SourceSpec.scala index 2e045cd9..f9a47591 100644 --- a/io/src/test/scala/sbt/internal/io/SourceSpec.scala +++ b/io/src/test/scala/sbt/internal/io/SourceSpec.scala @@ -26,7 +26,7 @@ class SourceSpec extends FlatSpec with Matchers { it should "apply exclude filter" in { val source = new Source(new File("/foo"), new SimpleFileFilter(_.toString.endsWith(".scala")), - new SimpleFileFilter(_.toString == "/foo/bar/buzz.scala"), + new SimpleFileFilter(_ == sbt.io.syntax.file("/foo/bar/buzz.scala")), true) source.accept(Paths.get("/foo/bar/baz.scala")) shouldBe true source.accept(Paths.get("/foo/bar/buzz.scala")) shouldBe false diff --git a/io/src/test/scala/sbt/io/IOSpec.scala b/io/src/test/scala/sbt/io/IOSpec.scala index 89711800..3be2d718 100644 --- a/io/src/test/scala/sbt/io/IOSpec.scala +++ b/io/src/test/scala/sbt/io/IOSpec.scala @@ -21,8 +21,8 @@ class IOSpec extends FlatSpec with Matchers { val relativeRootDir = new File(nestedDir, "..") - IO.relativize(rootDir.toFile, nestedFile) shouldBe Some("meh.file") - IO.relativize(relativeRootDir, nestedFile) shouldBe Some("../../meh.file") + IO.relativize(rootDir.toFile, nestedFile).map(file) shouldBe Some(file("meh.file")) + IO.relativize(relativeRootDir, nestedFile).map(file) shouldBe Some(file("../../meh.file")) } it should "relativize . dirs" in { @@ -43,8 +43,8 @@ class IOSpec extends FlatSpec with Matchers { } "toURI" should "make URI" in { - val u = IO.toURI(file("/etc/hosts")) - assert(u.toString == "file:///etc/hosts") + val u = IO.toURI(file("/etc/hosts").getAbsoluteFile) + assert(u.toString.startsWith("file:///") && u.toString.endsWith("etc/hosts")) } it should "make u0 URI from a relative path" in { @@ -53,8 +53,8 @@ class IOSpec extends FlatSpec with Matchers { } it should "make URI that roundtrips" in { - val u = IO.toURI(file("/etc/hosts")) - assert(IO.toFile(u) == file("/etc/hosts")) + val u = IO.toURI(file("/etc/hosts").getAbsoluteFile) + assert(IO.toFile(u) == file("/etc/hosts").getAbsoluteFile) } it should "make u0 URI that roundtrips" in { diff --git a/io/src/test/scala/sbt/io/PathMapperSpec.scala b/io/src/test/scala/sbt/io/PathMapperSpec.scala index 91782a4e..c130278a 100644 --- a/io/src/test/scala/sbt/io/PathMapperSpec.scala +++ b/io/src/test/scala/sbt/io/PathMapperSpec.scala @@ -39,14 +39,14 @@ class PathMapperSpec extends fixture.FlatSpec with Matchers { IO.createDirectory(nestedDir.toFile) IO.touch(nestedDirFile) - val mappings = Path.directory(tempDirectory.toFile) - - mappings should contain theSameElementsAs List[(File, String)]( - tempDirectory.toFile -> s"${tempDirectory.getFileName}", - nestedFile1 -> s"${tempDirectory.getFileName}/file1", - nestedFile2 -> s"${tempDirectory.getFileName}/file2", - nestedDir.toFile -> s"${tempDirectory.getFileName}/dir1", - nestedDirFile -> s"${tempDirectory.getFileName}/dir1/dir1-file1" + val mappings = Path.directory(tempDirectory.toFile).map { case (f, s) => (f, file(s)) } + + mappings should contain theSameElementsAs List( + tempDirectory.toFile -> file(s"${tempDirectory.getFileName}"), + nestedFile1 -> file(s"${tempDirectory.getFileName}/file1"), + nestedFile2 -> file(s"${tempDirectory.getFileName}/file2"), + nestedDir.toFile -> file(s"${tempDirectory.getFileName}/dir1"), + nestedDirFile -> file(s"${tempDirectory.getFileName}/dir1/dir1-file1") ) } @@ -86,13 +86,13 @@ class PathMapperSpec extends fixture.FlatSpec with Matchers { IO.createDirectory(nestedDir.toFile) IO.touch(nestedDirFile) - val mappings = Path.contentOf(tempDirectory.toFile) + val mappings = Path.contentOf(tempDirectory.toFile).map { case (f, s) => (f, file(s)) } - mappings should contain theSameElementsAs List[(File, String)]( - nestedFile1 -> s"file1", - nestedFile2 -> s"file2", - nestedDir.toFile -> s"dir1", - nestedDirFile -> s"dir1/dir1-file1" + mappings should contain theSameElementsAs List( + nestedFile1 -> file(s"file1"), + nestedFile2 -> file(s"file2"), + nestedDir.toFile -> file(s"dir1"), + nestedDirFile -> file(s"dir1/dir1-file1") ) }