Running ‘testthat.R’ [5s/14s]
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
  > library(testthat)
  > library(pkgfilecache)
  > 
  > test_check("pkgfilecache")
  Download file to '~/.local/share/pkgfilecache/local_file1.txt' from 'https://raw.githubusercontent.com/dfsp-spirit/pkgfilecache/master/inst/extdata/file1.txt'
  trying URL 'https://raw.githubusercontent.com/dfsp-spirit/pkgfilecache/master/inst/extdata/file1.txt'
  Content type 'text/plain; charset=utf-8' length 17 bytes
  ==================================================
  downloaded 17 bytes
  
  Download file to '~/.local/share/pkgfilecache/local_file2.txt' from 'https://raw.githubusercontent.com/dfsp-spirit/pkgfilecache/master/inst/extdata/file2.txt'
  trying URL 'https://raw.githubusercontent.com/dfsp-spirit/pkgfilecache/master/inst/extdata/file2.txt'
  Content type 'text/plain; charset=utf-8' length 17 bytes
  ==================================================
  downloaded 17 bytes
  
  Download file to '~/.local/share/pkgfilecache/local_file1.txt' from 'https://raw.githubusercontent.com/dfsp-spirit/pkgfilecache/master/inst/extdata/file1.txt'
  trying URL 'https://raw.githubusercontent.com/dfsp-spirit/pkgfilecache/master/inst/extdata/file1.txt'
  Content type 'text/plain; charset=utf-8' length 17 bytes
  ==================================================
  downloaded 17 bytes
  
  Download file to '~/.local/share/pkgfilecache/local_file2.txt' from 'https://raw.githubusercontent.com/dfsp-spirit/pkgfilecache/master/inst/extdata/file2.txt'
  trying URL 'https://raw.githubusercontent.com/dfsp-spirit/pkgfilecache/master/inst/extdata/file2.txt'
  Content type 'text/plain; charset=utf-8' length 17 bytes
  ==================================================
  downloaded 17 bytes
  
  Download file to '~/.local/share/pkgfilecache/local_file1_whatever.txt' from 'https://raw.githubusercontent.com/dfsp-spirit/pkgfilecache/master/inst/extdata/file1.txt'
  trying URL 'https://raw.githubusercontent.com/dfsp-spirit/pkgfilecache/master/inst/extdata/file1.txt'
  Content type 'text/plain; charset=utf-8' length 17 bytes
  ==================================================
  downloaded 17 bytes
  
  Download file to '~/.local/share/pkgfilecache/another_file2.some.ext' from 'https://raw.githubusercontent.com/dfsp-spirit/pkgfilecache/master/inst/extdata/file2.txt'
  trying URL 'https://raw.githubusercontent.com/dfsp-spirit/pkgfilecache/master/inst/extdata/file2.txt'
  Content type 'text/plain; charset=utf-8' length 17 bytes
  ==================================================
  downloaded 17 bytes
  
  Download file to '~/.local/share/pkgfilecache/local_file1.txt' from 'https://raw.githubusercontent.com/dfsp-spirit/pkgfilecache/master/inst/extdata/file1.txt'
  trying URL 'https://raw.githubusercontent.com/dfsp-spirit/pkgfilecache/master/inst/extdata/file1.txt'
  Content type 'text/plain; charset=utf-8' length 17 bytes
  ==================================================
  downloaded 17 bytes
  
  Download file to '~/.local/share/pkgfilecache/will_not_make_it.txt' from 'https://raw.githubusercontent.com/dfsp-spirit/pkgfilecache/master/inst/extdata/nosuchfile'
  trying URL 'https://raw.githubusercontent.com/dfsp-spirit/pkgfilecache/master/inst/extdata/nosuchfile'
  Download file to '~/.local/share/pkgfilecache/will_not_make_it.txt' from 'https://raw.githubusercontent.com/dfsp-spirit/pkgfilecache/master/inst/extdata/nosuchfile'
  trying URL 'https://raw.githubusercontent.com/dfsp-spirit/pkgfilecache/master/inst/extdata/nosuchfile'
  Download file to '~/.local/share/pkgfilecache/will_not_make_it.txt' from 'https://raw.githubusercontent.com/dfsp-spirit/pkgfilecache/master/inst/extdata/nosuchfile'
  trying URL 'https://raw.githubusercontent.com/dfsp-spirit/pkgfilecache/master/inst/extdata/nosuchfile'
  Download file to '~/.local/share/pkgfilecache/local_file1.txt' from 'https://raw.githubusercontent.com/dfsp-spirit/pkgfilecache/master/inst/extdata/file1.txt'
  trying URL 'https://raw.githubusercontent.com/dfsp-spirit/pkgfilecache/master/inst/extdata/file1.txt'
  Content type 'text/plain; charset=utf-8' length 17 bytes
  ==================================================
  downloaded 17 bytes
  
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  pkgfilecache
   --- call from context --- 
  ensure_files_available(pkg_info, local_relative_filenames, urls, 
      md5sums = md5sums)
   --- call from argument --- 
  if (!(dir.exists(datadir))) {
      dir.create(datadir, showWarnings = TRUE, recursive = TRUE)
  }
   --- R stacktrace ---
  where 1 at test-filecache.R#278: ensure_files_available(pkg_info, local_relative_filenames, urls, 
      md5sums = md5sums)
  where 2: eval(code, test_env)
  where 3: eval(code, test_env)
  where 4: 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)
  where 5: doTryCatch(return(expr), name, parentenv, handler)
  where 6: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 7: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 8: doTryCatch(return(expr), name, parentenv, handler)
  where 9: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 10: tryCatchList(expr, classes, parentenv, handlers)
  where 11: 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) {
      })
  where 12: test_code(desc, code, env = parent.frame(), reporter = reporter)
  where 13 at test-filecache.R#267: test_that("Using package version and author works", {
      skip_if_offline(host = "raw.githubusercontent.com")
      skip_if(tests_running_on_cran_under_macos(), message = "Skipping on CRAN under MacOS")
      pkg_info = get_pkg_info("pkgfilecache", author = "dfsp-spirit", 
          version = "0.1")
      testfile_local = "local_file1.txt"
      local_relative_filenames = c(testfile_local)
      urls = c("https://raw.githubusercontent.com/dfsp-spirit/pkgfilecache/master/inst/extdata/file1.txt")
      md5sums = c("35261471bcd198583c3805ee2a543b1f")
      deleted = remove_cached_files(pkg_info, local_relative_filenames)
      res = ensure_files_available(pkg_info, local_relative_filenames, 
          urls, md5sums = md5sums)
      expect_equal(res$file_status, c(TRUE))
      expect_equal(length(res$available), 1L)
      expect_equal(length(res$missing), 0L)
      erase_file_cache(pkg_info)
  })
  where 14: eval(code, test_env)
  where 15: eval(code, test_env)
  where 16: 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)
  where 17: doTryCatch(return(expr), name, parentenv, handler)
  where 18: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  where 19: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  where 20: doTryCatch(return(expr), name, parentenv, handler)
  where 21: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
      names[nh], parentenv, handlers[[nh]])
  where 22: tryCatchList(expr, classes, parentenv, handlers)
  where 23: 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) {
      })
  where 24: test_code(NULL, exprs, env)
  where 25: source_file(path, child_env(env), wrap = wrap)
  where 26: FUN(X[[i]], ...)
  where 27: lapply(test_paths, test_one_file, env = env, wrap = wrap)
  where 28: force(code)
  where 29: doWithOneRestart(return(expr), restart)
  where 30: withOneRestart(expr, restarts[[1L]])
  where 31: withRestarts(testthat_abort_reporter = function() NULL, force(code))
  where 32: with_reporter(reporters$multi, lapply(test_paths, test_one_file, 
      env = env, wrap = wrap))
  where 33: test_files(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, 
      wrap = wrap, load_package = load_package)
  where 34: 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, 
      wrap = wrap, load_package = load_package, parallel = parallel)
  where 35: test_dir("testthat", package = package, reporter = reporter, 
      ..., load_package = "installed")
  where 36: test_check("pkgfilecache")
  
   --- value of length: 14 type: logical ---
   [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
   --- function from context --- 
  function (pkg_info, relative_filenames, urls, files_are_binary = NULL, 
      md5sums = NULL, on_errors = "warn", download = TRUE) 
  {
      if (length(relative_filenames) != length(urls)) {
          stop(sprintf("Data mismatch: received %d relative_filenames but %d urls. Lengths must be identical.", 
              length(relative_filenames), length(urls)))
      }
      if (!is.null(md5sums)) {
          if (length(relative_filenames) != length(md5sums)) {
              stop(sprintf("Data mismatch: received %d relative_filenames but %d md5sums. Lengths must be identical if md5sums is not NULL.", 
                  length(relative_filenames), length(md5sums)))
          }
      }
      if (!(on_errors %in% c("warn", "stop", "ignore"))) {
          stop(sprintf("Parameter 'on_errors' must be one of c('warn', 'stop', 'ignore') nut was '%s'.\n", 
              on_errors))
      }
      datadir = get_cache_dir(pkg_info)
      make_pgk_cache_subdir_for_all_relative_files(pkg_info, relative_filenames)
      local_files_absolute = get_abs_filenames(datadir, relative_filenames)
      local_files_md5_ok = files_exist_md5(local_files_absolute, 
          md5sums)
      if (!(dir.exists(datadir))) {
          dir.create(datadir, showWarnings = TRUE, recursive = TRUE)
      }
      if (download) {
          download_files_with_md5_mismatch(local_files_absolute, 
              local_files_md5_ok, urls, files_are_binary = files_are_binary)
          are_local_files_md5_ok_afterwards = files_exist_md5(local_files_absolute, 
              md5sums)
          if (on_errors %in% c("warn", "stop")) {
              num_errors = 0L
              for (file_idx in 1:length(local_files_absolute)) {
                  lfile = local_files_absolute[file_idx]
                  if (!(are_local_files_md5_ok_afterwards[file_idx])) {
                    num_errors = num_errors + 1L
                    if (is.null(md5sums)) {
                      warning(sprintf("Failed to get file '%s' to path '%s'.\n", 
                        relative_filenames[file_idx], lfile))
                    }
                    else {
                      warning(sprintf("Failed to get file '%s' with md5sum '%s' to path '%s'.\n", 
                        relative_filenames[file_idx], md5sums[file_idx], 
                        lfile))
                    }
                  }
              }
              if (num_errors > 0L && on_errors == "stop") {
                  stop(sprintf("Getting files into local cache dir failed for %d of %d files (and stop on errors was requested).\n", 
                    num_errors, length(local_files_absolute)))
              }
          }
      }
      else {
          are_local_files_md5_ok_afterwards = files_exist_md5(local_files_absolute, 
              md5sums)
      }
      ret_list = list()
      ret_list$available = relative_filenames[are_local_files_md5_ok_afterwards == 
          TRUE]
      ret_list$missing = relative_filenames[are_local_files_md5_ok_afterwards == 
          FALSE]
      ret_list$file_status = are_local_files_md5_ok_afterwards
      return(ret_list)
  }
  <bytecode: 0x21445e8>
  <environment: namespace:pkgfilecache>
   --- function search by body ---
  Function ensure_files_available in namespace pkgfilecache has this body.
   ----------- END OF FAILURE REPORT -------------- 
  Download file to '~/.local/share/pkgfilecache/dir1/local_file1.txt' from 'https://raw.githubusercontent.com/dfsp-spirit/pkgfilecache/master/inst/extdata/file1.txt'
  trying URL 'https://raw.githubusercontent.com/dfsp-spirit/pkgfilecache/master/inst/extdata/file1.txt'
  Content type 'text/plain; charset=utf-8' length 17 bytes
  ==================================================
  downloaded 17 bytes
  
  Download file to '~/.local/share/pkgfilecache/dir2/will_not_make_it.txt' from 'https://raw.githubusercontent.com/dfsp-spirit/pkgfilecache/master/inst/extdata/nosuchfile'
  trying URL 'https://raw.githubusercontent.com/dfsp-spirit/pkgfilecache/master/inst/extdata/nosuchfile'
  ══ Warnings ════════════════════════════════════════════════════════════════════
  ── Warning (test-filecache.R:277:3): Using package version and author works ────
  number of items to replace is not a multiple of replacement length
  Backtrace:
   1. pkgfilecache::remove_cached_files(pkg_info, local_relative_filenames) test-filecache.R:277:2
   2. pkgfilecache:::get_abs_filenames(datadir, relative_filenames)
  ── Warning (test-filecache.R:278:3): Using package version and author works ────
  number of items to replace is not a multiple of replacement length
  Backtrace:
   1. pkgfilecache::ensure_files_available(...) test-filecache.R:278:2
   2. pkgfilecache:::get_abs_filenames(datadir, relative_filenames)
  
  ══ Failed tests ════════════════════════════════════════════════════════════════
  ── Error (test-filecache.R:278:3): Using package version and author works ──────
  Error: the condition has length > 1
  Backtrace:
      █
   1. └─pkgfilecache::ensure_files_available(...) test-filecache.R:278:2
  
  [ FAIL 1 | WARN 2 | SKIP 0 | PASS 87 ]
  Error: Test failures
  Execution halted