Skip to content

Commit 609c492

Browse files
Andrew Orrxin
authored andcommitted
[SPARK-7558] Guard against direct uses of FunSuite / FunSuiteLike
This is a follow-up patch to #6441. Author: Andrew Or <[email protected]> Closes #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
1 parent 7ed06c3 commit 609c492

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

core/src/test/scala/org/apache/spark/SparkFunSuite.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@
1717

1818
package org.apache.spark
1919

20+
// scalastyle:off
2021
import org.scalatest.{FunSuite, Outcome}
2122

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

2729
/**
2830
* Log the suite name and the test name before and after each test.

external/flume-sink/src/test/scala/org/apache/spark/streaming/flume/sink/SparkSinkSuite.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,18 @@ import org.apache.flume.Context
3131
import org.apache.flume.channel.MemoryChannel
3232
import org.apache.flume.event.EventBuilder
3333
import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory
34+
35+
// Due to MNG-1378, there is not a way to include test dependencies transitively.
36+
// We cannot include Spark core tests as a dependency here because it depends on
37+
// Spark core main, which has too many dependencies to require here manually.
38+
// For this reason, we continue to use FunSuite and ignore the scalastyle checks
39+
// that fail if this is detected.
40+
//scalastyle:off
3441
import org.scalatest.FunSuite
3542

3643
class SparkSinkSuite extends FunSuite {
44+
//scalastyle:on
45+
3746
val eventsPerBatch = 1000
3847
val channelCapacity = 5000
3948

scalastyle-config.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,11 @@
153153
</parameters>
154154
</check>
155155
<check level="error" class="org.scalastyle.scalariform.NotImplementedErrorUsage" enabled="true"></check>
156+
<!-- As of SPARK-7558, all tests in Spark should extend o.a.s.SparkFunSuite instead of FunSuited directly -->
157+
<check level="error" class="org.scalastyle.scalariform.TokenChecker" enabled="true">
158+
<parameters>
159+
<parameter name="regex">^FunSuite[A-Za-z]*$</parameter>
160+
</parameters>
161+
<customMessage>Tests must extend org.apache.spark.SparkFunSuite instead.</customMessage>
162+
</check>
156163
</scalastyle>

0 commit comments

Comments
 (0)