Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
lihaoyi committed Sep 7, 2024
1 parent 97a675d commit f36011b
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions os/test/src/SubprocessTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -204,20 +204,23 @@ object SubprocessTests extends TestSuite {
}
}
test("pwd0") {
// Windows doesnt have bash installed so a bit inconvenient
// to run these subprocesses for testing
if (!scala.util.Properties.isWin) {
val outsidePwd = os.pwd
val tmp0 = os.temp.dir()
val tmp = os.followLink(tmp0).getOrElse(tmp0)
val x = proc("bash", "-c", "pwd").call()
val y = os.pwd0.withValue(tmp) {
proc("bash", "-c", "pwd").call()
}

val outsidePwd = os.pwd
val tmp0 = os.temp.dir()
val tmp = os.followLink(tmp0).getOrElse(tmp0)
val x = proc("bash", "-c", "pwd").call()
val y = os.pwd0.withValue(tmp) {
proc("bash", "-c", "pwd").call()
val z = proc("bash", "-c", "pwd").call()
assert(outsidePwd.toString != tmp.toString)
assert(x.out.trim() == outsidePwd.toString)
assert(y.out.trim() == tmp.toString)
assert(z.out.trim() == outsidePwd.toString)
}

val z = proc("bash", "-c", "pwd").call()
assert(outsidePwd.toString != tmp.toString)
assert(x.out.trim() == outsidePwd.toString)
assert(y.out.trim() == tmp.toString)
assert(z.out.trim() == outsidePwd.toString)
}
}
}

0 comments on commit f36011b

Please sign in to comment.