From 7e1705c8091b50adb61c23cf00a756293c23e26f Mon Sep 17 00:00:00 2001 From: felixcheung Date: Sun, 6 Dec 2015 20:52:02 -0800 Subject: [PATCH 1/2] add test --- R/pkg/inst/tests/testthat/test_context.R | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/R/pkg/inst/tests/testthat/test_context.R b/R/pkg/inst/tests/testthat/test_context.R index 1707e314beff5..92dbd575c20ab 100644 --- a/R/pkg/inst/tests/testthat/test_context.R +++ b/R/pkg/inst/tests/testthat/test_context.R @@ -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() From fa4869d27b106a209ce515202c52d611922f63ab Mon Sep 17 00:00:00 2001 From: felixcheung Date: Tue, 15 Dec 2015 22:04:45 -0800 Subject: [PATCH 2/2] sort exported func name --- R/pkg/NAMESPACE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/pkg/NAMESPACE b/R/pkg/NAMESPACE index ccc01fe169601..425675faa955e 100644 --- a/R/pkg/NAMESPACE +++ b/R/pkg/NAMESPACE @@ -269,10 +269,10 @@ export("as.DataFrame", "createExternalTable", "dropTempTable", "jsonFile", - "read.json", "loadDF", "parquetFile", "read.df", + "read.json", "read.parquet", "sql", "table",