Skip to content

Commit 460c98b

Browse files
authored
Merge pull request #1168 from romanowski/scala-cli-sip
Turn the sip mode also for `scala-cli-sip` binary
2 parents 5843e25 + da89c89 commit 460c98b

File tree

4 files changed

+22
-14
lines changed

4 files changed

+22
-14
lines changed

modules/cli/src/main/scala/scala/cli/ScalaCli.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ object ScalaCli {
1818

1919
val progName = (new Argv0).get("scala-cli")
2020

21-
private var isSipScala =
22-
progName == "scala" ||
23-
progName.endsWith("/scala") ||
24-
progName.endsWith(File.separator + "scala")
21+
private def checkName(name: String) =
22+
progName == name ||
23+
progName.endsWith(s"/$name") ||
24+
progName.endsWith(File.separator + name)
25+
26+
private var isSipScala = checkName("scala") || checkName("scala-cli-sip")
2527

2628
private def isGraalvmNativeImage: Boolean =
2729
sys.props.contains("org.graalvm.nativeimage.imagecode")

modules/cli/src/main/scala/scala/cli/commands/Export.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import scala.cli.commands.util.SharedOptionsUtil._
1414
import scala.cli.exportCmd._
1515

1616
object Export extends ScalaCommand[ExportOptions] {
17+
override def inSipScala = false
1718

1819
private def prepareBuild(
1920
inputs: Inputs,

modules/cli/src/main/scala/scala/cli/commands/Package.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import scala.util.Properties
4242
object Package extends ScalaCommand[PackageOptions] {
4343
override def name = "package"
4444
override def group = "Main"
45+
override def inSipScala = false
4546
override def sharedOptions(options: PackageOptions): Option[SharedOptions] = Some(options.shared)
4647
def run(options: PackageOptions, args: RemainingArgs): Unit = {
4748
maybePrintGroupHelp(options)

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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,37 @@ import scala.util.Properties
66

77
class SipScalaTests extends munit.FunSuite {
88

9-
def noDirectoriesCommandTest(): Unit =
9+
def noDirectoriesCommandTest(binaryName: String): Unit =
1010
TestInputs(Nil).fromRoot { root =>
1111
val cliPath = os.Path(TestUtil.cliPath, os.pwd)
1212

1313
os.proc(cliPath, "directories").call(cwd = root)
1414
os.proc(cliPath, "compile", "--help").call(cwd = root)
1515
os.proc(cliPath, "run", "--help").call(cwd = root)
1616

17-
os.copy(cliPath, root / "scala")
18-
os.perms.set(root / "scala", "rwxr-xr-x")
17+
os.copy(cliPath, root / binaryName)
18+
os.perms.set(root / binaryName, "rwxr-xr-x")
1919

20-
os.proc(root / "scala", "compile", "--help").call(cwd = root)
21-
os.proc(root / "scala", "run", "--help").call(cwd = root)
20+
os.proc(root / binaryName, "compile", "--help").call(cwd = root)
21+
os.proc(root / binaryName, "run", "--help").call(cwd = root)
2222

23-
val res = os.proc(root / "scala", "directories").call(
23+
val res = os.proc(root / binaryName, "directories").call(
2424
cwd = root,
2525
check = false,
2626
mergeErrIntoOut = true
2727
)
2828
expect(res.exitCode == 1)
2929
val output = res.out.text()
30-
expect(output.contains("directories: not found"))
30+
expect(output.contains(s"directories: not found"))
31+
3132
}
3233

33-
if (TestUtil.isNativeCli && !Properties.isWin)
34+
if (TestUtil.isNativeCli && !Properties.isWin) {
3435
test("no directories command when run as scala") {
35-
noDirectoriesCommandTest()
36+
noDirectoriesCommandTest("scala")
3637
}
37-
38+
test("no directories command when run as scala-cli-sip") {
39+
noDirectoriesCommandTest("scala-cli-sip")
40+
}
41+
}
3842
}

0 commit comments

Comments
 (0)