This is an automated email from the ASF dual-hosted git repository.

gurwls223 pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/branch-3.0 by this push:
     new b3a971a5 [SPARK-32647][INFRA] Report SparkR test results with JUnit 
reporter
b3a971a5 is described below

commit b3a971a5b88ed1811c693bcc05fd7f2b4ade7773
Author: HyukjinKwon <[email protected]>
AuthorDate: Tue Aug 18 19:35:15 2020 +0900

    [SPARK-32647][INFRA] Report SparkR test results with JUnit reporter
    
    This PR proposes to generate JUnit XML test report in SparkR tests that can 
be leveraged in both Jenkins and GitHub Actions.
    
    **GitHub Actions**
    
    ![Screen Shot 2020-08-18 at 12 42 46 
PM](https://user-images.githubusercontent.com/6477701/90467934-55b85b00-e150-11ea-863c-c8415e764ddb.png)
    
    **Jenkins**
    
    ![Screen Shot 2020-08-18 at 2 03 42 
PM](https://user-images.githubusercontent.com/6477701/90472509-a5505400-e15b-11ea-9165-777ec9b96eaa.png)
    
    NOTE that while I am here, I am switching back the console reporter from 
"progress" to "summary". Currently non-ascii codes are broken in Jenkins 
console and switching it to "summary" can work around it.
    "summary" is the default format used in testthat 1.x.
    
    To check the test failures more easily.
    
    No, dev-only
    
    It is tested in GitHub Actions at 
https://github.com/HyukjinKwon/spark/pull/23/checks?check_run_id=996586446
    In case of Jenkins, 
https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/127525/testReport/
    
    Closes #29456 from HyukjinKwon/sparkr-junit.
    
    Authored-by: HyukjinKwon <[email protected]>
    Signed-off-by: HyukjinKwon <[email protected]>
---
 R/pkg/tests/run-all.R | 9 ++++++---
 appveyor.yml          | 4 ++--
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/R/pkg/tests/run-all.R b/R/pkg/tests/run-all.R
index bf02ecd..20e61b2 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",
diff --git a/appveyor.yml b/appveyor.yml
index a4da5f9..e0d2396 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: R -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: R -e "install.packages(c('knitr', 'rmarkdown', 'testthat', 'e1071', 
'survival', 'arrow', 'xml2'), repos='https://cloud.r-project.org/')"
   - cmd: R -e "packageVersion('knitr'); packageVersion('rmarkdown'); 
packageVersion('testthat'); packageVersion('e1071'); 
packageVersion('survival'); packageVersion('arrow')"
 
 build_script:


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to