Skip to content

Commit ee5e528

Browse files
Add 'scala-cli compile --python' test
1 parent bd1167d commit ee5e528

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,4 +509,35 @@ abstract class CompileTestDefinitions(val scalaVersionOpt: Option[String])
509509
.call(cwd = root, stdin = os.Inherit, stdout = os.Inherit)
510510
}
511511
}
512+
513+
test("scalapy") {
514+
515+
def maybeScalapyPrefix =
516+
if (actualScalaVersion.startsWith("2.13.")) ""
517+
else "import me.shadaj.scalapy.py" + System.lineSeparator()
518+
519+
val inputs = TestInputs(
520+
os.rel / "Hello.scala" ->
521+
s"""$maybeScalapyPrefix
522+
|object Hello {
523+
| def main(args: Array[String]): Unit = {
524+
| py.Dynamic.global.print("Hello from Python", flush = true)
525+
| }
526+
|}
527+
|""".stripMargin
528+
)
529+
530+
inputs.fromRoot { root =>
531+
val res =
532+
os.proc(TestUtil.cli, "compile", "--python", "--print-class-path", ".", extraOptions)
533+
.call(cwd = root)
534+
val classPath = res.out.trim().split(File.pathSeparator)
535+
val outputDir = os.Path(classPath.head, root)
536+
val classFiles = os.walk(outputDir)
537+
.filter(_.last.endsWith(".class"))
538+
.filter(os.isFile(_))
539+
.map(_.relativeTo(outputDir))
540+
expect(classFiles.contains(os.rel / "Hello.class"))
541+
}
542+
}
512543
}

0 commit comments

Comments
 (0)