Skip to content

Commit

Permalink
[SPARK-7558] Guard against direct uses of FunSuite / FunSuiteLike
Browse files Browse the repository at this point in the history
This is a follow-up patch to apache#6441.

Author: Andrew Or <[email protected]>

Closes apache#6510 from andrewor14/extends-funsuite-check and squashes the following commits:

6618b46 [Andrew Or] Exempt SparkSinkSuite from the FunSuite check
99d02ac [Andrew Or] Merge branch 'master' of github.com:apache/spark into extends-funsuite-check
48874dd [Andrew Or] Guard against direct uses of FunSuite / FunSuiteLike
  • Loading branch information
Andrew Or authored and nemccarthy committed Jun 19, 2015
1 parent 3b43a08 commit 4b72668
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/src/test/scala/org/apache/spark/SparkFunSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@

package org.apache.spark

// scalastyle:off
import org.scalatest.{FunSuite, Outcome}

/**
* Base abstract class for all unit tests in Spark for handling common functionality.
*/
private[spark] abstract class SparkFunSuite extends FunSuite with Logging {
// scalastyle:on

/**
* Log the suite name and the test name before and after each test.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,18 @@ import org.apache.flume.Context
import org.apache.flume.channel.MemoryChannel
import org.apache.flume.event.EventBuilder
import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory

// Due to MNG-1378, there is not a way to include test dependencies transitively.
// We cannot include Spark core tests as a dependency here because it depends on
// Spark core main, which has too many dependencies to require here manually.
// For this reason, we continue to use FunSuite and ignore the scalastyle checks
// that fail if this is detected.
//scalastyle:off
import org.scalatest.FunSuite

class SparkSinkSuite extends FunSuite {
//scalastyle:on

val eventsPerBatch = 1000
val channelCapacity = 5000

Expand Down
7 changes: 7 additions & 0 deletions scalastyle-config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,11 @@
</parameters>
</check>
<check level="error" class="org.scalastyle.scalariform.NotImplementedErrorUsage" enabled="true"></check>
<!-- As of SPARK-7558, all tests in Spark should extend o.a.s.SparkFunSuite instead of FunSuited directly -->
<check level="error" class="org.scalastyle.scalariform.TokenChecker" enabled="true">
<parameters>
<parameter name="regex">^FunSuite[A-Za-z]*$</parameter>
</parameters>
<customMessage>Tests must extend org.apache.spark.SparkFunSuite instead.</customMessage>
</check>
</scalastyle>

0 comments on commit 4b72668

Please sign in to comment.