Skip to content

Commit a96c6f7

Browse files
committed
Test --cross with the package sub-command
1 parent e947794 commit a96c6f7

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

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

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1354,7 +1354,7 @@ abstract class PackageTestDefinitions extends ScalaCliSuite with TestScalaVersio
13541354
)
13551355
else Nil)
13561356
packageDescription = packageOpts.headOption.getOrElse("bootstrap")
1357-
}
1357+
} {
13581358
test(s"package with main method in test scope ($packageDescription)") {
13591359
val mainClass = "TestScopeMain"
13601360
val testScopeFileName = s"$mainClass.test.scala"
@@ -1388,5 +1388,46 @@ abstract class PackageTestDefinitions extends ScalaCliSuite with TestScalaVersio
13881388
expect(output == message)
13891389
}
13901390
}
1391+
1392+
if (actualScalaVersion == Constants.scala3Next)
1393+
test(s"package ($packageDescription, --cross)") {
1394+
val crossDirective =
1395+
s"//> using scala $actualScalaVersion ${Constants.scala213} ${Constants.scala212}"
1396+
val mainClass = "TestScopeMain"
1397+
val mainFile = s"$mainClass.scala"
1398+
val message = "Hello"
1399+
val outputFile = mainClass + extension
1400+
TestInputs(
1401+
os.rel / "Messages.scala" ->
1402+
s"""$crossDirective
1403+
|object Messages { val msg = "$message" }""".stripMargin,
1404+
os.rel / mainFile ->
1405+
s"""object $mainClass extends App { println(Messages.msg) }""".stripMargin
1406+
).fromRoot { root =>
1407+
os.proc(
1408+
TestUtil.cli,
1409+
"--power",
1410+
"package",
1411+
"--cross",
1412+
extraOptions,
1413+
".",
1414+
packageOpts
1415+
)
1416+
.call(cwd = root)
1417+
val outputFilePath = root / outputFile
1418+
expect(os.isFile(outputFilePath))
1419+
val output =
1420+
if (packageDescription == libraryArg)
1421+
os.proc(TestUtil.cli, "run", outputFilePath).call(cwd = root).out.trim()
1422+
else if (packageDescription == jsArg)
1423+
os.proc(node, outputFilePath).call(cwd = root).out.trim()
1424+
else {
1425+
expect(Files.isExecutable(outputFilePath.toNIO))
1426+
TestUtil.maybeUseBash(outputFilePath)(cwd = root).out.trim()
1427+
}
1428+
expect(output == message)
1429+
}
1430+
}
1431+
}
13911432
}
13921433
}

0 commit comments

Comments
 (0)