Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-12168][SPARKR] Add automated tests for conflicted function in R #10171

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion R/pkg/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,10 @@ export("as.DataFrame",
"createExternalTable",
"dropTempTable",
"jsonFile",
"read.json",
"loadDF",
"parquetFile",
"read.df",
"read.json",
"read.parquet",
"sql",
"table",
Expand Down
23 changes: 23 additions & 0 deletions R/pkg/inst/tests/testthat/test_context.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,29 @@

context("test functions in sparkR.R")

test_that("Check masked functions", {
# Check that we are not masking any new function from base, stats, testthat unexpectedly
masked <- conflicts(detail = TRUE)$`package:SparkR`
expect_true("describe" %in% masked) # only when with testthat..
func <- lapply(masked, function(x) { capture.output(showMethods(x))[[1]] })
funcSparkROrEmpty <- grepl("\\(package SparkR\\)$|^$", func)
maskedBySparkR <- masked[funcSparkROrEmpty]
expect_equal(length(maskedBySparkR), 18)
expect_equal(sort(maskedBySparkR), sort(c("describe", "cov", "filter", "lag", "na.omit",
"predict", "sd", "var", "colnames", "colnames<-",
"intersect", "rank", "rbind", "sample", "subset",
"summary", "table", "transform")))
# above are those reported as masked when `library(SparkR)`
# note that many of these methods are still callable without base:: or stats:: prefix
# there should be a test for each of these, except followings, which are currently "broken"
funcHasAny <- unlist(lapply(masked, function(x) {
any(grepl("=\"ANY\"", capture.output(showMethods(x)[-1])))
}))
maskedCompletely <- masked[!funcHasAny]
expect_equal(length(maskedCompletely), 4)
expect_equal(sort(maskedCompletely), sort(c("cov", "filter", "sample", "table")))
})

test_that("repeatedly starting and stopping SparkR", {
for (i in 1:4) {
sc <- sparkR.init()
Expand Down