scala.tools.nsc.interactive.tests

InteractiveTest

abstract class InteractiveTest extends AskParse with AskShutdown with AskReload with AskLoadedTyped with PresentationCompilerInstance with CoreTestDefs with InteractiveTestSettings

A base class for writing interactive compiler tests.

This class tries to cover common functionality needed when testing the presentation compiler: instantiation source files, reloading, creating positions, instantiating the presentation compiler, random stress testing.

By default, this class loads all scala and java classes found under src/, going recursively into subfolders. Loaded classes are found in sourceFiles. trait TestResources The presentation compiler is available through compiler.

It is easy to test member completion, type and hyperlinking at a given position. Source files are searched for TextMarkers. By default, the completion marker is /*!*/, the typedAt marker is /*?*/ and the hyperlinking marker is /*#*/. Place these markers in your source files, and the test framework will automatically pick them up and test the corresponding actions. Sources are reloaded by askReload(sourceFiles) (blocking call). All ask operations are placed on the work queue without waiting for each one to complete before asking the next. After all asks, it waits for each response in turn and prints the result. The default timeout is 1 second per operation.

To define a custom operation you have to:

(1) Define a new marker by extending TestMarker (2) Provide an implementation for the operation you want to check by extending PresentationCompilerTestDef (3) Add the class defined in (1) to the set of executed test actions by calling ++ on InteractiveTest.

Then you can simply use the new defined marker in your test sources and the testing framework will automatically pick it up.

Self Type
InteractiveTest
Source
InteractiveTest.scala
See also

Check existing tests under test/files/presentation

Linear Supertypes
InteractiveTestSettings, CoreTestDefs, PresentationCompilerRequestsWorkingMode, TestResources, TestSettings, PresentationCompilerInstance, AskLoadedTyped, AskReload, AskShutdown, AskParse, AskCommand, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. InteractiveTest
  2. InteractiveTestSettings
  3. CoreTestDefs
  4. PresentationCompilerRequestsWorkingMode
  5. TestResources
  6. TestSettings
  7. PresentationCompilerInstance
  8. AskLoadedTyped
  9. AskReload
  10. AskShutdown
  11. AskParse
  12. AskCommand
  13. AnyRef
  14. Any
Visibility
  1. Public
  2. All

