Github actions crash on exception with testthat

Running github actions on Ubuntu. The following works when tested locally on Ubuntu and Windows, but crashes github actions without continuation. Note: Same error with testthat::expect_error.

test_that("expect_error works on gi actions", {
  a = try(stop("Hallo, welt", call. = FALSE))
  expect_s3_class(a, "try-error")
2022-03-13T09:11:03.3672781Z > library(testthat)
2022-03-13T09:11:03.3673367Z > #options(Ncpus = parallel::detectCores(logical = TRUE))
2022-03-13T09:11:03.3679743Z > options(Ncpus = 1)
2022-03-13T09:11:03.3680158Z > test_check("anomanor")
2022-03-13T09:11:03.3680591Z Loading required package: anomanor
2022-03-13T09:11:03.3718740Z ##[error]Error: R CMD check found ERRORs
2022-03-13T09:11:03.3731024Z Execution halted
2022-03-13T09:11:03.3768052Z Starting 1 test process
2022-03-13T09:11:03.3768377Z Error:
2022-03-13T09:11:03.3768852Z ! testthat subprocess exited in file `test_parse_markers2.R`
2022-03-13T09:11:03.3769595Z Caused by error:
2022-03-13T09:11:03.3770273Z ! R session crashed with exit code 2
2022-03-13T09:11:03.3770651Z Backtrace:
2022-03-13T09:11:03.3771110Z      ▆
2022-03-13T09:11:03.3771642Z   1. └─testthat::test_check("anomanor")
2022-03-13T09:11:03.3772406Z   2.   └─testthat::test_dir(...)
2022-03-13T09:11:03.3772960Z   3.     └─testthat:::test_files(...)
2022-03-13T09:11:03.3773672Z   4.       └─testthat:::test_files(...)
2022-03-13T09:11:03.3774198Z   5.         ├─testthat::with_reporter(...)
2022-03-13T09:11:03.3774748Z   6.         │ └─base::tryCatch(...)
2022-03-13T09:11:03.3775708Z   7.         │   └─base tryCatchList(expr, classes, parentenv, handlers)
2022-03-13T09:11:03.3776448Z   8.         │     └─base tryCatchOne(expr, names, parentenv, handlers[[1L]])
2022-03-13T09:11:03.3777114Z   9.         │       └─base doTryCatch(return(expr), name, parentenv, handler)
2022-03-13T09:11:03.3777855Z  10.         └─testthat:::parallel_event_loop_chunky(queue, reporters)
2022-03-13T09:11:03.3778434Z  11.           └─queue$poll(Inf)
2022-03-13T09:11:03.3778906Z  12.             └─base::lapply(...)
2022-03-13T09:11:03.3801002Z  13.               └─testthat FUN(X[[i]], ...)
2022-03-13T09:11:03.3801511Z  14.                 └─private$handle_error(msg, i)
2022-03-13T09:11:03.3802035Z  15.                   └─rlang::abort(...)
2022-03-13T09:11:03.3802332Z Execution halted

Can you please post a link to the package's code?

With two dozen earlier commits trying to locate the problem.
test_parse_markers2.R is the only currently active one. All tests work locally and on my remote Ubuntu.

Does it always crash? Does it crash if you turn of parallel tests?

Always crash: Yes. Never crashes locally (I did not even know that it can crash the system with no return)
Parallel tests: I set ncpus = 1, and made sure that only one test in the set is active, all others files are notest_xxxx.

There are about 24 commits with different versions in the history, always reproducible.

Even if you do that the one test will run in a subprocess. So try setting Config/testthat/parallel to false and see if it crashes.

Problem solved, with some take-home lessons which could be interesting for others:

  • There was an issue (=logical error) in my code: a test was if(invalid_channels), but should have been if(any(invalid_channels)).
  • I normally run R CMD check locally on Windows and on my Ubuntu Server. All 250 tests passed. On github actions, I got the incomprehensible crash which made me look at wrong places.
  • When I ran devtools check locally, there was a clear error message. After I corrected the above bug, everything was fine on github actions.
  • The error should have been detected in the tests, but I had forgotten that case.
  • The example I gave above with the error message was misleading, because the error was in my setup code, not in the test, so apologies to Gabor.
  • Running parallel true or false did not make any difference.

Thanks to Gabor for looking into this.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.