Repository: spark
Updated Branches:
  refs/heads/branch-2.0 1e13d09c5 -> 306601282


[SPARK-15745][SQL] Use classloader's getResource() for reading resource files 
in HiveTests

## What changes were proposed in this pull request?

This is a cleaner approach in general but my motivation behind this change in 
particular is to be able to run these tests from anywhere without relying on 
system properties.

## How was this patch tested?

Test only change

Author: Sameer Agarwal <sam...@databricks.com>

Closes #13489 from sameeragarwal/resourcepath.

(cherry picked from commit f7288e166c696da15e790c28fc3ed78531fd362d)
Signed-off-by: Reynold Xin <r...@databricks.com>


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/30660128
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/30660128
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/30660128

Branch: refs/heads/branch-2.0
Commit: 306601282983d3efa04b274bdc72d29c056ccdb1
Parents: 1e13d09
Author: Sameer Agarwal <sam...@databricks.com>
Authored: Fri Jun 3 00:13:43 2016 -0700
Committer: Reynold Xin <r...@databricks.com>
Committed: Fri Jun 3 00:14:27 2016 -0700

----------------------------------------------------------------------
 .../org/apache/spark/sql/hive/test/TestHive.scala      | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/30660128/sql/hive/src/main/scala/org/apache/spark/sql/hive/test/TestHive.scala
----------------------------------------------------------------------
diff --git 
a/sql/hive/src/main/scala/org/apache/spark/sql/hive/test/TestHive.scala 
b/sql/hive/src/main/scala/org/apache/spark/sql/hive/test/TestHive.scala
index 81964db..1d1d5e3 100644
--- a/sql/hive/src/main/scala/org/apache/spark/sql/hive/test/TestHive.scala
+++ b/sql/hive/src/main/scala/org/apache/spark/sql/hive/test/TestHive.scala
@@ -179,19 +179,8 @@ private[hive] class TestHiveSparkSession(
   hiveFilesTemp.mkdir()
   ShutdownHookManager.registerShutdownDeleteDir(hiveFilesTemp)
 
-  val inRepoTests = if (System.getProperty("user.dir").endsWith("sql" + 
File.separator + "hive")) {
-    new File("src" + File.separator + "test" + File.separator + "resources" + 
File.separator)
-  } else {
-    new File("sql" + File.separator + "hive" + File.separator + "src" + 
File.separator + "test" +
-      File.separator + "resources")
-  }
-
   def getHiveFile(path: String): File = {
-    val stripped = path.replaceAll("""\.\.\/""", "").replace('/', 
File.separatorChar)
-    hiveDevHome
-      .map(new File(_, stripped))
-      .filter(_.exists)
-      .getOrElse(new File(inRepoTests, stripped))
+    new 
File(Thread.currentThread().getContextClassLoader.getResource(path).getFile)
   }
 
   val describedTable = "DESCRIBE (\\w+)".r


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to