Instance Constructors

  1. new InteractiveTest()

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. def ++(tests: PresentationCompilerTestDef*): Unit

    Add new presentation compiler actions to test.

    Add new presentation compiler actions to test. Presentation compiler's test need to extends trait PresentationCompilerTestDef.

    Attributes
    protected
  5. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  6. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  7. final val TIMEOUT: Int(10000)

    Attributes
    protected
    Definition Classes
    TestSettings
  8. val argsString: String

    If there's a file ending in .

    If there's a file ending in .opts, read it and parse it for cmd line arguments.

    Attributes
    protected
    Definition Classes
    InteractiveTestSettings
  9. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  10. def ask[T](op: (Response[T]) ⇒ Unit): Response[T]

    Presentation compiler's askXXX actions work by doing side-effects on a Response instance passed as an argument during the askXXX call.

    Presentation compiler's askXXX actions work by doing side-effects on a Response instance passed as an argument during the askXXX call. The defined method ask is meant to encapsulate this behavior.

    Attributes
    protected
    Definition Classes
    AskCommand
  11. def askAllSources[T]: (TestMarker) ⇒ ((Position) ⇒ Response[T]) ⇒ ((Position, T) ⇒ Unit) ⇒ Unit

    Attributes
    protected
    Definition Classes
    PresentationCompilerRequestsWorkingMode
  12. def askLoadedTyped(source: SourceFile)(implicit reporter: Reporter): Response[Tree]

    Attributes
    protected
    Definition Classes
    AskLoadedTyped
  13. def askParse(sources: Seq[SourceFile]): Unit

    sources need to be entirely parsed before running the test (else commands such as AskCompletionAt may fail simply because the source's AST is not yet loaded).

    sources need to be entirely parsed before running the test (else commands such as AskCompletionAt may fail simply because the source's AST is not yet loaded).

    Definition Classes
    AskParse
  14. def askReload(sources: Seq[SourceFile])(implicit reporter: Reporter): Response[Unit]

    Reload the given source files and wait for them to be reloaded.

    Reload the given source files and wait for them to be reloaded.

    Attributes
    protected
    Definition Classes
    AskReload
  15. def askShutdown(): Unit

    Definition Classes
    AskShutdown
  16. val baseDir: Path

    The base directory for this test, usually a subdirectory of "test/files/presentation/"

    The base directory for this test, usually a subdirectory of "test/files/presentation/"

    Attributes
    protected
    Definition Classes
    TestSettings
  17. def clone(): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  18. lazy val compiler: Global

    Attributes
    protected
    Definition Classes
    PresentationCompilerInstance
  19. val compilerReporter: StoreReporter

    Attributes
    protected
    Definition Classes
    PresentationCompilerInstance
  20. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  21. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  22. def finalize(): Unit

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  23. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  24. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  25. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  26. def main(args: Array[String]): Unit

    Test's entry point

  27. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  28. final def notify(): Unit

    Definition Classes
    AnyRef
  29. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  30. val outDir: Path

    The root directory for this test suite, usually the test kind ("test/files/presentation").

    The root directory for this test suite, usually the test kind ("test/files/presentation").

    Attributes
    protected
    Definition Classes
    TestSettings
  31. def prepareSettings(settings: Settings): Unit

    Prepare the settings object.

    Prepare the settings object. Load the .opts file and adjust all paths from the Unix-like syntax to the platform specific syntax. This is necessary so that a single .opts file can be used on all platforms.

    Attributes
    protected
    Definition Classes
    InteractiveTestSettings → PresentationCompilerInstance
    Note

    Bootclasspath is treated specially. If there is a -bootclasspath option in the file, the 'usejavacp' setting is set to false. This ensures that the bootclasspath takes precedence over the scala-library used to run the current test.

  32. def printClassPath(implicit reporter: Reporter): Unit

    Attributes
    protected
    Definition Classes
    InteractiveTestSettings → PresentationCompilerInstance
  33. implicit val reporter: Reporter

    Attributes
    protected
    Definition Classes
    TestSettings
  34. val runRandomTests: Boolean

    Attributes
    protected
  35. def runTests(): Unit

    Run all defined PresentationCompilerTestDef

    Run all defined PresentationCompilerTestDef

    Attributes
    protected
  36. val settings: Settings

    Attributes
    protected
    Definition Classes
    PresentationCompilerInstance
  37. def shutdown(): Unit

    shutdown the presentation compiler.

    shutdown the presentation compiler.

    Attributes
    protected
  38. val sourceDir: String

    Where source files are placed.

    Where source files are placed.

    Attributes
    protected
    Definition Classes
    TestSettings
  39. lazy val sourceFiles: Array[SourceFile]

    collected source files that are to be used by the test runner

    collected source files that are to be used by the test runner

    Attributes
    protected
    Definition Classes
    TestResources
  40. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  41. val synchronousRequests: Boolean

    Should askAllSources wait for each ask to finish before issuing the next?

    Should askAllSources wait for each ask to finish before issuing the next?

    Attributes
    protected
    Definition Classes
    InteractiveTestPresentationCompilerRequestsWorkingMode
  42. lazy val testActions: ListBuffer[PresentationCompilerTestDef]

    The core set of test actions that are executed during each test run are CompletionAction, TypeAction and HyperlinkAction.

    The core set of test actions that are executed during each test run are CompletionAction, TypeAction and HyperlinkAction. Override this member if you need to change the default set of executed test actions.

    Attributes
    protected
  43. def toString(): String

    Definition Classes
    AnyRef → Any
  44. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  45. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  46. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()

Inherited from InteractiveTestSettings

Inherited from CoreTestDefs

Inherited from TestResources

Inherited from TestSettings

Inherited from PresentationCompilerInstance

Inherited from AskLoadedTyped

Inherited from AskReload

Inherited from AskShutdown

Inherited from AskParse

Inherited from AskCommand

Inherited from AnyRef

Inherited from Any