Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ import org.apache.spark.sql.types.StructType
* SPARK_GENERATE_GOLDEN_FILES=1 build/sbt "sql/test-only *SQLQueryTestSuite"
* }}}
*
* For selective tests, run:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not directly using something like

build/sbt "~sql/test-only *SQLQueryTestSuite -- -z inline-table.sql -z random.sql"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, I didn't know sbt can do. I usually use maven and it seems maven cannot do that. Anyway, it's okay to use `sbt for this case. Thanks!

* {{{
* SPARK_SQL_QUERY_TEST_FILTER=limit.sql,random.sql build/sbt "sql/test-only *SQLQueryTestSuite"
* }}}
*
* The format for input files is simple:
* 1. A list of SQL queries separated by semicolon.
* 2. Lines starting with -- are treated as comments and ignored.
Expand Down Expand Up @@ -83,6 +88,15 @@ class SQLQueryTestSuite extends QueryTest with SharedSQLContext {

private val regenerateGoldenFiles: Boolean = System.getenv("SPARK_GENERATE_GOLDEN_FILES") == "1"

private val testFilter: Option[Set[String]] = {
val testFilter = System.getenv("SPARK_SQL_QUERY_TEST_FILTER")
if (testFilter != null && !testFilter.isEmpty) {
Some(testFilter.toLowerCase(Locale.ROOT).split(",").map(_.trim).toSet)
} else {
None
}
}

private val baseResourcePath = {
// If regenerateGoldenFiles is true, we must be running this in SBT and we use hard-coded
// relative path. Otherwise, we use classloader's getResource to find the location.
Expand Down Expand Up @@ -124,13 +138,18 @@ class SQLQueryTestSuite extends QueryTest with SharedSQLContext {
}

private def createScalaTestCase(testCase: TestCase): Unit = {
if (blackList.exists(t =>
testCase.name.toLowerCase(Locale.ROOT).contains(t.toLowerCase(Locale.ROOT)))) {
val testName = testCase.name.toLowerCase(Locale.ROOT)
if (blackList.exists(t => testName.contains(t.toLowerCase(Locale.ROOT)))) {
// Create a test case to ignore this case.
ignore(testCase.name) { /* Do nothing */ }
} else {
// Create a test case to run this case.
test(testCase.name) { runTest(testCase) }
testFilter match {
case Some(filter) if !filter.exists { _.contains(testName) } =>
ignore(testCase.name) { /* Do nothing */ }
case _ =>
// Create a test case to run this case.
test(testCase.name) { runTest(testCase) }
}
}
}

Expand Down