Skip to content

Commit 758cf6a

Browse files
committed
Add testing for multiple scripts
1 parent 14b8f8b commit 758cf6a

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -535,10 +535,22 @@ trait RunScriptTestDefinitions { _: RunTestDefinitions =>
535535
"""//> using dep "com.lihaoyi::os-lib:0.9.1"
536536
|//> using object.wrapper
537537
|@main def main(args: String*): Unit = println("Hello")
538-
|""".stripMargin
538+
|""".stripMargin,
539+
os.rel / "munit.sc" ->
540+
"""//> using scala "3.2.2"
541+
|//> using dep "org.scalatest::scalatest:3.2.15"
542+
|
543+
|import org.scalatest.*, flatspec.*, matchers.*
544+
|
545+
|class PiTest extends AnyFlatSpec with should.Matchers {
546+
| "pi calculus" should "return a precise enough pi value" in {
547+
| math.Pi shouldBe 3.14158d +- 0.001d
548+
| }
549+
|}
550+
|org.scalatest.tools.Runner.main(Array("-oDF", "-s", classOf[PiTest].getName))""".stripMargin
539551
)
540552
inputs.fromRoot { root =>
541-
val res = os.proc(TestUtil.cli, "--power", "script.sc", "--object-wrapper")
553+
val res = os.proc(TestUtil.cli, "--power", "script.sc", "munit.sc", "--object-wrapper")
542554
.call(cwd = root, mergeErrIntoOut = true, stdout = os.Pipe)
543555

544556
val outputNormalized: String = normalizeConsoleOutput(res.out.text())
@@ -547,7 +559,7 @@ trait RunScriptTestDefinitions { _: RunTestDefinitions =>
547559
"[warn] Annotation @main in .sc scripts is not supported, it will be ignored, use .scala format instead"
548560
))
549561

550-
val directiveRes = os.proc(TestUtil.cli, "--power", "script-with-directive.sc")
562+
val directiveRes = os.proc(TestUtil.cli, "--power", "script-with-directive.sc", "munit.sc")
551563
.call(cwd = root, mergeErrIntoOut = true, stdout = os.Pipe)
552564

553565
val directiveOutputNormalized: String = normalizeConsoleOutput(directiveRes.out.text())

0 commit comments

Comments
 (0)