From 9ba4cb69331386dfde9bac69dc2d5b22401face3 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Wed, 12 Dec 2018 16:56:02 -0800 Subject: collapse boilerplate folder structure within src/ folders (#505) * collapse boilerplate folder structure within src/ folders * . --- scalalib/test/src/GenIdeaTests.scala | 62 ++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 scalalib/test/src/GenIdeaTests.scala (limited to 'scalalib/test/src/GenIdeaTests.scala') diff --git a/scalalib/test/src/GenIdeaTests.scala b/scalalib/test/src/GenIdeaTests.scala new file mode 100644 index 00000000..50db95c0 --- /dev/null +++ b/scalalib/test/src/GenIdeaTests.scala @@ -0,0 +1,62 @@ +package mill.scalalib + +import coursier.Cache +import mill._ +import mill.util.{TestEvaluator, TestUtil} +import utest._ + +object GenIdeaTests extends TestSuite { + + val millSourcePath = os.pwd / 'target / 'workspace / "gen-idea" + + trait HelloWorldModule extends scalalib.ScalaModule { + def scalaVersion = "2.12.4" + def millSourcePath = GenIdeaTests.millSourcePath + object test extends super.Tests { + def testFrameworks = Seq("utest.runner.Framework") + } + } + + object HelloWorld extends TestUtil.BaseModule with HelloWorldModule + + val helloWorldEvaluator = TestEvaluator.static(HelloWorld) + + def tests: Tests = Tests { + 'genIdeaTests - { + val pp = new scala.xml.PrettyPrinter(999, 4) + + val layout = GenIdeaImpl.xmlFileLayout( + helloWorldEvaluator.evaluator, + HelloWorld, + ("JDK_1_8", "1.8 (1)"), fetchMillModules = false) + for((relPath, xml) <- layout){ + os.write.over(millSourcePath/ "generated"/ relPath, pp.format(xml), createFolders = true) + } + + Seq( + "gen-idea/idea_modules/iml" -> + millSourcePath / "generated" / ".idea_modules" /".iml", + "gen-idea/idea_modules/test.iml" -> + millSourcePath / "generated" / ".idea_modules" /"test.iml", + "gen-idea/idea_modules/mill-build.iml" -> + millSourcePath / "generated" / ".idea_modules" /"mill-build.iml", + "gen-idea/idea/libraries/scala-library-2.12.4.jar.xml" -> + millSourcePath / "generated" / ".idea" / "libraries" / "scala-library-2.12.4.jar.xml", + "gen-idea/idea/modules.xml" -> + millSourcePath / "generated" / ".idea" / "modules.xml", + "gen-idea/idea/misc.xml" -> + millSourcePath / "generated" / ".idea" / "misc.xml" + ).foreach { case (resource, generated) => + val resourceString = scala.io.Source.fromResource(resource).getLines().mkString("\n") + val generatedString = normaliseLibraryPaths(os.read(generated)) + + assert(resourceString == generatedString) + } + } + } + + + private def normaliseLibraryPaths(in: String): String = { + in.replaceAll(Cache.default.toPath.toAbsolutePath.toString, "COURSIER_HOME") + } +} -- cgit v1.2.3