Skip to content

Commit

Permalink
Merge pull request #153 from OlegYch/fix-tests
Browse files Browse the repository at this point in the history
Fix tests on windows, closes #52
  • Loading branch information
eed3si9n authored May 27, 2018
2 parents 3328e02 + c3c8848 commit 9a354f1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion io/src/test/scala/sbt/internal/io/SourceSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions io/src/test/scala/sbt/io/IOSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
28 changes: 14 additions & 14 deletions io/src/test/scala/sbt/io/PathMapperSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)
}

Expand Down Expand Up @@ -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")
)
}

Expand Down

0 comments on commit 9a354f1

Please sign in to comment.