Skip to content

Commit

Permalink
adjust to new launcher scala cli 1.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
bishabosha committed May 7, 2024
1 parent 89f7f5c commit 1e4a234
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 18 deletions.
2 changes: 1 addition & 1 deletion bin/scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" >& /dev/null && pwd)/.."

"$ROOT/bin/common" "$ROOT/dist/target/pack/bin/scala" "$@" "--offline" "--server=false"
"$ROOT/bin/common" "$ROOT/dist/target/pack/bin/scala" "--power" "$@" "--offline" "--server=false"
2 changes: 1 addition & 1 deletion bin/test/TestScripts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class TestScripts {
s"bin/scalac script did not run properly. Output:$lineSep$dotcOutput"
)

val (retDotr, dotrOutput) = executeScript("./bin/scala HelloWorld")
val (retDotr, dotrOutput) = executeScript("./bin/scala -M HelloWorld")
assert(
retDotr == 0 && dotrOutput == "hello world\n",
s"Running hello world exited with status: $retDotr and output: $dotrOutput"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class BashExitCodeTests:
}, expectedExitCode, exitCode)

// Helpers for running scala, scalac, and scalac without the the output directory ("raw")
def scala(args: String*) = verifyExit(scalaPath, ("--offline" +: "--server=false" +: args)*)
def scala(args: String*) = verifyExit(scalaPath, ("--power" +: "--offline" +: "--server=false" +: args)*)
def scalacRaw(args: String*) = verifyExit(scalacPath, args*)
def scalac(args: String*) = scalacRaw(("-d" +: tmpDir +: args)*)

Expand Down
6 changes: 3 additions & 3 deletions compiler/test/dotty/tools/scripting/BashScriptsTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ object BashScriptsTests:
def callScript(tag: String, script: String, keyPre: String): String =
val keyArg = s"$keyPre=$tag"
printf("pass tag [%s] via [%s] to script [%s]\n", tag, keyArg, script)
val cmd: String = Seq("SCALA_OPTS= ", scalaPath, "run", keyArg, "--offline", "--server=false", script).mkString(" ")
val cmd: String = Seq("SCALA_OPTS= ", scalaPath, "run", keyArg, "--power", "--offline", "--server=false", script).mkString(" ")
printf("cmd: [%s]\n", cmd)
val (validTest, exitCode, stdout, stderr) = bashCommand(cmd)
stderr.filter { !_.contains("Inappropriate ioctl") }.foreach { System.err.printf("stderr [%s]\n", _) }
Expand Down Expand Up @@ -131,7 +131,7 @@ class BashScriptsTests:

val tag = "World5"
val commandline2 = Seq(
"SCALA_OPTS= ", scalaPath.relpath, "run", s"-Dkey=$tag", "-classpath", testJar.relpath, "--offline", "--server=false")
"SCALA_OPTS= ", scalaPath.relpath, "run", s"-Dkey=$tag", "-classpath", testJar.relpath, "--power", "--offline", "--server=false")
printf("cmd[%s]\n", commandline2.mkString(" "))
val (validTest, exitCode, stdout, stderr) = bashCommand(commandline2.mkString(" "))
assertEquals(s"Hello $tag", stdout.mkString("/n"))
Expand All @@ -157,7 +157,7 @@ class BashScriptsTests:
assumeFalse("Scripts do not yet support Scala 2 library TASTy", Properties.usingScalaLibraryTasty)
val commandline = (
Seq("SCALA_OPTS= ", scalaPath, showArgsScalaCli)
++ Seq("--offline", "--server=false")
++ Seq("--power", "--offline", "--server=false")
++ ("--" +: testScriptArgs)
).mkString(" ")
val (validTest, exitCode, stdout, stderr) = bashCommand(commandline)
Expand Down
2 changes: 1 addition & 1 deletion compiler/test/dotty/tools/scripting/ClasspathTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class ClasspathTests:
val bashCmdline = Seq(
"set +x ;",
"SCALA_OPTS=",
scalaCommand, "run", "--classpath", s"'$tastyDirGlob'", "--offline", "--server=false", relpath
scalaCommand, "run", "--classpath", s"'$tastyDirGlob'", "--power", "--offline", "--server=false", relpath
).mkString(" ")
val cmd = Array(bashExe, "-c", bashCmdline)

Expand Down
2 changes: 1 addition & 1 deletion compiler/test/dotty/tools/scripting/ExpressionTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ExpressionTest:
assert(success)

