From 4ab66d1613da276712692001ed8f9f3c009736ab Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Sat, 18 May 2013 08:46:43 -0700 Subject: SI-7494 Tests for status quo Exploit SI-6446 fix to move old pending tests for plugins to the active pool. Also, nuance the partest runner to allow the compiler to crash with a FatalError if a check file is present. Some of the plugin tests make phase assembly throw. One of the legacy tests was moved back to pending: There seems to be a race for who shall be deemed truly dependent. Back to pending for you! apm@mara:~/projects/snytt/test$ ./partest files/neg/t7494-cyclic-dependency/ Selected 1 tests drawn from specified tests > starting 1 test in neg ok 1 - neg/t7494-cyclic-dependency 1/1 passed (elapsed time: 00:00:04) Test Run PASSED apm@mara:~/projects/snytt/test$ ./partest files/neg/t7494-cyclic-dependency/ Selected 1 tests drawn from specified tests > starting 1 test in neg !! 1 - neg/t7494-cyclic-dependency [output differs] > 0/1 passed, 1 failed in neg >>>>> Transcripts from failed tests >>>>> > partest files/neg/t7494-cyclic-dependency % scalac t7494-cyclic-dependency/ThePlugin.scala % scalac t7494-cyclic-dependency/sample_2.scala error: Cycle in compiler phase dependencies detected, phase cyclicdependency1 reacted twice! % diff files/neg/t7494-cyclic-dependency-neg.log files/neg/t7494-cyclic-dependency.check @@ -1 +1 @@ -error: Cycle in compiler phase dependencies detected, phase cyclicdependency1 reacted twice! +error: Cycle in compiler phase dependencies detected, phase cyclicdependency2 reacted twice! 0/1 passed, 1 failed (elapsed time: 00:00:04) Test Run FAILED --- test/files/neg/t7494-after-terminal.check | 2 ++ .../files/neg/t7494-after-terminal/ThePlugin.scala | 31 ++++++++++++++++++++ test/files/neg/t7494-after-terminal/sample_2.flags | 1 + test/files/neg/t7494-after-terminal/sample_2.scala | 6 ++++ .../neg/t7494-after-terminal/scalac-plugin.xml | 5 ++++ test/files/neg/t7494-before-parser.check | 2 ++ test/files/neg/t7494-before-parser/ThePlugin.scala | 32 +++++++++++++++++++++ test/files/neg/t7494-before-parser/sample_2.flags | 1 + test/files/neg/t7494-before-parser/sample_2.scala | 6 ++++ .../neg/t7494-before-parser/scalac-plugin.xml | 5 ++++ test/files/neg/t7494-cyclic-dependency.check | 1 + test/files/neg/t7494-multi-right-after.check | 3 ++ .../neg/t7494-multi-right-after/ThePlugin.scala | 31 ++++++++++++++++++++ .../neg/t7494-multi-right-after/sample_2.flags | 1 + .../neg/t7494-multi-right-after/sample_2.scala | 6 ++++ .../neg/t7494-multi-right-after/scalac-plugin.xml | 5 ++++ test/files/neg/t7494-no-options.check | 33 ++++++++++++++++++++++ test/files/neg/t7494-no-options/ploogin_1.scala | 31 ++++++++++++++++++++ test/files/neg/t7494-no-options/sample_2.flags | 1 + test/files/neg/t7494-no-options/sample_2.scala | 6 ++++ test/files/neg/t7494-no-options/scalac-plugin.xml | 4 +++ test/files/neg/t7494-right-after-before.check | 1 + .../neg/t7494-right-after-before/ThePlugin.scala | 31 ++++++++++++++++++++ .../neg/t7494-right-after-before/sample_2.flags | 1 + .../neg/t7494-right-after-before/sample_2.scala | 6 ++++ .../neg/t7494-right-after-before/scalac-plugin.xml | 5 ++++ test/files/neg/t7494-right-after-terminal.check | 2 ++ .../neg/t7494-right-after-terminal/ThePlugin.scala | 32 +++++++++++++++++++++ .../neg/t7494-right-after-terminal/sample_2.flags | 1 + .../neg/t7494-right-after-terminal/sample_2.scala | 6 ++++ .../t7494-right-after-terminal/scalac-plugin.xml | 5 ++++ 31 files changed, 303 insertions(+) create mode 100644 test/files/neg/t7494-after-terminal.check create mode 100644 test/files/neg/t7494-after-terminal/ThePlugin.scala create mode 100644 test/files/neg/t7494-after-terminal/sample_2.flags create mode 100644 test/files/neg/t7494-after-terminal/sample_2.scala create mode 100644 test/files/neg/t7494-after-terminal/scalac-plugin.xml create mode 100644 test/files/neg/t7494-before-parser.check create mode 100644 test/files/neg/t7494-before-parser/ThePlugin.scala create mode 100644 test/files/neg/t7494-before-parser/sample_2.flags create mode 100644 test/files/neg/t7494-before-parser/sample_2.scala create mode 100644 test/files/neg/t7494-before-parser/scalac-plugin.xml create mode 100644 test/files/neg/t7494-cyclic-dependency.check create mode 100644 test/files/neg/t7494-multi-right-after.check create mode 100644 test/files/neg/t7494-multi-right-after/ThePlugin.scala create mode 100644 test/files/neg/t7494-multi-right-after/sample_2.flags create mode 100644 test/files/neg/t7494-multi-right-after/sample_2.scala create mode 100644 test/files/neg/t7494-multi-right-after/scalac-plugin.xml create mode 100644 test/files/neg/t7494-no-options.check create mode 100644 test/files/neg/t7494-no-options/ploogin_1.scala create mode 100644 test/files/neg/t7494-no-options/sample_2.flags create mode 100644 test/files/neg/t7494-no-options/sample_2.scala create mode 100644 test/files/neg/t7494-no-options/scalac-plugin.xml create mode 100644 test/files/neg/t7494-right-after-before.check create mode 100644 test/files/neg/t7494-right-after-before/ThePlugin.scala create mode 100644 test/files/neg/t7494-right-after-before/sample_2.flags create mode 100644 test/files/neg/t7494-right-after-before/sample_2.scala create mode 100644 test/files/neg/t7494-right-after-before/scalac-plugin.xml create mode 100644 test/files/neg/t7494-right-after-terminal.check create mode 100644 test/files/neg/t7494-right-after-terminal/ThePlugin.scala create mode 100644 test/files/neg/t7494-right-after-terminal/sample_2.flags create mode 100644 test/files/neg/t7494-right-after-terminal/sample_2.scala create mode 100644 test/files/neg/t7494-right-after-terminal/scalac-plugin.xml (limited to 'test/files') diff --git a/test/files/neg/t7494-after-terminal.check b/test/files/neg/t7494-after-terminal.check new file mode 100644 index 0000000000..096efe09cd --- /dev/null +++ b/test/files/neg/t7494-after-terminal.check @@ -0,0 +1,2 @@ +error: [phase assembly, after dependency on terminal phase not allowed: afterterminal => terminal] +one error found diff --git a/test/files/neg/t7494-after-terminal/ThePlugin.scala b/test/files/neg/t7494-after-terminal/ThePlugin.scala new file mode 100644 index 0000000000..2a4607392f --- /dev/null +++ b/test/files/neg/t7494-after-terminal/ThePlugin.scala @@ -0,0 +1,31 @@ +package scala.test.plugins + +import scala.tools.nsc +import nsc.Global +import nsc.Phase +import nsc.plugins.Plugin +import nsc.plugins.PluginComponent + +class ThePlugin(val global: Global) extends Plugin { + import global._ + + val name = "afterterminal" + val description = "Declares one plugin that wants to be after the terminal phase" + val components = List[PluginComponent](thePhase) + + private object thePhase extends PluginComponent { + val global = ThePlugin.this.global + + val runsAfter = List[String]("terminal") + + val phaseName = ThePlugin.this.name + + def newPhase(prev: Phase) = new ThePhase(prev) + } + + private class ThePhase(prev: Phase) extends Phase(prev) { + def name = ThePlugin.this.name + def run {} + } +} + diff --git a/test/files/neg/t7494-after-terminal/sample_2.flags b/test/files/neg/t7494-after-terminal/sample_2.flags new file mode 100644 index 0000000000..b8a476e361 --- /dev/null +++ b/test/files/neg/t7494-after-terminal/sample_2.flags @@ -0,0 +1 @@ +-Xplugin:. -Xplugin-require:afterterminal diff --git a/test/files/neg/t7494-after-terminal/sample_2.scala b/test/files/neg/t7494-after-terminal/sample_2.scala new file mode 100644 index 0000000000..73cdc64e40 --- /dev/null +++ b/test/files/neg/t7494-after-terminal/sample_2.scala @@ -0,0 +1,6 @@ + +package sample + +// just a sample that is compiled with the sample plugin enabled +object Sample extends App { +} diff --git a/test/files/neg/t7494-after-terminal/scalac-plugin.xml b/test/files/neg/t7494-after-terminal/scalac-plugin.xml new file mode 100644 index 0000000000..2558d6fd03 --- /dev/null +++ b/test/files/neg/t7494-after-terminal/scalac-plugin.xml @@ -0,0 +1,5 @@ + + ignored + scala.test.plugins.ThePlugin + + diff --git a/test/files/neg/t7494-before-parser.check b/test/files/neg/t7494-before-parser.check new file mode 100644 index 0000000000..9a407923b1 --- /dev/null +++ b/test/files/neg/t7494-before-parser.check @@ -0,0 +1,2 @@ +error: [phase assembly, before dependency on parser phase not allowed: parser => beforeparser] +one error found diff --git a/test/files/neg/t7494-before-parser/ThePlugin.scala b/test/files/neg/t7494-before-parser/ThePlugin.scala new file mode 100644 index 0000000000..7ca896650d --- /dev/null +++ b/test/files/neg/t7494-before-parser/ThePlugin.scala @@ -0,0 +1,32 @@ +package scala.test.plugins + +import scala.tools.nsc +import nsc.Global +import nsc.Phase +import nsc.plugins.Plugin +import nsc.plugins.PluginComponent + +class ThePlugin(val global: Global) extends Plugin { + import global._ + + val name = "beforeparser" + val description = "Declares one plugin that wants to be before the parser phase" + val components = List[PluginComponent](thePhase) + + private object thePhase extends PluginComponent { + val global = ThePlugin.this.global + + val runsAfter = List[String]() + override val runsBefore = List[String]("parser") + + val phaseName = ThePlugin.this.name + + def newPhase(prev: Phase) = new ThePhase(prev) + } + + private class ThePhase(prev: Phase) extends Phase(prev) { + def name = ThePlugin.this.name + def run {} + } +} + diff --git a/test/files/neg/t7494-before-parser/sample_2.flags b/test/files/neg/t7494-before-parser/sample_2.flags new file mode 100644 index 0000000000..0c92fc8a06 --- /dev/null +++ b/test/files/neg/t7494-before-parser/sample_2.flags @@ -0,0 +1 @@ +-Xplugin:. -Xplugin-require:beforeparser diff --git a/test/files/neg/t7494-before-parser/sample_2.scala b/test/files/neg/t7494-before-parser/sample_2.scala new file mode 100644 index 0000000000..73cdc64e40 --- /dev/null +++ b/test/files/neg/t7494-before-parser/sample_2.scala @@ -0,0 +1,6 @@ + +package sample + +// just a sample that is compiled with the sample plugin enabled +object Sample extends App { +} diff --git a/test/files/neg/t7494-before-parser/scalac-plugin.xml b/test/files/neg/t7494-before-parser/scalac-plugin.xml new file mode 100644 index 0000000000..90ff27dc2a --- /dev/null +++ b/test/files/neg/t7494-before-parser/scalac-plugin.xml @@ -0,0 +1,5 @@ + + beforeparser + scala.test.plugins.ThePlugin + + diff --git a/test/files/neg/t7494-cyclic-dependency.check b/test/files/neg/t7494-cyclic-dependency.check new file mode 100644 index 0000000000..205387c3dd --- /dev/null +++ b/test/files/neg/t7494-cyclic-dependency.check @@ -0,0 +1 @@ +error: Cycle in compiler phase dependencies detected, phase cyclicdependency2 reacted twice! diff --git a/test/files/neg/t7494-multi-right-after.check b/test/files/neg/t7494-multi-right-after.check new file mode 100644 index 0000000000..9c6fdbe91f --- /dev/null +++ b/test/files/neg/t7494-multi-right-after.check @@ -0,0 +1,3 @@ +error: Multiple phases want to run right after the phase explicitouter +Phases: erasure, multi-rafter, +Re-run with -Xgenerate-phase-graph to better see the problem. diff --git a/test/files/neg/t7494-multi-right-after/ThePlugin.scala b/test/files/neg/t7494-multi-right-after/ThePlugin.scala new file mode 100644 index 0000000000..819176fa88 --- /dev/null +++ b/test/files/neg/t7494-multi-right-after/ThePlugin.scala @@ -0,0 +1,31 @@ +package scala.test.plugins + +import scala.tools.nsc +import nsc.Global +import nsc.Phase +import nsc.plugins.Plugin +import nsc.plugins.PluginComponent + +class ThePlugin(val global: Global) extends Plugin { + import global._ + + val name = "multi-rafter" + val description = "" + val components = List[PluginComponent](thePhase) + + private object thePhase extends PluginComponent { + val global = ThePlugin.this.global + + val runsAfter = List[String]() + override val runsRightAfter = Some("explicitouter") + val phaseName = ThePlugin.this.name + + def newPhase(prev: Phase) = new ThePhase(prev) + } + + private class ThePhase(prev: Phase) extends Phase(prev) { + def name = ThePlugin.this.name + def run {} + } +} + diff --git a/test/files/neg/t7494-multi-right-after/sample_2.flags b/test/files/neg/t7494-multi-right-after/sample_2.flags new file mode 100644 index 0000000000..9273fb98d7 --- /dev/null +++ b/test/files/neg/t7494-multi-right-after/sample_2.flags @@ -0,0 +1 @@ +-Xplugin:. -Xplugin-require:multi-rafter diff --git a/test/files/neg/t7494-multi-right-after/sample_2.scala b/test/files/neg/t7494-multi-right-after/sample_2.scala new file mode 100644 index 0000000000..73cdc64e40 --- /dev/null +++ b/test/files/neg/t7494-multi-right-after/sample_2.scala @@ -0,0 +1,6 @@ + +package sample + +// just a sample that is compiled with the sample plugin enabled +object Sample extends App { +} diff --git a/test/files/neg/t7494-multi-right-after/scalac-plugin.xml b/test/files/neg/t7494-multi-right-after/scalac-plugin.xml new file mode 100644 index 0000000000..2558d6fd03 --- /dev/null +++ b/test/files/neg/t7494-multi-right-after/scalac-plugin.xml @@ -0,0 +1,5 @@ + + ignored + scala.test.plugins.ThePlugin + + diff --git a/test/files/neg/t7494-no-options.check b/test/files/neg/t7494-no-options.check new file mode 100644 index 0000000000..c197d2a671 --- /dev/null +++ b/test/files/neg/t7494-no-options.check @@ -0,0 +1,33 @@ +error: Error: ploogin has no options + phase name id description + ---------- -- ----------- + parser 1 parse source into ASTs, perform simple desugaring + namer 2 resolve names, attach symbols to named trees +packageobjects 3 load package objects + typer 4 the meat and potatoes: type the trees + patmat 5 translate match expressions +superaccessors 6 add super accessors in traits and nested classes + extmethods 7 add extension methods for inline classes + pickler 8 serialize symbol tables + refchecks 9 reference/override checking, translate nested objects + uncurry 10 uncurry, translate function values to anonymous classes + tailcalls 11 replace tail calls by jumps + specialize 12 @specialized-driven class and method specialization + explicitouter 13 this refs to outer pointers, translate patterns + erasure 14 erase types, add interfaces for traits + posterasure 15 clean up erased inline classes + lazyvals 16 allocate bitmaps, translate lazy vals into lazified defs + lambdalift 17 move nested functions to top level + constructors 18 move field definitions into constructors + flatten 19 eliminate inner classes + mixin 20 mixin composition + cleanup 21 platform-specific cleanups, generate reflective calls + icode 22 generate portable intermediate code + inliner 23 optimization: do inlining +inlinehandlers 24 optimization: inline exception handlers + closelim 25 optimization: eliminate uncalled closures + constopt 26 optimization: optimize null and other constants + dce 27 optimization: eliminate dead code + jvm 28 generate JVM bytecode + ploogin 29 A sample phase that does so many things it's kind of hard... + terminal 30 The last phase in the compiler chain diff --git a/test/files/neg/t7494-no-options/ploogin_1.scala b/test/files/neg/t7494-no-options/ploogin_1.scala new file mode 100644 index 0000000000..ed6adfc1cf --- /dev/null +++ b/test/files/neg/t7494-no-options/ploogin_1.scala @@ -0,0 +1,31 @@ + +package t6446 + +import scala.tools.nsc.{ Global, Phase } +import scala.tools.nsc.plugins.{ Plugin, PluginComponent } +import scala.reflect.io.Path +import scala.reflect.io.File + +/** A test plugin. */ +class Ploogin(val global: Global) extends Plugin { + import global._ + + val name = "ploogin" + val description = "A sample plugin for testing." + val components = List[PluginComponent](TestComponent) + + private object TestComponent extends PluginComponent { + val global: Ploogin.this.global.type = Ploogin.this.global + //override val runsBefore = List("refchecks") + val runsAfter = List("jvm") + val phaseName = Ploogin.this.name + override def description = "A sample phase that does so many things it's kind of hard to describe briefly." + def newPhase(prev: Phase) = new TestPhase(prev) + class TestPhase(prev: Phase) extends StdPhase(prev) { + override def description = TestComponent.this.description + def apply(unit: CompilationUnit) { + // kewl kode + } + } + } +} diff --git a/test/files/neg/t7494-no-options/sample_2.flags b/test/files/neg/t7494-no-options/sample_2.flags new file mode 100644 index 0000000000..7f0f7afe48 --- /dev/null +++ b/test/files/neg/t7494-no-options/sample_2.flags @@ -0,0 +1 @@ +-Xplugin:. -Xshow-phases -P:ploogin:inploog diff --git a/test/files/neg/t7494-no-options/sample_2.scala b/test/files/neg/t7494-no-options/sample_2.scala new file mode 100644 index 0000000000..73cdc64e40 --- /dev/null +++ b/test/files/neg/t7494-no-options/sample_2.scala @@ -0,0 +1,6 @@ + +package sample + +// just a sample that is compiled with the sample plugin enabled +object Sample extends App { +} diff --git a/test/files/neg/t7494-no-options/scalac-plugin.xml b/test/files/neg/t7494-no-options/scalac-plugin.xml new file mode 100644 index 0000000000..e849bb5919 --- /dev/null +++ b/test/files/neg/t7494-no-options/scalac-plugin.xml @@ -0,0 +1,4 @@ + +sample-plugin +t6446.Ploogin + diff --git a/test/files/neg/t7494-right-after-before.check b/test/files/neg/t7494-right-after-before.check new file mode 100644 index 0000000000..9b57a7711b --- /dev/null +++ b/test/files/neg/t7494-right-after-before.check @@ -0,0 +1 @@ +error: phase erasure want to run right after explicitouter, but some phase has declared to run before erasure. Re-run with -Xgenerate-phase-graph to better see the problem. diff --git a/test/files/neg/t7494-right-after-before/ThePlugin.scala b/test/files/neg/t7494-right-after-before/ThePlugin.scala new file mode 100644 index 0000000000..81ba85ae80 --- /dev/null +++ b/test/files/neg/t7494-right-after-before/ThePlugin.scala @@ -0,0 +1,31 @@ +package scala.test.plugins + +import scala.tools.nsc +import nsc.Global +import nsc.Phase +import nsc.plugins.Plugin +import nsc.plugins.PluginComponent + +class ThePlugin(val global: Global) extends Plugin { + import global._ + + val name = "rafter-before-1" + val description = "" + val components = List[PluginComponent](thePhase1) + + private object thePhase1 extends PluginComponent { + val global = ThePlugin.this.global + + val runsAfter = List[String]("refchecks") + override val runsBefore = List[String]("erasure") + val phaseName = ThePlugin.this.name + + def newPhase(prev: Phase) = new ThePhase(prev) + } + + private class ThePhase(prev: Phase) extends Phase(prev) { + def name = ThePlugin.this.name + def run {} + } +} + diff --git a/test/files/neg/t7494-right-after-before/sample_2.flags b/test/files/neg/t7494-right-after-before/sample_2.flags new file mode 100644 index 0000000000..97d0f5b5f6 --- /dev/null +++ b/test/files/neg/t7494-right-after-before/sample_2.flags @@ -0,0 +1 @@ +-Xplugin:. -Xplugin-require:rafter-before-1 diff --git a/test/files/neg/t7494-right-after-before/sample_2.scala b/test/files/neg/t7494-right-after-before/sample_2.scala new file mode 100644 index 0000000000..73cdc64e40 --- /dev/null +++ b/test/files/neg/t7494-right-after-before/sample_2.scala @@ -0,0 +1,6 @@ + +package sample + +// just a sample that is compiled with the sample plugin enabled +object Sample extends App { +} diff --git a/test/files/neg/t7494-right-after-before/scalac-plugin.xml b/test/files/neg/t7494-right-after-before/scalac-plugin.xml new file mode 100644 index 0000000000..2558d6fd03 --- /dev/null +++ b/test/files/neg/t7494-right-after-before/scalac-plugin.xml @@ -0,0 +1,5 @@ + + ignored + scala.test.plugins.ThePlugin + + diff --git a/test/files/neg/t7494-right-after-terminal.check b/test/files/neg/t7494-right-after-terminal.check new file mode 100644 index 0000000000..6fe4f63c82 --- /dev/null +++ b/test/files/neg/t7494-right-after-terminal.check @@ -0,0 +1,2 @@ +error: [phase assembly, right after dependency on terminal phase not allowed: rightafterterminal => terminal] +one error found diff --git a/test/files/neg/t7494-right-after-terminal/ThePlugin.scala b/test/files/neg/t7494-right-after-terminal/ThePlugin.scala new file mode 100644 index 0000000000..9d6d30b327 --- /dev/null +++ b/test/files/neg/t7494-right-after-terminal/ThePlugin.scala @@ -0,0 +1,32 @@ +package scala.test.plugins + +import scala.tools.nsc +import nsc.Global +import nsc.Phase +import nsc.plugins.Plugin +import nsc.plugins.PluginComponent + +class ThePlugin(val global: Global) extends Plugin { + import global._ + + val name = "rightafterterminal" + val description = "Declares one plugin that wants to be right after the terminal phase" + val components = List[PluginComponent](thePhase) + + private object thePhase extends PluginComponent { + val global = ThePlugin.this.global + + val runsAfter = List[String]() + override val runsRightAfter = Some("terminal") + + val phaseName = ThePlugin.this.name + + def newPhase(prev: Phase) = new ThePhase(prev) + } + + private class ThePhase(prev: Phase) extends Phase(prev) { + def name = ThePlugin.this.name + def run {} + } +} + diff --git a/test/files/neg/t7494-right-after-terminal/sample_2.flags b/test/files/neg/t7494-right-after-terminal/sample_2.flags new file mode 100644 index 0000000000..da046ba5f1 --- /dev/null +++ b/test/files/neg/t7494-right-after-terminal/sample_2.flags @@ -0,0 +1 @@ +-Xplugin:. -Xplugin-require:rightafterterminal diff --git a/test/files/neg/t7494-right-after-terminal/sample_2.scala b/test/files/neg/t7494-right-after-terminal/sample_2.scala new file mode 100644 index 0000000000..73cdc64e40 --- /dev/null +++ b/test/files/neg/t7494-right-after-terminal/sample_2.scala @@ -0,0 +1,6 @@ + +package sample + +// just a sample that is compiled with the sample plugin enabled +object Sample extends App { +} diff --git a/test/files/neg/t7494-right-after-terminal/scalac-plugin.xml b/test/files/neg/t7494-right-after-terminal/scalac-plugin.xml new file mode 100644 index 0000000000..2558d6fd03 --- /dev/null +++ b/test/files/neg/t7494-right-after-terminal/scalac-plugin.xml @@ -0,0 +1,5 @@ + + ignored + scala.test.plugins.ThePlugin + + -- cgit v1.2.3