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

drive-relative paths in Windows SHELL environments #2516

Merged
merged 11 commits into from
Nov 24, 2023
Merged
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ out/
.scala-build
dest/
target/

# ignore vim backup files
*.sw[op]
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ object InstallCompletions extends ScalaCommand[InstallCompletionsOptions] {
def getFormat(format: Option[String]): Option[String] =
format.map(_.trim).filter(_.nonEmpty)
.orElse {
Option(System.getenv("SHELL")).map(_.split(File.separator).last).map {
Option(System.getenv("SHELL")).map(_.split("[\\/]+").last).map {
case "bash" => Bash.id
case "zsh" => Zsh.id
case other => other
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ abstract class CompileTestDefinitions(val scalaVersionOpt: Option[String])
"."
).call(cwd = root)
val classPath = res.out.trim().split(File.pathSeparator)
val classPathFileNames = classPath.map(_.split(Pattern.quote(File.separator)).last)
val classPathFileNames = classPath.map(_.split("[\\\\/]+").last)
expect(classPathFileNames.exists(_.startsWith("spark-core_")))
// usually a duplicate is there if we don't call .distrinct when necessary here or there
expect(classPathFileNames.exists(_.startsWith("snappy-java")))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -561,4 +561,20 @@ class ConfigTests extends ScalaCliSuite {
}
}

test("verify os.Path attributes") {
philwalk marked this conversation as resolved.
Show resolved Hide resolved
// requires os-lib 0.9.2 or later to succeed in Windows
val dr = os.Path.driveRoot
val testStr = "/omg"
val p = os.Path(testStr) // <<< must not throw Exception
val absPath = p.toString.replace('\\', '/')
val relPath = if (dr.nonEmpty) absPath.drop(2) else absPath
val synPath = s"${os.Path.driveRoot}$relPath"
printf("absPath[%s]\n", absPath)
printf("synPath[%s]\n", synPath)
printf("relPath[%s]\n", relPath)
expect(absPath == synPath)
expect(relPath == testStr)
expect(absPath endsWith testStr)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ abstract class PackageTestDefinitions(val scalaVersionOpt: Option[String])
if (actualScalaVersion.startsWith("2.")) actualScalaVersion
else {
val scalaLibJarName = scalaLibCp.split(File.pathSeparator)
.map(_.split(Pattern.quote(File.separator)).last).find(_.startsWith("scala-library-"))
.map(_.split("[\\\\/]+").last).find(_.startsWith("scala-library-"))
.getOrElse {
sys.error(s"scala-library not found in provided class path $scalaLibCp")
}
Expand Down
2 changes: 1 addition & 1 deletion project/deps.sc
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ object Deps {
def munit = ivy"org.scalameta::munit:0.7.29"
def nativeTestRunner = ivy"org.scala-native::test-runner:${Versions.scalaNative}"
def nativeTools = ivy"org.scala-native::tools:${Versions.scalaNative}"
def osLib = ivy"com.lihaoyi::os-lib:0.9.1"
def osLib = ivy"com.lihaoyi::os-lib:0.9.2"
philwalk marked this conversation as resolved.
Show resolved Hide resolved
def pprint = ivy"com.lihaoyi::pprint:0.8.1"
def pythonInterface = ivy"io.github.alexarchambault.python:interface:0.1.0"
def pythonNativeLibs = ivy"ai.kien::python-native-libs:0.2.4"
Expand Down
Loading