Running ‘testthat.R’ [454s/589s]
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
  > library(testthat)
  > library(DrugExposureDiagnostics)
  > 
  > test_check("DrugExposureDiagnostics")
  
  Attaching package: 'plotly'
  
  The following object is masked from 'package:ggplot2':
  
      last_plot
  
  The following object is masked from 'package:stats':
  
      filter
  
  The following object is masked from 'package:graphics':
  
      layout
  
  
  Attaching package: 'dplyr'
  
  The following object is masked from 'package:testthat':
  
      matches
  
  The following objects are masked from 'package:stats':
  
      filter, lag
  
  The following objects are masked from 'package:base':
  
      intersect, setdiff, setequal, union
  
  population after earliestStartDate smaller than sample, sampling ignored
  i The following estimates will be computed:
  * daily_dose: count_missing, percentage_missing, mean, sd, q05, q25, median, q75, q95, min, max
  ! Table is collected to memory as not all requested estimates are supported on the database side
  > Start summary of data, at 2025-04-12 02:15:52.663292
  v Summary finished, at 2025-04-12 02:15:54.545645
  population after earliestStartDate smaller than sample, sampling ignored
  population after earliestStartDate smaller than sample, sampling ignored
  i The following estimates will be computed:
  * daily_dose: count_missing, percentage_missing, mean, sd, q05, q25, median, q75, q95, min, max
  ! Table is collected to memory as not all requested estimates are supported on the database side
  > Start summary of data, at 2025-04-12 02:16:54.45439
  ===============>--------------- 2/4 group-strata combinations @ 2025-04-12 02...
  ==============================> 4/4 group-strata combinations @ 2025-04-12 02...
  v Summary finished, at 2025-04-12 02:16:56.735484
  population after earliestStartDate smaller than sample, sampling ignored
  i The following estimates will be computed:
  * daily_dose: count_missing, percentage_missing, mean, sd, q05, q25, median, q75, q95, min, max
  ! Table is collected to memory as not all requested estimates are supported on the database side
  > Start summary of data, at 2025-04-12 02:17:39.984514
  ===============>--------------- 2/4 group-strata combinations @ 2025-04-12 02...
  ==============================> 4/4 group-strata combinations @ 2025-04-12 02...
  v Summary finished, at 2025-04-12 02:17:42.083955
  i The following estimates will be computed:
  * daily_dose: count_missing, percentage_missing, mean, sd, q05, q25, median, q75, q95, min, max
  ! Table is collected to memory as not all requested estimates are supported on the database side
  > Start summary of data, at 2025-04-12 02:17:48.355108
  v Summary finished, at 2025-04-12 02:17:50.653531
  Progress: getting descendant concepts of ingredient (1125315) used in database
  Progress: getting descendant concepts of ingredient
  Progress: adding drug strength info
  Progress: limiting to concepts in the db
  Progress: adding concept names
  Overall time taken: 0 minutes and 3 seconds
  Time taken: 0 minutes and 4 seconds
  Progress: getting drug records for ingredient
  Time taken: 0 minutes and 0 seconds
  Progress: get concepts used
  Time taken: 0 minutes and 0 seconds
  Progress: sampling drug records
  population after earliestStartDate smaller than sample, sampling ignored
  Time taken: 0 minutes and 0 seconds
  Progress: check drugsMissing
  Time taken: 0 minutes and 5 seconds
  Progress: check ExposureDuration
  Time taken: 0 minutes and 0 seconds
  Progress: check drugQuantity
  Time taken: 0 minutes and 0 seconds
  Finished
  i The following estimates will be computed:
  * daily_dose: count_missing, percentage_missing, mean, sd, q05, q25, median, q75, q95, min, max
  ! Table is collected to memory as not all requested estimates are supported on the database side
  > Start summary of data, at 2025-04-12 02:19:32.326187
  ===============>--------------- 2/4 group-strata combinations @ 2025-04-12 02...
  ==============================> 4/4 group-strata combinations @ 2025-04-12 02...
  v Summary finished, at 2025-04-12 02:19:35.43372
  population after earliestStartDate smaller than sample, sampling ignored
  population after earliestStartDate smaller than sample, sampling ignored
  population after earliestStartDate smaller than sample, sampling ignored
  population after earliestStartDate smaller than sample, sampling ignored
  population after earliestStartDate smaller than sample, sampling ignored
  i The following estimates will be computed:
  * daily_dose: count_missing, percentage_missing, mean, sd, q05, q25, median, q75, q95, min, max
  ! Table is collected to memory as not all requested estimates are supported on the database side
  > Start summary of data, at 2025-04-12 02:22:26.595744
  v Summary finished, at 2025-04-12 02:22:28.390637
  population after earliestStartDate smaller than sample, sampling ignored
  population after earliestStartDate smaller than sample, sampling ignored
  population after earliestStartDate smaller than sample, sampling ignored
  population after earliestStartDate smaller than sample, sampling ignored
  
   *** caught segfault ***
  address (nil), cause 'unknown'
  
  Traceback:
   1: rapi_execute(stmt, arrow, integer64)
   2: withCallingHandlers(expr, condition = function(cnd) {    {        .__handler_frame__. <- TRUE        .__setup_frame__. <- frame        if (inherits(cnd, "message")) {            except <- c("warning", "error")        }        else if (inherits(cnd, "warning")) {            except <- "error"        }        else {            except <- ""        }    }    while (!is_null(cnd)) {        if (inherits(cnd, "error")) {            out <- handlers[[1L]](cnd)            if (!inherits(out, "rlang_zap"))                 throw(out)        }        inherit <- .subset2(.subset2(cnd, "rlang"), "inherit")        if (is_false(inherit)) {            return()        }        cnd <- .subset2(cnd, "parent")    }})
   3: doTryCatch(return(expr), name, parentenv, handler)
   4: tryCatchOne(expr, names, parentenv, handlers[[1L]])
   5: tryCatchList(expr, classes, parentenv, handlers)
   6: tryCatch(withCallingHandlers(expr, condition = function(cnd) {    {        .__handler_frame__. <- TRUE        .__setup_frame__. <- frame        if (inherits(cnd, "message")) {            except <- c("warning", "error")        }        else if (inherits(cnd, "warning")) {            except <- "error"        }        else {            except <- ""        }    }    while (!is_null(cnd)) {        if (inherits(cnd, "error")) {            out <- handlers[[1L]](cnd)            if (!inherits(out, "rlang_zap"))                 throw(out)        }        inherit <- .subset2(.subset2(cnd, "rlang"), "inherit")        if (is_false(inherit)) {            return()        }        cnd <- .subset2(cnd, "parent")    }}), stackOverflowError = handlers[[1L]])
   7: rlang::try_fetch(rapi_execute(stmt, arrow, integer64), error = function(e) {    rethrow_error_from_rapi(e, call)})
   8: rethrow_rapi_execute(res@stmt_lst$ref, res@arrow, res@connection@bigint ==     "integer64")
   9: duckdb_execute(res)
  10: duckdb_result(connection = conn, stmt_lst = stmt_lst, arrow = arrow)
  11: .local(conn, statement, ...)
  12: dbSendQuery(conn, statement, ...)
  13: dbSendQuery(conn, statement, ...)
  14: dbSendStatement(conn, statement, ...)
  15: dbSendStatement(conn, statement, ...)
  16: dbExecute(con, sql, immediate = TRUE)
  17: dbExecute(con, sql, immediate = TRUE)
  18: withCallingHandlers(code, error = function(cnd) {    msg <- c(msg, i = paste0("Using SQL: ", sql))    cli_abort(msg, parent = cnd, call = call, .envir = env)})
  19: dbi_wrap(dbExecute(con, sql, immediate = TRUE), sql = sql, msg = msg,     call = call, env = env)
  20: db_execute(con, sql, "Can't save query to table {.table {format(name, con = con)}}.")
  21: db_save_query.DBIConnection(con, ...)
  22: eval_bare(expr((!!fun)(con, ...)))
  23: dbplyr_fallback(con, "db_save_query", ...)
  24: dbplyr_save_query(con, sql, table, ..., temporary = temporary,     overwrite = overwrite)
  25: withCallingHandlers(code, error = function(cnd) {    cli_abort(msg, parent = cnd, call = call, .envir = env)})
  26: with_transaction(con, in_transaction, "Can't copy query to table {.field {format(table, con = con)}}.",     {        table <- dbplyr_save_query(con, sql, table, ..., temporary = temporary,             overwrite = overwrite)        create_indexes(con, table, unique_indexes, unique = TRUE)        create_indexes(con, table, indexes)        if (analyze)             dbplyr_analyze(con, table)    })
  27: db_compute.DBIConnection(x$src$con, name, sql, temporary = temporary,     unique_indexes = unique_indexes, indexes = indexes, analyze = analyze,     ...)
  28: db_compute(x$src$con, name, sql, temporary = temporary, unique_indexes = unique_indexes,     indexes = indexes, analyze = analyze, ...)
  29: compute.tbl_sql(x, name = name, temporary = temporary, ...)
  30: dplyr::compute(x, name = name, temporary = temporary, ...)
  31: .computeQuery(x, name = name, temporary = temporary, schema = schema,     overwrite = overwrite)
  32: compute.db_cdm(addClass(keepClass(x), cl), name = name, temporary = temporary,     overwrite = overwrite)
  33: dplyr::compute(addClass(keepClass(x), cl), name = name, temporary = temporary,     overwrite = overwrite)
  34: compute.cdm_table(.)
  35: dplyr::compute(.)
  36: table %>% dplyr::compute()
  37: computeDBQuery(table = dbConceptsTable, tablePrefix = tablePrefix,     tableName = "_DED_concepts_3", cdm = cdm)
  38: ingredientDescendantsInDb(cdm = cdm, ingredient = ingredient,     verbose = verbose, tablePrefix = tablePrefix)
  39: dplyr::compute(., name = "ingredient_concepts")
  40: ingredientDescendantsInDb(cdm = cdm, ingredient = ingredient,     verbose = verbose, tablePrefix = tablePrefix) %>% dplyr::compute(name = "ingredient_concepts")
  41: executeChecksSingleIngredient(cdm = cdm, ingredient = ingredient,     subsetToConceptId = subsetToConceptId, checks = checks, minCellCount = minCellCount,     sampleSize = sample, tablePrefix = tablePrefix, earliestStartDate = earliestStartDate,     verbose = verbose, byConcept = byConcept, exposureTypeId = exposureTypeId)
  42: doTryCatch(return(expr), name, parentenv, handler)
  43: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  44: tryCatchList(expr, classes, parentenv, handlers)
  45: tryCatch({    ingredientResult <- executeChecksSingleIngredient(cdm = cdm,         ingredient = ingredient, subsetToConceptId = subsetToConceptId,         checks = checks, minCellCount = minCellCount, sampleSize = sample,         tablePrefix = tablePrefix, earliestStartDate = earliestStartDate,         verbose = verbose, byConcept = byConcept, exposureTypeId = exposureTypeId)    if (!is.null(outputFolder)) {        writeIngredientResultToDisk(resultList = ingredientResult,             databaseId = databaseId, outputFolder = outputFolder,             clearDBDir = (i == 1))    }}, error = function(e) {    warning(e)})
  46: executeChecks(cdm, ingredients = ingredients, subsetToConceptId = subsetToConceptId,     checks = checks, sample = sample, tablePrefix = tablePrefix,     earliestStartDate = earliestStartDate, verbose = verbose,     exposureTypeId = exposureTypeId, minCellCount = minCellCount,     outputFolder = outputFolder, databaseId = databaseId)
  47: executeChecksMock(cdm = cdm, ingredients = 1125315, subsetToConceptId = c(-40162522,     -19133768, -1127433, -40229134, -40231925, 1127078))
  48: eval(code, test_env)
  49: eval(code, test_env)
  50: withCallingHandlers({    eval(code, test_env)    if (!handled && !is.null(test)) {        skip_empty()    }}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,     message = handle_message, error = handle_error)
  51: doTryCatch(return(expr), name, parentenv, handler)
  52: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  53: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  54: doTryCatch(return(expr), name, parentenv, handler)
  55: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),     names[nh], parentenv, handlers[[nh]])
  56: tryCatchList(expr, classes, parentenv, handlers)
  57: tryCatch(withCallingHandlers({    eval(code, test_env)    if (!handled && !is.null(test)) {        skip_empty()    }}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,     message = handle_message, error = handle_error), error = handle_fatal,     skip = function(e) {    })
  58: test_code(desc, code, env = parent.frame(), reporter = reporter)
  59: test_that("subset on specific concepts", {    cdm <- mockDrugExposure()    result_all <- executeChecksMock(cdm = cdm, ingredients = 1125315,         subsetToConceptId = NULL)    expect_true(all(result_all$conceptSummary$drug_concept_id %in%         c(40162522, 19133768, 1127433, 1127078, 40229134, 40231925)))    result_subset <- executeChecksMock(cdm = cdm, ingredients = 1125315,         subsetToConceptId = 40162522)    expect_true(all(result_subset$conceptSummary$drug_concept_id %in%         c(40162522)))    result_subset2 <- executeChecksMock(cdm = cdm, ingredients = 1125315,         subsetToConceptId = c(40162522, 1127078))    expect_true(all(result_subset2$conceptSummary$drug_concept_id %in%         c(40162522, 1127078)))    result_subset3 <- executeChecksMock(cdm = cdm, ingredients = 1125315,         subsetToConceptId = c(-40162522, -19133768, -1127433,             -40229134, -40231925))    expect_true(all(result_subset3$conceptSummary$drug_concept_id ==         1127078))    result_subset4 <- executeChecksMock(cdm = cdm, ingredients = 1125315,         subsetToConceptId = c(-40162522, -19133768, -1127433,             -40229134, -40231925, 1127078))    expect_true(identical(result_subset3, result_subset4))    expect_error(executeChecksMock(cdm = cdm, ingredients = 1125315,         subsetToConceptId = c(-40162522, 40162522)))    DBI::dbDisconnect(attr(cdm, "dbcon"), shutdown = TRUE)})
  60: eval(code, test_env)
  61: eval(code, test_env)
  62: withCallingHandlers({    eval(code, test_env)    if (!handled && !is.null(test)) {        skip_empty()    }}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,     message = handle_message, error = handle_error)
  63: doTryCatch(return(expr), name, parentenv, handler)
  64: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  65: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  66: doTryCatch(return(expr), name, parentenv, handler)
  67: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),     names[nh], parentenv, handlers[[nh]])
  68: tryCatchList(expr, classes, parentenv, handlers)
  69: tryCatch(withCallingHandlers({    eval(code, test_env)    if (!handled && !is.null(test)) {        skip_empty()    }}, expectation = handle_expectation, skip = handle_skip, warning = handle_warning,     message = handle_message, error = handle_error), error = handle_fatal,     skip = function(e) {    })
  70: test_code(test = NULL, code = exprs, env = env, reporter = get_reporter() %||%     StopReporter$new())
  71: source_file(path, env = env(env), desc = desc, error_call = error_call)
  72: FUN(X[[i]], ...)
  73: lapply(test_paths, test_one_file, env = env, desc = desc, error_call = error_call)
  74: doTryCatch(return(expr), name, parentenv, handler)
  75: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  76: tryCatchList(expr, classes, parentenv, handlers)
  77: tryCatch(code, testthat_abort_reporter = function(cnd) {    cat(conditionMessage(cnd), "\n")    NULL})
  78: with_reporter(reporters$multi, lapply(test_paths, test_one_file,     env = env, desc = desc, error_call = error_call))
  79: test_files_serial(test_dir = test_dir, test_package = test_package,     test_paths = test_paths, load_helpers = load_helpers, reporter = reporter,     env = env, stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning,     desc = desc, load_package = load_package, error_call = error_call)
  80: test_files(test_dir = path, test_paths = test_paths, test_package = package,     reporter = reporter, load_helpers = load_helpers, env = env,     stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning,     load_package = load_package, parallel = parallel)
  81: test_dir("testthat", package = package, reporter = reporter,     ..., load_package = "installed")
  82: test_check("DrugExposureDiagnostics")
  An irrecoverable exception occurred. R is aborting now ...