Skip to content

Commit 4f51aa1

Browse files
Allow to run TestUtil.putCsInPathViaEnv several times
in the same test
1 parent d0c01b8 commit 4f51aa1

File tree

1 file changed

+16
-10
lines changed
  • modules/integration/src/test/scala/scala/cli/integration

1 file changed

+16
-10
lines changed

modules/integration/src/test/scala/scala/cli/integration/TestUtil.scala

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -230,18 +230,24 @@ object TestUtil {
230230
.find(_._1.toLowerCase(Locale.ROOT) == "path")
231231
.getOrElse(("PATH", ""))
232232
if (Properties.isWin) {
233-
val script =
234-
s"""@echo off
235-
|"${TestUtil.cs}" %*
236-
|""".stripMargin
237-
os.write(binDir / "cs.bat", script, createFolders = true)
233+
val dest = binDir / "cs.bat"
234+
if (!os.exists(dest)) {
235+
val script =
236+
s"""@echo off
237+
|"${TestUtil.cs}" %*
238+
|""".stripMargin
239+
os.write(dest, script, createFolders = true)
240+
}
238241
}
239242
else {
240-
val script =
241-
s"""#!/usr/bin/env bash
242-
|exec "${TestUtil.cs}" "$$@"
243-
|""".stripMargin
244-
os.write(binDir / "cs", script, "rwxr-xr-x", createFolders = true)
243+
val dest = binDir / "cs"
244+
if (!os.exists(dest)) {
245+
val script =
246+
s"""#!/usr/bin/env bash
247+
|exec "${TestUtil.cs}" "$$@"
248+
|""".stripMargin
249+
os.write(dest, script, "rwxr-xr-x", createFolders = true)
250+
}
245251
}
246252
Map(pathVarName -> s"$binDir${File.pathSeparator}$currentPath")
247253
}

0 commit comments

Comments
 (0)