diff options
author | Josh Suereth <joshua.suereth@gmail.com> | 2011-08-29 20:24:39 +0000 |
---|---|---|
committer | Josh Suereth <joshua.suereth@gmail.com> | 2011-08-29 20:24:39 +0000 |
commit | 8f3c3f5387125fe43ef2f7cc63f410413fa51365 (patch) | |
tree | a4b877a7efe921f7834ef8e5bd54d4dd2ca825be /src/compiler/scala/tools/ant/ClassloadVerify.scala | |
parent | d52e53ce4ff8ab2eb26eba794a637b43487f3608 (diff) | |
download | scala-8f3c3f5387125fe43ef2f7cc63f410413fa51365.tar.gz scala-8f3c3f5387125fe43ef2f7cc63f410413fa51365.tar.bz2 scala-8f3c3f5387125fe43ef2f7cc63f410413fa51365.zip |
Added extraneous test where classes are verifie...
Added extraneous test where classes are verified by loading them in
non-boot classloaders one at a time. These are not wired into the
standard workflow, but available optionally. Review by rytz
Diffstat (limited to 'src/compiler/scala/tools/ant/ClassloadVerify.scala')
-rw-r--r-- | src/compiler/scala/tools/ant/ClassloadVerify.scala | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/ant/ClassloadVerify.scala b/src/compiler/scala/tools/ant/ClassloadVerify.scala new file mode 100644 index 0000000000..33a20f6894 --- /dev/null +++ b/src/compiler/scala/tools/ant/ClassloadVerify.scala @@ -0,0 +1,53 @@ +/* __ *\ +** ________ ___ / / ___ Scala Ant Tasks ** +** / __/ __// _ | / / / _ | (c) 2005-2011, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala.tools.ant + +import org.apache.tools.ant.Project +import org.apache.tools.ant.types.{Path, Reference} +import collection.JavaConverters._ +import scala.tools.util.VerifyClass + +class ClassloadVerify extends ScalaMatchingTask { + + /** The class path to use for this compilation. */ + protected var classpath: Option[Path] = None + + /** Sets the `classpath` attribute. Used by [[http://ant.apache.org Ant]]. + * @param input The value of `classpath`. */ + def setClasspath(input: Path) { + classpath = Some(input) + } + + def setClasspathref(input: Reference) { + val p = new Path(getProject()) + p.setRefid(input) + classpath = Some(p) + } + + private def getClasspath: Array[String] = classpath match { + case None => buildError("Member 'classpath' is empty.") + case Some(x) => x.list.toArray + } + + override def execute(): Unit = { + val results = VerifyClass.run(getClasspath).asScala + results foreach (r => log("Checking: " + r, Project.MSG_DEBUG)) + val errors = for((name, error) <- results; if error != null) yield (name,error) + if(errors.isEmpty) { + // TODO - Log success + log("Classload verification succeeded with " + results.size + " classes.", Project.MSG_INFO) + } else { + for((name, error) <- errors) { + log(name + " failed verification with: " + error, Project.MSG_ERR) + } + buildError(errors.size + " classload verification errors on " + results.size + " classes.") + } + } + +} |