Skip to content
This repository
Browse code

Improve testing interactive experience.

Currently the exceptions that happen in the test are swallowed, as
the JVM is forced to exit before printing the stack trace.
Also assert message doesn't contain information about the problem.

The call to "sys.exit" masks bugs in the testing framework, that
has to be addressed more elaborately, so here we remove it. Also
add the message parameter to assert to make it more informative.

After removing "sys.exit" call, doc test starts failing. I suspect
there might be a problem when expanding doc variables, but this
should be addressed separately.
  • Loading branch information...
commit 74de4ba0a295db8754d0aee12c01d51af0d12d8b 1 parent 59d4998
Eugene Vigdorchik vigdorchik authored
12 src/interactive/scala/tools/nsc/interactive/tests/InteractiveTest.scala
@@ -74,7 +74,7 @@ abstract class InteractiveTest
74 74 /** Test's entry point */
75 75 def main(args: Array[String]) {
76 76 try execute()
77   - finally shutdown()
  77 + finally askShutdown()
78 78 }
79 79
80 80 protected def execute(): Unit = {
@@ -110,14 +110,4 @@ abstract class InteractiveTest
110 110 tester.run()
111 111 }
112 112 ****/
113   -
114   - /** shutdown the presentation compiler. */
115   - protected def shutdown() {
116   - askShutdown()
117   -
118   - // this is actually needed to force exit on test completion.
119   - // Note: May be a bug on either the testing framework or (less likely)
120   - // the presentation compiler
121   - sys.exit(0)
122   - }
123 113 }
2  src/interactive/scala/tools/nsc/interactive/tests/core/SourcesCollector.scala
@@ -11,7 +11,7 @@ private[tests] object SourcesCollector {
11 11 * With the default `filter` only .scala and .java files are collected.
12 12 * */
13 13 def apply(base: Path, filter: SourceFilter): Array[SourceFile] = {
14   - assert(base.isDirectory)
  14 + assert(base.isDirectory, base + " is not a directory")
15 15 base.walk.filter(filter).map(source).toList.toArray.sortBy(_.file.name)
16 16 }
17 17
7 test/files/presentation/doc/doc.scala
@@ -127,16 +127,17 @@ object Test extends InteractiveTest {
127 127 val baseSource = findSource("Base.scala")
128 128 val derivedSource = findSource("Derived.scala")
129 129 def existsText(where: Any, text: String): Boolean = where match {
130   - case `text` => true
  130 + case s: String => s contains text
131 131 case s: Seq[_] => s exists (existsText(_, text))
132 132 case p: Product => p.productIterator exists (existsText(_, text))
  133 + case c: Comment => existsText(c.body, text)
133 134 }
134 135 val (derived, base) = compiler.ask { () =>
135 136 val derived = definitions.RootPackage.info.decl(newTermName("p")).info.decl(newTypeName("Derived"))
136 137 (derived, derived.ancestors(0))
137 138 }
138 139 val cmt1 = getComment(derived, derivedSource, (base, baseSource)::(derived, derivedSource)::Nil)
139   - if (!existsText(cmt1, "Derived comment."))
  140 + if (!existsText(cmt1, "This is Derived comment"))
140 141 println("Unexpected Derived class comment:"+cmt1)
141 142
142 143 val (fooDerived, fooBase) = compiler.ask { () =>
@@ -145,7 +146,7 @@ object Test extends InteractiveTest {
145 146 }
146 147
147 148 val cmt2 = getComment(fooDerived, derivedSource, (fooBase, baseSource)::(fooDerived, derivedSource)::Nil)
148   - if (!existsText(cmt2, "Base method has documentation."))
  149 + if (!existsText(cmt2, "Base method has documentation"))
149 150 println("Unexpected foo method comment:"+cmt2)
150 151 }
151 152 }
2  test/files/presentation/doc/src/p/Base.scala
... ... @@ -1,7 +1,7 @@
1 1 package p
2 2
3 3 /**
4   - * @define BaseComment $BaseVar comment.
  4 + * @define BaseComment This is $BaseVar comment.
5 5 */
6 6 trait Base {
7 7 /**

0 comments on commit 74de4ba

Please sign in to comment.
Something went wrong with that request. Please try again.