summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2013-12-12 06:09:29 -0800
committerJason Zaugg <jzaugg@gmail.com>2013-12-12 06:09:29 -0800
commit2b686791f08389900b0bd9d96a7aba8cf2b9f53d (patch)
tree4a007f9992b0da87d1f0dfb76411b9025774bca3 /test
parentfcf1adad75553d25ea4e6afe37c971902b11f35e (diff)
parent1d30ea86690db1b3b074190094d1f62d12e4efe1 (diff)
downloadscala-2b686791f08389900b0bd9d96a7aba8cf2b9f53d.tar.gz
scala-2b686791f08389900b0bd9d96a7aba8cf2b9f53d.tar.bz2
scala-2b686791f08389900b0bd9d96a7aba8cf2b9f53d.zip
Merge pull request #3169 from som-snytt/issue/4841-plugin-cp
Plugins get a class path
Diffstat (limited to 'test')
-rwxr-xr-xtest/files/neg/t6446-missing.check2
-rw-r--r--test/files/run/t4841-isolate-plugins.check2
-rw-r--r--test/files/run/t4841-isolate-plugins/ploogin.scala30
-rw-r--r--test/files/run/t4841-isolate-plugins/t4841-isolate-plugin.scala39
-rw-r--r--test/files/run/t4841-no-plugin.check1
-rw-r--r--test/files/run/t4841-no-plugin.scala17
6 files changed, 90 insertions, 1 deletions
diff --git a/test/files/neg/t6446-missing.check b/test/files/neg/t6446-missing.check
index cd867289c3..029c8057c3 100755
--- a/test/files/neg/t6446-missing.check
+++ b/test/files/neg/t6446-missing.check
@@ -1,4 +1,4 @@
-Warning: class not found: t6446.Ploogin
+Error: unable to load class: t6446.Ploogin
phase name id description
---------- -- -----------
parser 1 parse source into ASTs, perform simple desugaring
diff --git a/test/files/run/t4841-isolate-plugins.check b/test/files/run/t4841-isolate-plugins.check
new file mode 100644
index 0000000000..a6462b424b
--- /dev/null
+++ b/test/files/run/t4841-isolate-plugins.check
@@ -0,0 +1,2 @@
+My phase name is ploogin1_1
+My phase name is ploogin1_2
diff --git a/test/files/run/t4841-isolate-plugins/ploogin.scala b/test/files/run/t4841-isolate-plugins/ploogin.scala
new file mode 100644
index 0000000000..bd8c7275ec
--- /dev/null
+++ b/test/files/run/t4841-isolate-plugins/ploogin.scala
@@ -0,0 +1,30 @@
+
+package t4841
+
+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, val name: String = "ploogin") extends Plugin {
+ import global._
+
+ 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) {
+ if (settings.developer) inform(s"My phase name is $phaseName")
+ }
+ }
+ }
+}
diff --git a/test/files/run/t4841-isolate-plugins/t4841-isolate-plugin.scala b/test/files/run/t4841-isolate-plugins/t4841-isolate-plugin.scala
new file mode 100644
index 0000000000..5421922c9c
--- /dev/null
+++ b/test/files/run/t4841-isolate-plugins/t4841-isolate-plugin.scala
@@ -0,0 +1,39 @@
+
+import tools.nsc.plugins.PluginDescription
+import tools.partest.DirectTest
+
+import java.io.File
+
+// show that plugins are on isolated class loaders
+object Test extends DirectTest {
+ override def code = "class Code"
+
+ override def extraSettings = s"-usejavacp"
+
+ // plugin named ploogin1_1 or ploogin1_2, but not ploogin2_x
+ // Although the samples are in different classloaders, the plugin
+ // loader checks for distinctness by class name, so the names must differ.
+ def pluginCode(index: Int) = s"""
+ |package t4841 {
+ | class SamplePloogin$index(global: scala.tools.nsc.Global) extends Ploogin(global, s"$${PlooginCounter.named}_$index")
+ | object PlooginCounter {
+ | val count = new java.util.concurrent.atomic.AtomicInteger
+ | def named = s"ploogin$${count.incrementAndGet}"
+ | }
+ |}""".stripMargin.trim
+
+ def compilePlugin(i: Int) = {
+ val out = (testOutput / s"p$i").createDirectory()
+ val args = Seq("-usejavacp", "-d", out.path)
+ compileString(newCompiler(args: _*))(pluginCode(i))
+ val xml = PluginDescription(s"p$i", s"t4841.SamplePloogin$i").toXML
+ (out / "scalac-plugin.xml").toFile writeAll xml
+ out
+ }
+
+ override def show() = {
+ val dirs = 1 to 2 map (compilePlugin(_))
+ compile("-Xdev", s"-Xplugin:${dirs mkString ","}", "-usejavacp", "-d", testOutput.path)
+ }
+}
+
diff --git a/test/files/run/t4841-no-plugin.check b/test/files/run/t4841-no-plugin.check
new file mode 100644
index 0000000000..4338f0ce23
--- /dev/null
+++ b/test/files/run/t4841-no-plugin.check
@@ -0,0 +1 @@
+warning: No plugin in path t4841-no-plugin-run.obj/plugins.partest
diff --git a/test/files/run/t4841-no-plugin.scala b/test/files/run/t4841-no-plugin.scala
new file mode 100644
index 0000000000..d91bf7ee21
--- /dev/null
+++ b/test/files/run/t4841-no-plugin.scala
@@ -0,0 +1,17 @@
+
+import tools.partest.DirectTest
+
+import java.io.File
+
+// warn only if no plugin on Xplugin path
+object Test extends DirectTest {
+ override def code = "class Code"
+
+ override def extraSettings = s"-usejavacp -d ${testOutput.path}"
+
+ override def show() = {
+ val tmp = new File(testOutput.jfile, "plugins.partest").getAbsolutePath
+ compile("-Xdev", s"-Xplugin:$tmp", "-Xpluginsdir", tmp)
+ }
+}
+