You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by sh...@apache.org on 2016/01/20 01:33:51 UTC
spark git commit: [SPARK-12168][SPARKR] Add automated tests for
conflicted function in R
Repository: spark
Updated Branches:
refs/heads/master 3e84ef0a5 -> 37fefa66c
[SPARK-12168][SPARKR] Add automated tests for conflicted function in R
Currently this is reported when loading the SparkR package in R (probably would add is.nan)
```
Loading required package: methods
Attaching package: ‘SparkR’
The following objects are masked from ‘package:stats’:
cov, filter, lag, na.omit, predict, sd, var
The following objects are masked from ‘package:base’:
colnames, colnames<-, intersect, rank, rbind, sample, subset,
summary, table, transform
```
Adding this test adds an automated way to track changes to masked method.
Also, the second part of this test check for those functions that would not be accessible without namespace/package prefix.
Incidentally, this might point to how we would fix those inaccessible functions in base or stats.
Looking for feedback for adding this test.
Author: felixcheung <fe...@hotmail.com>
Closes #10171 from felixcheung/rmaskedtest.
Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/37fefa66
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/37fefa66
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/37fefa66
Branch: refs/heads/master
Commit: 37fefa66cbd61bc592aba42b0ed3aefc0cf3abb0
Parents: 3e84ef0
Author: felixcheung <fe...@hotmail.com>
Authored: Tue Jan 19 16:33:48 2016 -0800
Committer: Shivaram Venkataraman <sh...@cs.berkeley.edu>
Committed: Tue Jan 19 16:33:48 2016 -0800
----------------------------------------------------------------------
R/pkg/NAMESPACE | 2 +-
R/pkg/inst/tests/testthat/test_context.R | 23 +++++++++++++++++++++++
2 files changed, 24 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/spark/blob/37fefa66/R/pkg/NAMESPACE
----------------------------------------------------------------------
diff --git a/R/pkg/NAMESPACE b/R/pkg/NAMESPACE
index 34d1437..27d2f98 100644
--- a/R/pkg/NAMESPACE
+++ b/R/pkg/NAMESPACE
@@ -271,10 +271,10 @@ export("as.DataFrame",
"createExternalTable",
"dropTempTable",
"jsonFile",
- "read.json",
"loadDF",
"parquetFile",
"read.df",
+ "read.json",
"read.parquet",
"read.text",
"sql",
http://git-wip-us.apache.org/repos/asf/spark/blob/37fefa66/R/pkg/inst/tests/testthat/test_context.R
----------------------------------------------------------------------
diff --git a/R/pkg/inst/tests/testthat/test_context.R b/R/pkg/inst/tests/testthat/test_context.R
index 1707e31..92dbd57 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()
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org