summaryrefslogtreecommitdiff
path: root/scalalib/test/src/GenIdeaTests.scala
diff options
context:
space:
mode:
Diffstat (limited to 'scalalib/test/src/GenIdeaTests.scala')
-rw-r--r--scalalib/test/src/GenIdeaTests.scala62
1 files changed, 62 insertions, 0 deletions
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")
+ }
+}