def getResult(expression: String): String =
val (_, _, stdout, stderr) = bashCommand(s"$scalaPath -e '$expression' --offline --server=false")
val (_, _, stdout, stderr) = bashCommand(s"$scalaPath -e '$expression' --power --offline --server=false")
printf("stdout: %s\n", stdout.mkString("|"))
printf("stderr: %s\n", stderr.mkString("\n", "\n", ""))
stdout.filter(_.nonEmpty).mkString("")
Expand Down
1 change: 1 addition & 0 deletions dist/bin/scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ done
[ -z "${ConEmuPID-}" -o -n "${cygwin-}" ] && export MSYSTEM= PWD= # workaround for #12405
eval "\"$JAVACMD\"" \
"-jar \"$SCALA_CLI_JAR\"" \
"--prog-name scala" \
"--cli-default-scala-version \"$SCALA_VERSION\"" \
"-r \"$MVN_REPOSITORY\"" \
"${scala_args[@]}"
Expand Down
2 changes: 1 addition & 1 deletion dist/bin/scala.bat
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ call :setScalaOpts
@rem we need to escape % in the java command path, for some reason this doesnt work in common.bat
set "_JAVACMD=!_JAVACMD:%%=%%%%!"

call "%_JAVACMD%" "-jar" "%SCALA_CLI_JAR%" "--cli-default-scala-version" "%_SCALA_VERSION%" "-r" "%MVN_REPOSITORY%" %*
call "%_JAVACMD%" "-jar" "%SCALA_CLI_JAR%" "--prog-name" "scala" "--cli-default-scala-version" "%_SCALA_VERSION%" "-r" "%MVN_REPOSITORY%" %*
if not %ERRORLEVEL%==0 ( set _EXITCODE=1& goto end )

goto end
Expand Down
2 changes: 1 addition & 1 deletion project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ object Build {
val mimaPreviousLTSDottyVersion = "3.3.0"

/** Version of Scala CLI to download */
val scalaCliLauncherVersion = "1.3.0"
val scalaCliLauncherVersion = "1.3.1"

object CompatMode {
final val BinaryCompatible = 0
Expand Down
11 changes: 3 additions & 8 deletions project/scripts/bootstrappedOnlyCmdTests
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ echo "testing scala.quoted.Expr.run from sbt scala"
"$SBT" ";scala3-compiler-bootstrapped/scalac -with-compiler tests/run-staging/quote-run.scala; scala3-compiler-bootstrapped/scala -with-compiler Test" > "$tmp"
grep -qe "val a: scala.Int = 3" "$tmp"


# setup for `scalac`/`scala` script tests
"$SBT" dist/pack

Expand All @@ -37,11 +36,9 @@ test "$EXPECTED_OUTPUT" = "$(cat "$tmp")"
clear_out "$OUT1"

# check that `scalac` and `scala` works for staging.
# TODO: scala3-staging should be automatically added by Scala CLI
# - see: https://github.com/VirtusLab/scala-cli/issues/2879
clear_out "$OUT"
./bin/scalac tests/run-staging/i4044f.scala -d "$OUT"
./bin/scala -with-compiler -classpath "$OUT" --dep "org.scala-lang::scala3-staging:$scala_version" -M Test > "$tmp"
./bin/scala -with-compiler -classpath "$OUT" -M Test > "$tmp"

# check that `scalac -from-tasty` compiles and `scala` runs it
echo "testing ./bin/scalac -from-tasty and scala -classpath"
Expand Down Expand Up @@ -99,12 +96,10 @@ clear_out "$OUT"
./bin/scalac -help > "$tmp" 2>&1
grep -qe "Usage: scalac <options> <source files>" "$tmp"

# TODO: JAVA launcher should be able to override "scala-cli" program name
# - see: https://github.com/VirtusLab/scala-cli/issues/2838#issuecomment-2085130815
./bin/scala -help > "$tmp" 2>&1
grep -qe "See 'scala-cli <command> --help' to read about a specific subcommand." "$tmp"
grep -qe "See 'scala <command> --help' to read about a specific subcommand." "$tmp"

./bin/scala -d hello.jar tests/run/hello.scala --server=false
./bin/scala -d hello.jar tests/run/hello.scala
ls hello.jar

echo "testing i12973"
Expand Down

0 comments on commit 1e4a234

Please sign in to comment.