Permalink
Browse files

Updates continuations option tests for 2.11

In Scala 2.11, the continuation plugin is no more enabled by default when
available.
Two main changes:
- forces enable the continuation plugin when running the tests on Scala 2.11
- modifies the tests to use the project specific preferences, to avoid side effects
of the configuration changes needed for the tests.
  • Loading branch information...
1 parent 9650153 commit d08420fb836cf5e6da0bde1db057281c083769d6 @skyluc skyluc committed Sep 5, 2013
@@ -0,0 +1,11 @@
+package scala.tools.eclipse
+
+import org.osgi.framework.Version
+
+object TestUtil {
+
+ def installedScalaVersionGreaterOrEqualsTo(version: Version): Boolean = {
+ ScalaPlugin.plugin.scalaLibBundle.getVersion().compareTo(version) >= 0
+ }
+
+}
@@ -8,46 +8,83 @@ import java.io.File
import org.junit.Ignore
import org.eclipse.core.resources.IncrementalProjectBuilder
import org.eclipse.core.runtime.NullProgressMonitor
+import org.osgi.framework.Version
+import org.junit.AfterClass
object ContinuationPluginSettingsTest {
private val simulator = new EclipseUserSimulator
lazy val projectName = "test_settings"
- lazy val project = simulator.createProjectInWorkspace(projectName, false)
+ lazy val project = {
+ val p =simulator.createProjectInWorkspace(projectName, false)
+ val prefs = p.projectSpecificStorage
+ prefs.setValue(SettingConverterUtil.USE_PROJECT_SETTINGS_PREFERENCE, true)
+ prefs.save()
+ p
+ }
+
+ private def setPrefToDefault(key: String) {
+ val prefs = project.projectSpecificStorage
+ prefs.setToDefault(key)
+ prefs.save()
+ }
+
+ private def setPrefValue(key: String, value: String) {
+ val prefs = project.projectSpecificStorage
+ prefs.setValue(key, value)
+ prefs.save()
+ }
+
+ private def setPrefValue(key: String, value: Boolean) {
+ val prefs = project.projectSpecificStorage
+ prefs.setValue(key, value)
+ prefs.save()
+ }
+
+ @AfterClass
+ def deleteTestProject {
+ project.underlying.delete(true, null)
+ }
+
}
class ContinuationPluginSettingsTest {
import ContinuationPluginSettingsTest._
@Test
def continuationsPluginIsAlwaysLoaded() {
- project.storage.setToDefault("Xpluginsdir")
- project.storage.setToDefault("Xplugin")
+ setPrefToDefault("Xpluginsdir")
+ setPrefToDefault("Xplugin")
+ forceEnableContinuationForNewerScalaVersion()
+ project.resetPresentationCompiler()
val plugins = loadedPlugins(project)
Assert.assertEquals("Loaded plugins: ", List("continuations"), loadedPlugins(project))
}
@Test
def loadContinuationsPluginVia_XpluginsdirCompilerSetting() {
- project.storage.setValue("Xpluginsdir", ScalaPlugin.plugin.defaultPluginsDir)
- project.storage.setValue("Xplugin", "/doesnotexits")
+ setPrefValue("Xpluginsdir", ScalaPlugin.plugin.defaultPluginsDir)
+ setPrefValue("Xplugin", "/doesnotexits")
+ forceEnableContinuationForNewerScalaVersion()
project.resetPresentationCompiler()
val plugins = loadedPlugins(project)
Assert.assertEquals("Loaded plugins: ", List("continuations"), loadedPlugins(project))
}
@Test
def loadContinuationsPluginVia_XpluginCompilerSetting() {
- project.storage.setValue("Xpluginsdir", "/doesnotexist")
- project.storage.setValue("Xplugin", ScalaPlugin.plugin.defaultPluginsDir + File.separator + "continuations.jar")
+ setPrefValue("Xpluginsdir", "/doesnotexist")
+ setPrefValue("Xplugin", ScalaPlugin.plugin.defaultPluginsDir + File.separator + "continuations.jar")
+ forceEnableContinuationForNewerScalaVersion()
project.resetPresentationCompiler()
val plugins = loadedPlugins(project)
Assert.assertEquals("Loaded plugins: ", List("continuations"), loadedPlugins(project))
}
@Test
def continuationPluginCannotBeLoadedWhen_pluginsDir_pointsToDirectoryThatDoesNotContainContinuationsPluginJar() {
- project.storage.setValue("Xpluginsdir", "/doesnotexist")
- project.storage.setValue("Xplugin", "/doesnotexits")
+ setPrefValue("Xpluginsdir", "/doesnotexist")
+ setPrefValue("Xplugin", "/doesnotexits")
+ forceEnableContinuationForNewerScalaVersion()
project.resetPresentationCompiler()
project.underlying.build(IncrementalProjectBuilder.CLEAN_BUILD, new NullProgressMonitor)
@@ -60,4 +97,10 @@ class ContinuationPluginSettingsTest {
val plugins = project.withPresentationCompiler(comp => comp.plugins)(List[Plugin]())
plugins.map(_.name)
}
+
+ private def forceEnableContinuationForNewerScalaVersion() {
+ if (TestUtil.installedScalaVersionGreaterOrEqualsTo(new Version(2, 11, 0)))
+ setPrefValue("P", "continuations:enable")
+ }
+
}
@@ -6,7 +6,6 @@
package scala.tools.eclipse
import java.io.File.pathSeparator
-
import scala.collection.immutable
import scala.collection.mutable
import scala.reflect.internal.util.BatchSourceFile
@@ -24,7 +23,6 @@ import scala.tools.eclipse.util.Trim
import scala.tools.eclipse.util.Utils
import scala.tools.nsc.MissingRequirementError
import scala.tools.nsc.Settings
-
import org.eclipse.core.resources.IContainer
import org.eclipse.core.resources.IFile
import org.eclipse.core.resources.IMarker
@@ -47,6 +45,7 @@ import org.eclipse.ui.IEditorPart
import org.eclipse.ui.IPartListener
import org.eclipse.ui.IWorkbenchPart
import org.eclipse.ui.part.FileEditorInput
+import org.eclipse.jface.preference.IPersistentPreferenceStore
trait BuildSuccessListener {
def buildSuccessful(): Unit
@@ -554,7 +553,7 @@ class ScalaProject private (val underlying: IProject) extends ClasspathManagemen
* @see #1001241.
* @see `storage` for a method that decides based on user preference
*/
- def projectSpecificStorage: IPreferenceStore = {
+ def projectSpecificStorage: IPersistentPreferenceStore = {
new PropertyStore(underlying, ScalaPlugin.prefStore, plugin.pluginId)
}

0 comments on commit d08420f

Please sign in to comment.