From 3a5e0ab86c31e6863c8ddcc9418d8356b880e76e Mon Sep 17 00:00:00 2001 From: Yu ISHIKAWA Date: Tue, 21 Jul 2015 16:28:12 +0900 Subject: [PATCH 1/4] [SPARK-9121][SparkR] Get rid of the warnings about `no visible global function definition` in SparkR --- R/pkg/inst/tests/test_sparkSQL.R | 8 ++++---- dev/lint-r.R | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/R/pkg/inst/tests/test_sparkSQL.R b/R/pkg/inst/tests/test_sparkSQL.R index a3039d36c9402..202190389e613 100644 --- a/R/pkg/inst/tests/test_sparkSQL.R +++ b/R/pkg/inst/tests/test_sparkSQL.R @@ -21,10 +21,10 @@ context("SparkSQL functions") # Utility function for easily checking the values of a StructField checkStructField <- function(actual, expectedName, expectedType, expectedNullable) { - expect_equal(class(actual), "structField") - expect_equal(actual$name(), expectedName) - expect_equal(actual$dataType.toString(), expectedType) - expect_equal(actual$nullable(), expectedNullable) + testthat::expect_equal(class(actual), "structField") + testthat::expect_equal(actual$name(), expectedName) + testthat::expect_equal(actual$dataType.toString(), expectedType) + testthat::expect_equal(actual$nullable(), expectedNullable) } # Tests for SparkSQL functions in SparkR diff --git a/dev/lint-r.R b/dev/lint-r.R index dcb1a184291e1..85cfd0bf55997 100644 --- a/dev/lint-r.R +++ b/dev/lint-r.R @@ -25,5 +25,6 @@ library(lintr) argv <- commandArgs(TRUE) SPARK_ROOT_DIR <- as.character(argv[1]) +library(SparkR, lib.loc = file.path(SPARK_ROOT_DIR, "R", "lib")) path.to.package <- file.path(SPARK_ROOT_DIR, "R", "pkg") lint_package(path.to.package, cache = FALSE) From 1a0398735a113869d75bbce2d864d109ff7f0920 Mon Sep 17 00:00:00 2001 From: Yu ISHIKAWA Date: Wed, 22 Jul 2015 08:43:29 +0900 Subject: [PATCH 2/4] Load the `testthat` package in `dev/lint-r.R`, instead of using the full path of function. --- R/pkg/inst/tests/test_sparkSQL.R | 8 ++++---- dev/lint-r.R | 10 ++++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/R/pkg/inst/tests/test_sparkSQL.R b/R/pkg/inst/tests/test_sparkSQL.R index 202190389e613..a3039d36c9402 100644 --- a/R/pkg/inst/tests/test_sparkSQL.R +++ b/R/pkg/inst/tests/test_sparkSQL.R @@ -21,10 +21,10 @@ context("SparkSQL functions") # Utility function for easily checking the values of a StructField checkStructField <- function(actual, expectedName, expectedType, expectedNullable) { - testthat::expect_equal(class(actual), "structField") - testthat::expect_equal(actual$name(), expectedName) - testthat::expect_equal(actual$dataType.toString(), expectedType) - testthat::expect_equal(actual$nullable(), expectedNullable) + expect_equal(class(actual), "structField") + expect_equal(actual$name(), expectedName) + expect_equal(actual$dataType.toString(), expectedType) + expect_equal(actual$nullable(), expectedNullable) } # Tests for SparkSQL functions in SparkR diff --git a/dev/lint-r.R b/dev/lint-r.R index 85cfd0bf55997..9b6352debbb53 100644 --- a/dev/lint-r.R +++ b/dev/lint-r.R @@ -15,16 +15,18 @@ # limitations under the License. # +argv <- commandArgs(TRUE) +SPARK_ROOT_DIR <- as.character(argv[1]) + # Installs lintr from Github. # NOTE: The CRAN's version is too old to adapt to our rules. if ("lintr" %in% row.names(installed.packages()) == FALSE) { devtools::install_github("jimhester/lintr") } -library(lintr) - -argv <- commandArgs(TRUE) -SPARK_ROOT_DIR <- as.character(argv[1]) +# NOTE: You should install SparkR with `R/install-dev.sh` before running this script. +library(lintr) +library(testthat) library(SparkR, lib.loc = file.path(SPARK_ROOT_DIR, "R", "lib")) path.to.package <- file.path(SPARK_ROOT_DIR, "R", "pkg") lint_package(path.to.package, cache = FALSE) From b1f19ed7e9b9918ca04cb584e16aa5369e550ff3 Mon Sep 17 00:00:00 2001 From: Yu ISHIKAWA Date: Wed, 22 Jul 2015 10:00:30 +0900 Subject: [PATCH 3/4] Add a validate statement for local SparkR --- dev/lint-r.R | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dev/lint-r.R b/dev/lint-r.R index 9b6352debbb53..6060a5679e1db 100644 --- a/dev/lint-r.R +++ b/dev/lint-r.R @@ -24,9 +24,12 @@ if ("lintr" %in% row.names(installed.packages()) == FALSE) { devtools::install_github("jimhester/lintr") } -# NOTE: You should install SparkR with `R/install-dev.sh` before running this script. library(lintr) +library(methods) library(testthat) -library(SparkR, lib.loc = file.path(SPARK_ROOT_DIR, "R", "lib")) +if (! library(SparkR, lib.loc = file.path(SPARK_ROOT_DIR, "R", "lib"), logical.return = TRUE)) { + stop("You should install SparkR in a local directory with `R/instlal-dev.sh`.") +} + path.to.package <- file.path(SPARK_ROOT_DIR, "R", "pkg") lint_package(path.to.package, cache = FALSE) From c8cfd63cdca66a9429565e9546a1d4f05a913c60 Mon Sep 17 00:00:00 2001 From: Yu ISHIKAWA Date: Wed, 22 Jul 2015 10:39:03 +0900 Subject: [PATCH 4/4] Fix the typo --- dev/lint-r.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/lint-r.R b/dev/lint-r.R index 6060a5679e1db..48bd6246096ae 100644 --- a/dev/lint-r.R +++ b/dev/lint-r.R @@ -28,7 +28,7 @@ library(lintr) library(methods) library(testthat) if (! library(SparkR, lib.loc = file.path(SPARK_ROOT_DIR, "R", "lib"), logical.return = TRUE)) { - stop("You should install SparkR in a local directory with `R/instlal-dev.sh`.") + stop("You should install SparkR in a local directory with `R/install-dev.sh`.") } path.to.package <- file.path(SPARK_ROOT_DIR, "R", "pkg")