@@ -169,6 +169,7 @@ test_that("spark.lapply should perform simple transforms", {
169169
170170test_that(" add and get file to be downloaded with Spark job on every node" , {
171171 sparkR.sparkContext()
172+ # Test add file.
172173 path <- tempfile(pattern = " hello" , fileext = " .txt" )
173174 filename <- basename(path )
174175 words <- " Hello World!"
@@ -177,5 +178,25 @@ test_that("add and get file to be downloaded with Spark job on every node", {
177178 download_path <- spark.getSparkFiles(filename )
178179 expect_equal(readLines(download_path ), words )
179180 unlink(path )
181+
182+ # Test add directory recursively.
183+ path <- tempdir()
184+ dir_name <- basename(path )
185+ path1 <- paste0(path , " /hello.txt" )
186+ file.create(path1 )
187+ sub_path <- paste0(path , " /sub_hello" )
188+ dir.create(sub_path )
189+ path2 <- paste0(sub_path , " /sub_hello.txt" )
190+ file.create(path2 )
191+ words <- " Hello World!"
192+ sub_words <- " Sub Hello World!"
193+ writeLines(words , path1 )
194+ writeLines(sub_words , path2 )
195+ spark.addFile(path , recursive = TRUE )
196+ download_path1 = spark.getSparkFiles(paste0(dir_name , " /hello.txt" ))
197+ expect_equal(readLines(download_path1 ), words )
198+ download_path2 = spark.getSparkFiles(paste0(dir_name , " /sub_hello/sub_hello.txt" ))
199+ expect_equal(readLines(download_path2 ), sub_words )
200+ unlink(path , recursive = TRUE )
180201 sparkR.session.stop()
181202})
0 commit comments