summaryrefslogtreecommitdiff
path: root/src/partest
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-12-22 21:03:58 -0800
committerPaul Phillips <paulp@improving.org>2012-12-22 21:03:58 -0800
commit02ffddc6c16d6d32f898bad4497ed3b14aa2d9da (patch)
tree3abe36fd9c35672eec528879959796de2920cc48 /src/partest
parentcbac99417f58e66f257af33951f5c3341d7221a6 (diff)
parentfadb306fdf3d37284fd29c50aa3956cabe79480d (diff)
downloadscala-02ffddc6c16d6d32f898bad4497ed3b14aa2d9da.tar.gz
scala-02ffddc6c16d6d32f898bad4497ed3b14aa2d9da.tar.bz2
scala-02ffddc6c16d6d32f898bad4497ed3b14aa2d9da.zip
Merge pull request #1506 from som-snytt/issue/6446-plugin-desc
PluginComponent contributes description to -Xshow-phases. (Fixes SI-6446)
Diffstat (limited to 'src/partest')
-rw-r--r--src/partest/scala/tools/partest/nest/CompileManager.scala43
-rw-r--r--src/partest/scala/tools/partest/nest/ReflectiveRunner.scala3
-rw-r--r--src/partest/scala/tools/partest/nest/RunnerManager.scala17
3 files changed, 45 insertions, 18 deletions
diff --git a/src/partest/scala/tools/partest/nest/CompileManager.scala b/src/partest/scala/tools/partest/nest/CompileManager.scala
index 3f005d143e..9a48c5ce2b 100644
--- a/src/partest/scala/tools/partest/nest/CompileManager.scala
+++ b/src/partest/scala/tools/partest/nest/CompileManager.scala
@@ -9,7 +9,7 @@ package scala.tools.partest
package nest
import scala.tools.nsc.{ Global, Settings, CompilerCommand, FatalError, io }
-import scala.tools.nsc.io.{ File => SFile }
+import scala.reflect.io.{ Directory, File => SFile, FileOperationException }
import scala.tools.nsc.interactive.RangePositions
import scala.tools.nsc.reporters.{ Reporter, ConsoleReporter }
import scala.tools.nsc.util.{ ClassPath, FakePos }
@@ -70,10 +70,27 @@ class DirectCompiler(val fileManager: FileManager) extends SimpleCompiler {
s
}
- private def updatePluginPath(options: String): String = {
- def absolutize(path: String) = Path(path) match {
+ implicit class Copier(f: SFile) {
+ // But what if f is bigger than CHUNK?!
+ def copyTo(dest: Path) {
+ dest.toFile writeAll f.slurp
+ }
+ }
+
+ // plugin path can be relative to test root, or cwd is out
+ private def updatePluginPath(options: String, out: Option[File], srcdir: Directory): String = {
+ val dir = fileManager.testRootDir
+ def pathOrCwd(p: String) =
+ if (p == "." && out.isDefined) {
+ val plugxml = "scalac-plugin.xml"
+ val pout = Path(out.get)
+ val pd = (srcdir / plugxml).toFile
+ if (pd.exists) pd copyTo (pout / plugxml)
+ pout
+ } else Path(p)
+ def absolutize(path: String) = pathOrCwd(path) match {
case x if x.isAbsolute => x.path
- case x => (fileManager.testRootDir / x).toAbsolute.path
+ case x => (dir / x).toAbsolute.path
}
val (opt1, opt2) = (options split "\\s").toList partition (_ startsWith "-Xplugin:")
@@ -90,17 +107,21 @@ class DirectCompiler(val fileManager: FileManager) extends SimpleCompiler {
}
val logWriter = new FileWriter(log)
+ // this api has no notion of srcdir, so fake it
+ val fstFile = SFile(files(0))
+ val srcdir = fstFile.parent
+
// check whether there is a ".flags" file
+ def convertFlags(f: SFile) = updatePluginPath(f.slurp(), out, srcdir)
val logFile = basename(log.getName)
val flagsFileName = "%s.flags" format (logFile.substring(0, logFile.lastIndexOf("-")))
- val argString = (io.File(log).parent / flagsFileName) ifFile (x => updatePluginPath(x.slurp())) getOrElse ""
+ val argString = (SFile(log).parent / flagsFileName) ifFile (convertFlags) getOrElse ""
// slurp local flags (e.g., "A_1.flags")
- val fstFile = SFile(files(0))
def isInGroup(num: Int) = fstFile.stripExtension endsWith ("_" + num)
val inGroup = (1 to 9) flatMap (group => if (isInGroup(group)) List(group) else List())
val localFlagsList = if (inGroup.nonEmpty) {
- val localArgString = (fstFile.parent / (fstFile.stripExtension + ".flags")) ifFile (x => updatePluginPath(x.slurp())) getOrElse ""
+ val localArgString = (srcdir / (fstFile.stripExtension + ".flags")) ifFile (convertFlags) getOrElse ""
localArgString.split(' ').toList.filter(_.length > 0)
} else List()
@@ -140,8 +161,10 @@ class DirectCompiler(val fileManager: FileManager) extends SimpleCompiler {
NestUI.verbose("compiling "+toCompile)
NestUI.verbose("with classpath: "+global.classPath.toString)
NestUI.verbose("and java classpath: "+ propOrEmpty("java.class.path"))
- try new global.Run compile toCompile
- catch {
+ try {
+ if (command.shouldStopWithInfo) logWriter append (command getInfoMessage global)
+ else new global.Run compile toCompile
+ } catch {
case FatalError(msg) =>
testRep.error(null, "fatal error: " + msg)
return CompilerCrashed
@@ -152,7 +175,7 @@ class DirectCompiler(val fileManager: FileManager) extends SimpleCompiler {
}
finally logWriter.close()
- if (testRep.hasErrors) CompileFailed
+ if (testRep.hasErrors || command.shouldStopWithInfo) CompileFailed
else CompileSuccess
}
}
diff --git a/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala b/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala
index d3a40718c6..3446dd0f72 100644
--- a/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala
+++ b/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala
@@ -81,6 +81,9 @@ class ReflectiveRunner {
val newClasspath = ClassPath.join(paths: _*)
setProp("java.class.path", newClasspath)
+
+ // don't let partest find pluginsdir; in ant build, standard plugin has dedicated test suite
+ //setProp("scala.home", latestLibFile.parent.parent.path)
setProp("scala.home", "")
if (isPartestDebug)
diff --git a/src/partest/scala/tools/partest/nest/RunnerManager.scala b/src/partest/scala/tools/partest/nest/RunnerManager.scala
index f2ce19a950..fbef97dab4 100644
--- a/src/partest/scala/tools/partest/nest/RunnerManager.scala
+++ b/src/partest/scala/tools/partest/nest/RunnerManager.scala
@@ -344,21 +344,22 @@ class RunnerManager(kind: String, val fileManager: FileManager, params: TestRunP
* compiler expects and how to implement them. (see SI-1240 for the full story)
*
* In practice, this happens in 3 steps:
- * STEP1: feed all the files to scalac
- * it will parse java files and obtain their expected signatures and generate bytecode for scala files
- * STEP2: feed the java files to javac
- * it will generate the bytecode for the java files and link to the scalac-generated bytecode for scala
- * STEP3: only if there are both scala and java files, recompile the scala sources so they link to the correct
+ * STEP1: Feed all the files to scalac if there are also non-Scala sources.
+ * It will parse java files and obtain their expected signatures and generate bytecode for scala files
+ * STEP2: Feed the java files to javac if there are any.
+ * It will generate the bytecode for the java files and link to the scalac-generated bytecode for scala
+ * STEP3: (Re-)compile the scala sources so they link to the correct
* java signatures, in case the signatures deduced by scalac from the source files were wrong. Since the
* bytecode for java is already in place, we only feed the scala files to scalac so it will take the
- * java signatures from the existing javac-generated bytecode
+ * java signatures from the existing javac-generated bytecode.
+ * Note that no artifacts are deleted before this step.
*/
List(1, 2, 3).foldLeft(CompileSuccess: CompilationOutcome) {
- case (CompileSuccess, 1) if scalaFiles.nonEmpty =>
+ case (CompileSuccess, 1) if scalaFiles.nonEmpty && javaFiles.nonEmpty =>
compileMgr.attemptCompile(Some(outDir), allFiles, kind, logFile)
case (CompileSuccess, 2) if javaFiles.nonEmpty =>
javac(outDir, javaFiles, logFile)
- case (CompileSuccess, 3) if scalaFiles.nonEmpty && javaFiles.nonEmpty =>
+ case (CompileSuccess, 3) if scalaFiles.nonEmpty =>
// TODO: Do we actually need this? SI-1240 is known to require this, but we don't know if other tests
// require it: https://groups.google.com/forum/?fromgroups#!topic/scala-internals/rFDKAcOKciU
compileMgr.attemptCompile(Some(outDir), scalaFiles, kind, logFile)