@@ -1354,7 +1354,7 @@ abstract class PackageTestDefinitions extends ScalaCliSuite with TestScalaVersio
1354
1354
)
1355
1355
else Nil )
1356
1356
packageDescription = packageOpts.headOption.getOrElse(" bootstrap" )
1357
- }
1357
+ } {
1358
1358
test(s " package with main method in test scope ( $packageDescription) " ) {
1359
1359
val mainClass = " TestScopeMain"
1360
1360
val testScopeFileName = s " $mainClass.test.scala "
@@ -1388,5 +1388,46 @@ abstract class PackageTestDefinitions extends ScalaCliSuite with TestScalaVersio
1388
1388
expect(output == message)
1389
1389
}
1390
1390
}
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
+ }
1391
1432
}
1392
1433
}
0 commit comments