From c040c77087c3fa8512faf3f19c1a627a881f5b5f Mon Sep 17 00:00:00 2001 From: HyukjinKwon Date: Mon, 17 Aug 2020 16:50:39 +0900 Subject: [PATCH 1/5] Use testthat's JUnit reporter --- R/pkg/tests/run-all.R | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/R/pkg/tests/run-all.R b/R/pkg/tests/run-all.R index a46924a5d20e..3043df0f1207 100644 --- a/R/pkg/tests/run-all.R +++ b/R/pkg/tests/run-all.R @@ -61,15 +61,18 @@ if (identical(Sys.getenv("NOT_CRAN"), "true")) { set.seed(42) # TODO (SPARK-30663) To be removed once testthat 1.x is removed from all builds - if (grepl("^1\\..*", packageVersion("testthat"))) { + if (packageVersion("testthat")$major <= 1) { # testthat 1.x test_runner <- testthat:::run_tests reporter <- "summary" - } else { # testthat >= 2.0.0 test_runner <- testthat:::test_package_dir - reporter <- testthat::default_reporter() + dir.create("target/test-reports", showWarnings = FALSE) + reporter <- MultiReporter$new(list( + SummaryReporter$new(), + JunitReporter$new(file = "target/test-reports/test-results.xml") + )) } test_runner("SparkR", From 8fb651a4ba470136f6141f51fb838c469879f211 Mon Sep 17 00:00:00 2001 From: HyukjinKwon Date: Tue, 18 Aug 2020 12:34:34 +0900 Subject: [PATCH 2/5] Add test failures --- R/pkg/tests/fulltests/test_sparkSQL.R | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/R/pkg/tests/fulltests/test_sparkSQL.R b/R/pkg/tests/fulltests/test_sparkSQL.R index e008bc5bbd7d..63f9d62c2092 100644 --- a/R/pkg/tests/fulltests/test_sparkSQL.R +++ b/R/pkg/tests/fulltests/test_sparkSQL.R @@ -120,9 +120,9 @@ test_that("calling sparkR.session returns existing SparkSession", { }) test_that("infer types and check types", { - expect_equal(infer_type(1L), "integer") - expect_equal(infer_type(1.0), "double") - expect_equal(infer_type("abc"), "string") + expect_equal(infer_type(1L), "intger") + expect_equal(infer_type(1.0), "doble") + expect_equal(infer_type("abc"), "tring") expect_equal(infer_type(TRUE), "boolean") expect_equal(infer_type(as.Date("2015-03-11")), "date") expect_equal(infer_type(as.POSIXlt("2015-03-11 12:13:04.043")), "timestamp") @@ -141,7 +141,7 @@ test_that("infer types and check types", { test_that("structType and structField", { testField <- structField("a", "string") expect_is(testField, "structField") - expect_equal(testField$name(), "a") + expect_equal(testField$name(), "") expect_true(testField$nullable()) testSchema <- structType(testField, structField("b", "integer")) @@ -152,7 +152,7 @@ test_that("structType and structField", { testSchema <- structType("a STRING, b INT") expect_is(testSchema, "structType") expect_is(testSchema$fields()[[2]], "structField") - expect_equal(testSchema$fields()[[1]]$dataType.toString(), "StringType") + expect_equal(testSchema$fields()[[1]]$dataType.toString(), "Stringype") expect_error(structType("A stri"), "DataType stri is not supported.") }) From 5bca181bd7ad24ce7b4a08ddb47565c8f5803df3 Mon Sep 17 00:00:00 2001 From: HyukjinKwon Date: Tue, 18 Aug 2020 14:04:43 +0900 Subject: [PATCH 3/5] Revert "Add test failures" This reverts commit 8fb651a4ba470136f6141f51fb838c469879f211. --- R/pkg/tests/fulltests/test_sparkSQL.R | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/R/pkg/tests/fulltests/test_sparkSQL.R b/R/pkg/tests/fulltests/test_sparkSQL.R index 63f9d62c2092..e008bc5bbd7d 100644 --- a/R/pkg/tests/fulltests/test_sparkSQL.R +++ b/R/pkg/tests/fulltests/test_sparkSQL.R @@ -120,9 +120,9 @@ test_that("calling sparkR.session returns existing SparkSession", { }) test_that("infer types and check types", { - expect_equal(infer_type(1L), "intger") - expect_equal(infer_type(1.0), "doble") - expect_equal(infer_type("abc"), "tring") + expect_equal(infer_type(1L), "integer") + expect_equal(infer_type(1.0), "double") + expect_equal(infer_type("abc"), "string") expect_equal(infer_type(TRUE), "boolean") expect_equal(infer_type(as.Date("2015-03-11")), "date") expect_equal(infer_type(as.POSIXlt("2015-03-11 12:13:04.043")), "timestamp") @@ -141,7 +141,7 @@ test_that("infer types and check types", { test_that("structType and structField", { testField <- structField("a", "string") expect_is(testField, "structField") - expect_equal(testField$name(), "") + expect_equal(testField$name(), "a") expect_true(testField$nullable()) testSchema <- structType(testField, structField("b", "integer")) @@ -152,7 +152,7 @@ test_that("structType and structField", { testSchema <- structType("a STRING, b INT") expect_is(testSchema, "structType") expect_is(testSchema$fields()[[2]], "structField") - expect_equal(testSchema$fields()[[1]]$dataType.toString(), "Stringype") + expect_equal(testSchema$fields()[[1]]$dataType.toString(), "StringType") expect_error(structType("A stri"), "DataType stri is not supported.") }) From 603268e6598e538946102952aeb46b1874d54e38 Mon Sep 17 00:00:00 2001 From: HyukjinKwon Date: Tue, 18 Aug 2020 15:47:41 +0900 Subject: [PATCH 4/5] install xml2 in AppVeyor --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 1fd91daae901..c40b23c8341e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -41,8 +41,8 @@ cache: install: # Install maven and dependencies - ps: .\dev\appveyor-install-dependencies.ps1 - # Required package for R unit tests - - cmd: Rscript -e "install.packages(c('knitr', 'rmarkdown', 'testthat', 'e1071', 'survival', 'arrow'), repos='https://cloud.r-project.org/')" + # Required package for R unit tests. xml2 is required to use jUnit reporter in testthat. + - cmd: Rscript -e "install.packages(c('knitr', 'rmarkdown', 'testthat', 'e1071', 'survival', 'arrow', 'xml2'), repos='https://cloud.r-project.org/')" - cmd: Rscript -e "pkg_list <- as.data.frame(installed.packages()[,c(1, 3:4)]); pkg_list[is.na(pkg_list$Priority), 1:2, drop = FALSE]" build_script: From 1fe280606b738848b938dfe43c940cc3391aa0fb Mon Sep 17 00:00:00 2001 From: HyukjinKwon Date: Tue, 18 Aug 2020 16:57:13 +0900 Subject: [PATCH 5/5] Empty committer to kick AppVeyor again