@@ -31,6 +31,7 @@ import org.apache.hadoop.hive.serde2.`lazy`.LazySimpleSerDe
31
31
import org .apache .hadoop .hive .serde2 .avro .AvroSerDe
32
32
33
33
import org .apache .spark .{SparkConf , SparkContext }
34
+ import org .apache .spark .util .Utils
34
35
import org .apache .spark .sql .catalyst .analysis ._
35
36
import org .apache .spark .sql .catalyst .plans .logical .{CacheTableCommand , LogicalPlan , NativeCommand }
36
37
import org .apache .spark .sql .catalyst .util ._
@@ -71,11 +72,14 @@ class TestHiveContext(sc: SparkContext) extends HiveContext(sc) {
71
72
setConf(" javax.jdo.option.ConnectionURL" ,
72
73
s " jdbc:derby:;databaseName= $metastorePath;create=true " )
73
74
setConf(" hive.metastore.warehouse.dir" , warehousePath)
75
+ Utils .registerShutdownDeleteDir(new File (warehousePath))
76
+ Utils .registerShutdownDeleteDir(new File (metastorePath))
74
77
}
75
78
76
79
val testTempDir = File .createTempFile(" testTempFiles" , " spark.hive.tmp" )
77
80
testTempDir.delete()
78
81
testTempDir.mkdir()
82
+ Utils .registerShutdownDeleteDir(testTempDir)
79
83
80
84
// For some hive test case which contain ${system:test.tmp.dir}
81
85
System .setProperty(" test.tmp.dir" , testTempDir.getCanonicalPath)
@@ -121,8 +125,7 @@ class TestHiveContext(sc: SparkContext) extends HiveContext(sc) {
121
125
val hiveFilesTemp = File .createTempFile(" catalystHiveFiles" , " " )
122
126
hiveFilesTemp.delete()
123
127
hiveFilesTemp.mkdir()
124
- hiveFilesTemp.deleteOnExit()
125
-
128
+ Utils .registerShutdownDeleteDir(hiveFilesTemp)
126
129
127
130
val inRepoTests = if (System .getProperty(" user.dir" ).endsWith(" sql" + File .separator + " hive" )) {
128
131
new File (" src" + File .separator + " test" + File .separator + " resources" + File .separator)
0 commit comments