Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests on windows, closes #52 #153

Merged
merged 1 commit into from
May 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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