Skip to content

fix 13618 - undo windows wildcard classpath globbing #13619

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

Merged
merged 4 commits into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
20 changes: 1 addition & 19 deletions compiler/src/dotty/tools/MainGenericRunner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ object MainGenericRunner {
process(tail, settings.withExecuteMode(ExecuteMode.Run).withTargetToRun(fqName))
case ("-cp" | "-classpath" | "--class-path") :: cp :: tail =>
val cpEntries = cp.split(classpathSeparator).toList
val singleEntryClasspath: Boolean = cpEntries.nonEmpty && cpEntries.drop(1).isEmpty
val singleEntryClasspath: Boolean = cpEntries.take(2).size == 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clever

val globdir: String = if singleEntryClasspath then cp.replaceAll("[\\\\/][^\\\\/]*$", "") else "" // slash/backslash agnostic
def validGlobbedJar(s: String): Boolean = s.startsWith(globdir) && ((s.toLowerCase.endsWith(".jar") || s.toLowerCase.endsWith(".zip")))
val (tailargs, newEntries) = if singleEntryClasspath && validGlobbedJar(cpEntries.head) then
Expand Down Expand Up @@ -243,22 +243,4 @@ object MainGenericRunner {
e.foreach(_.printStackTrace())
!isFailure
}

def display(settings: Settings)= Seq(
s"verbose: ${settings.verbose}",
s"classPath: ${settings.classPath.mkString("\n ","\n ","")}",
s"executeMode: ${settings.executeMode}",
s"exitCode: ${settings.exitCode}",
s"javaArgs: ${settings.javaArgs}",
s"scalaArgs: ${settings.scalaArgs}",
s"residualArgs: ${settings.residualArgs}",
s"possibleEntryPaths: ${settings.possibleEntryPaths}",
s"scriptArgs: ${settings.scriptArgs}",
s"targetScript: ${settings.targetScript}",
s"targetToRun: ${settings.targetToRun}",
s"save: ${settings.save}",
s"modeShouldBePossibleRun: ${settings.modeShouldBePossibleRun}",
s"modeShouldBeRun: ${settings.modeShouldBeRun}",
s"compiler: ${settings.compiler}",
)
}
6 changes: 4 additions & 2 deletions compiler/test/dotty/tools/scripting/ClasspathTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ class ClasspathTests:
val hashbangClasspathJars = scriptCp.split(psep).map { _.getName }.sorted.distinct
val packlibJars = listJars(s"$scriptCwd/$packLibDir").sorted.distinct

printf("%d jar files in dist/target/pack/lib\n", packlibJars.size)
printf("%d test script jars in classpath\n", hashbangClasspathJars.size)

// verify that the classpath set in the hashbang line is effective
if hashbangClasspathJars.size != packlibJars.size then
printf("%d test script jars in classpath\n", hashbangClasspathJars.size)
printf("%d jar files in dist/target/pack/lib\n", packlibJars.size)
printf("hashbangClasspathJars: %s\n", hashbangClasspathJars.mkString("\n ", "\n ", ""))

assert(hashbangClasspathJars.size == packlibJars.size)
}
Expand Down