summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Timushev <rtimush@gmail.com>2017-12-29 17:41:38 +0100
committerLi Haoyi <haoyi.sg@gmail.com>2017-12-29 08:41:38 -0800
commitb31810e10f095947905786507c7c60f507bfe64c (patch)
tree0b653173a26990a3ef5d407f0f6706675c111e78
parent7250a28ac4c14f57cfdbaff1339bfcefca5f0525 (diff)
downloadmill-b31810e10f095947905786507c7c60f507bfe64c.tar.gz
mill-b31810e10f095947905786507c7c60f507bfe64c.tar.bz2
mill-b31810e10f095947905786507c7c60f507bfe64c.zip
Do not use tar for jar verification (#85)
-rw-r--r--scalaplugin/src/test/scala/mill/scalaplugin/HelloWorldTests.scala35
1 files changed, 17 insertions, 18 deletions
diff --git a/scalaplugin/src/test/scala/mill/scalaplugin/HelloWorldTests.scala b/scalaplugin/src/test/scala/mill/scalaplugin/HelloWorldTests.scala
index 4ec10472..81dcef20 100644
--- a/scalaplugin/src/test/scala/mill/scalaplugin/HelloWorldTests.scala
+++ b/scalaplugin/src/test/scala/mill/scalaplugin/HelloWorldTests.scala
@@ -1,5 +1,7 @@
package mill.scalaplugin
+import java.util.jar.JarFile
+
import ammonite.ops._
import ammonite.ops.ImplicitWd._
import mill._
@@ -10,6 +12,8 @@ import mill.scalaplugin.publish._
import sbt.internal.inc.CompileFailed
import utest._
+import scala.collection.JavaConverters._
+
trait HelloWorldModule extends ScalaModule {
def scalaVersion = "2.12.4"
def basePath = HelloWorldTests.workspacePath
@@ -134,8 +138,7 @@ object HelloWorldTests extends TestSuite {
val outPath = result.classes.path
val analysisFile = result.analysisFile
val outputFiles = ls.rec(outPath)
- val expectedClassfiles =
- compileClassfiles(workspacePath / 'compile / 'classes)
+ val expectedClassfiles = compileClassfiles.map(workspacePath / 'compile / 'classes / _)
assert(
outPath == workspacePath / 'compile / 'classes,
exists(analysisFile),
@@ -265,20 +268,16 @@ object HelloWorldTests extends TestSuite {
evalCount > 0
)
- val unJarPath = workspacePath / 'unjar
- mkdir(unJarPath)
- %("tar", "xf", result.path, "-C", unJarPath)
+ val entries = new JarFile(result.path.toIO).entries().asScala.map(_.getName).toSet
- val manifestFiles = Seq(
- unJarPath / "META-INF",
- unJarPath / "META-INF" / "MANIFEST.MF"
+ val manifestFiles = Seq[RelPath](
+ "META-INF" / "MANIFEST.MF"
)
- val expectedFiles = compileClassfiles(unJarPath) ++ manifestFiles
+ val expectedFiles = compileClassfiles ++ manifestFiles
- val jarFiles = ls.rec(unJarPath)
assert(
- jarFiles.nonEmpty,
- jarFiles.forall(expectedFiles.contains)
+ entries.nonEmpty,
+ entries == expectedFiles.map(_.toString()).toSet
)
}
'runJar - {
@@ -306,12 +305,12 @@ object HelloWorldTests extends TestSuite {
}
}
- def compileClassfiles(parentDir: Path) = Seq(
- parentDir / "Main.class",
- parentDir / "Main$.class",
- parentDir / "Main$delayedInit$body.class",
- parentDir / "Person.class",
- parentDir / "Person$.class"
+ def compileClassfiles = Seq[RelPath](
+ "Main.class",
+ "Main$.class",
+ "Main$delayedInit$body.class",
+ "Person.class",
+ "Person$.class"
)
def prepareWorkspace(): Unit = {