@@ -560,8 +560,10 @@ abstract class RunTestDefinitions
560
560
forbiddenDirTest()
561
561
}
562
562
563
- private def resourcesInputs (directive : String = " " ) = {
564
- val resourceContent = " Hello from resources"
563
+ protected def resourcesInputs (
564
+ directive : String = " " ,
565
+ resourceContent : String = " Hello from resources"
566
+ ): TestInputs =
565
567
TestInputs (
566
568
os.rel / " src" / " proj" / " resources" / " test" / " data" -> resourceContent,
567
569
os.rel / " src" / " proj" / " Test.scala" ->
@@ -571,24 +573,30 @@ abstract class RunTestDefinitions
571
573
| val cl = Thread.currentThread().getContextClassLoader
572
574
| val is = cl.getResourceAsStream("test/data")
573
575
| val content = scala.io.Source.fromInputStream(is)(scala.io.Codec.UTF8).mkString
574
- | assert (content == " $resourceContent " )
576
+ | println (content)
575
577
| }
576
578
|}
577
579
| """ .stripMargin
578
580
)
579
- }
580
581
581
- test(" resources" ) {
582
- resourcesInputs().fromRoot { root =>
583
- os.proc(TestUtil .cli, " run" , " src" , " --resource-dirs" , " ./src/proj/resources" ).call(cwd =
584
- root
585
- )
582
+ test(" resources via command line" ) {
583
+ val expectedMessage = " hello"
584
+ resourcesInputs(resourceContent = expectedMessage).fromRoot { root =>
585
+ val res = os.proc(TestUtil .cli, " run" , " src" , " --resource-dirs" , " ./src/proj/resources" )
586
+ .call(cwd = root)
587
+ expect(res.out.trim() == expectedMessage)
586
588
}
587
589
}
588
590
test(" resources via directive" ) {
589
- resourcesInputs(" //> using resourceDirs \" ./resources\" " ).fromRoot { root =>
590
- os.proc(TestUtil .cli, " run" , " ." ).call(cwd = root)
591
- }
591
+ val expectedMessage = " hello"
592
+ resourcesInputs(
593
+ directive = " //> using resourceDirs \" ./resources\" " ,
594
+ resourceContent = expectedMessage
595
+ )
596
+ .fromRoot { root =>
597
+ val res = os.proc(TestUtil .cli, " run" , " ." ).call(cwd = root)
598
+ expect(res.out.trim() == expectedMessage)
599
+ }
592
600
}
593
601
594
602
def argsAsIsTest (): Unit = {
0 commit comments