diff --git a/scalanativelib/src/mill/scalanativelib/ScalaNativeModule.scala b/scalanativelib/src/mill/scalanativelib/ScalaNativeModule.scala index 8e4a1646da6..d4c868b01b6 100644 --- a/scalanativelib/src/mill/scalanativelib/ScalaNativeModule.scala +++ b/scalanativelib/src/mill/scalanativelib/ScalaNativeModule.scala @@ -24,6 +24,7 @@ import mill.scalanativelib.api._ import mill.scalanativelib.worker.{ScalaNativeWorkerExternalModule, api => workerApi} import mill.T import mill.api.PathRef +import mill.main.client.EnvVars trait ScalaNativeModule extends ScalaModule { outer => def scalaNativeVersion: T[String] @@ -352,7 +353,7 @@ trait TestScalaNativeModule extends ScalaNativeModule with TestModule { val (close, framework) = scalaNativeBridge().getFramework( nativeLink().toIO, - forkEnv(), + forkEnv() ++ Map(EnvVars.MILL_TEST_RESOURCE_FOLDER -> resources().map(_.path).mkString(";")), toWorkerApi(logLevel()), testFramework() ) diff --git a/scalanativelib/test/resources/hello-native-world/build/test/resources/hello-resource.txt b/scalanativelib/test/resources/hello-native-world/build/test/resources/hello-resource.txt new file mode 100644 index 00000000000..069f48326fc --- /dev/null +++ b/scalanativelib/test/resources/hello-native-world/build/test/resources/hello-resource.txt @@ -0,0 +1 @@ +hello world resource text \ No newline at end of file diff --git a/scalanativelib/test/resources/hello-native-world/build/test/src/utest/tests/MainTests.scala b/scalanativelib/test/resources/hello-native-world/build/test/src/utest/tests/MainTests.scala index a43e3f4befc..de075077b7f 100644 --- a/scalanativelib/test/resources/hello-native-world/build/test/src/utest/tests/MainTests.scala +++ b/scalanativelib/test/resources/hello-native-world/build/test/src/utest/tests/MainTests.scala @@ -2,7 +2,8 @@ package hellotest import hello._ import utest._ - +import java.nio.file._ +import java.util.stream.Collectors object MainTests extends TestSuite { val tests: Tests = Tests { @@ -17,6 +18,16 @@ object MainTests extends TestSuite { Main.vmName.contains("Scala") ) } + test("resource") { + val expected = new java.util.ArrayList[Path]() + expected.add(Paths.get(sys.env("MILL_TEST_RESOURCE_FOLDER") + "/hello-resource.txt")) + val listed = Files.list(Paths.get(sys.env("MILL_TEST_RESOURCE_FOLDER"))).collect(Collectors.toList()) + assert(listed == expected) + assert( + Files.readString(Paths.get(sys.env("MILL_TEST_RESOURCE_FOLDER") + "/hello-resource.txt")) == + "hello world resource text" + ) + } } } diff --git a/scalanativelib/test/src/mill/scalanativelib/HelloNativeWorldTests.scala b/scalanativelib/test/src/mill/scalanativelib/HelloNativeWorldTests.scala index 2a56e613c55..d2569ab3cf2 100644 --- a/scalanativelib/test/src/mill/scalanativelib/HelloNativeWorldTests.scala +++ b/scalanativelib/test/src/mill/scalanativelib/HelloNativeWorldTests.scala @@ -177,7 +177,7 @@ object HelloNativeWorldTests extends TestSuite { val argParserTests = resultMap("hellotest.ArgsParserTests") assert( - mainTests.size == 2, + mainTests.size == 3, mainTests("hellotest.MainTests.vmName.containNative").status == "Success", mainTests("hellotest.MainTests.vmName.containScala").status == "Success", argParserTests.size == 2,