xkrogen commented on a change in pull request #32845:
URL: https://github.com/apache/spark/pull/32845#discussion_r650123330
##########
File path: core/src/test/scala/org/apache/spark/SparkContextSuite.scala
##########
@@ -1285,6 +1285,35 @@ class SparkContextSuite extends SparkFunSuite with
LocalSparkContext with Eventu
}
}
}
+
+ test("SPARK-35691: addFile/addJar/addDirectory should put CanonicalFile") {
+ withTempDir { dir =>
+ try {
+ sc = new SparkContext(new
SparkConf().setAppName("test").setMaster("local"))
+
+ val sep = File.separator
+ val tmpCanonicalDir = Utils.createTempDir(dir.getAbsolutePath + sep +
"test space")
+ val tmpAbsoluteDir = new File(tmpCanonicalDir.getAbsolutePath + sep +
'.' + sep)
+ val tmpJar = File.createTempFile("test", ".jar", tmpAbsoluteDir)
+ val tmpFile = File.createTempFile("test", ".txt", tmpAbsoluteDir)
+
+ assert(tmpJar.getAbsolutePath != tmpJar.getCanonicalPath)
+ assert(tmpFile.getAbsolutePath != tmpFile.getCanonicalPath)
+
+ sc.addJar(tmpJar.getAbsolutePath)
+ sc.addFile(tmpFile.getAbsolutePath)
+
+ assert(sc.listJars().size == 1)
+ assert(sc.listFiles().size == 1)
Review comment:
You can use the triple-equals here for Scalatest to give better error
messages:
```
assert(tmpJar.getAbsolutePath !== tmpJar.getCanonicalPath) // !==
instead of !=
assert(tmpFile.getAbsolutePath !== tmpFile.getCanonicalPath)
...
assert(sc.listJars().size === 1) // === instead of ==
assert(sc.listFiles().size === 1)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]