Running 'cli.R' [0s]
  Running 'lcg-uniformity.R' [20s]
  Running 'lcg.R' [3s]
  Running 'odds-and-ends.R' [154s]
  Running 'port4me,list.R' [0s]
  Running 'port4me-uniformity.R' [10s]
  Running 'port4me.R' [173s]
  Running 'string_to_uint.R' [0s]
Running the tests in 'tests/odds-and-ends.R' failed.
Complete output:
  > library(port4me)
  > 
  > is_tcp_port_available <- port4me:::is_tcp_port_available
  > initialize_internet <- port4me:::initialize_internet
  > parse_cli_args <- port4me:::parse_cli_args
  > 
  > # --------------------------------------------------------
  > # is_tcp_port_available() and initialize_internet()
  > # --------------------------------------------------------
  > Sys.setenv("_PORT4ME_CHECK_AVAILABLE_PORTS_" = "<invalid>")
  > res <- tryCatch({
  +   is_tcp_port_available(1024)
  + }, error = identity)
  > stopifnot(inherits(res, "error"))
  > Sys.unsetenv("_PORT4ME_CHECK_AVAILABLE_PORTS_")
  > 
  > env <- environment(initialize_internet)
  > env[["done"]] <- FALSE
  > initialize_internet()
  > 
  > env <- environment(initialize_internet)
  > env[["done"]] <- FALSE
  > env[["baseenv"]] <- emptyenv()
  > initialize_internet()
  Warning message:
  In socketConnection(port = 0L, server = FALSE, blocking = FALSE,  :
    localhost:0 cannot be opened
  > 
  > 
  > # --------------------------------------------------------
  > # Test unloading package
  > # --------------------------------------------------------
  > unloadNamespace("port4me")
  > 
  > 
  > proc.time()
     user  system elapsed 
     0.15    0.09    0.20 
Running the tests in 'tests/port4me.R' failed.
Complete output:
  > library(port4me)
  > 
  > Sys.setenv("_PORT4ME_CHECK_AVAILABLE_PORTS_" = "any")
  > 
  > message('- port4me(user = "alice")')
  - port4me(user = "alice")
  > truth <- 30845L
  > ports <- port4me(user = "alice")
  > print(ports)
  [1] 30845
  > stopifnot(
  +   is.integer(ports),
  +   all(is.finite(ports)),
  +   all(ports > 0L),
  +   all(ports <= 65535L),
  +   all(ports >= 1024L),
  +   length(ports) == length(truth),
  +   all(ports == truth)
  + )
  > 
  > 
  > message('- port4me(user = "bob")')
  - port4me(user = "bob")
  > truth <- 54242L
  > ports <- port4me(user = "bob")
  > print(ports)
  [1] 54242
  > stopifnot(
  +   is.integer(ports),
  +   all(is.finite(ports)),
  +   all(ports > 0L),
  +   all(ports <= 65535L),
  +   all(ports >= 1024L),
  +   length(ports) == length(truth),
  +   all(ports == truth)
  + )
  > 
  > 
  > message('- port4me(user = "alice", tool = "rstudio")')
  - port4me(user = "alice", tool = "rstudio")
  > truth <- 22486L
  > ports <- port4me(user = "alice", tool="rstudio")
  > print(ports)
  [1] 22486
  > stopifnot(
  +   is.integer(ports),
  +   all(is.finite(ports)),
  +   all(ports > 0L),
  +   all(ports <= 65535L),
  +   all(ports >= 1024L),
  +   length(ports) == length(truth),
  +   all(ports == truth)
  + )
  > 
  > 
  > message('- port4me(user = "alice") with PORT4ME_TOOL=rstudio)')
  - port4me(user = "alice") with PORT4ME_TOOL=rstudio)
  > Sys.setenv(PORT4ME_TOOL = "rstudio")
  > truth <- 22486L
  > ports <- port4me(user = "alice")
  > print(ports)
  [1] 22486
  > stopifnot(
  +   is.integer(ports),
  +   all(is.finite(ports)),
  +   all(ports > 0L),
  +   all(ports <= 65535L),
  +   all(ports >= 1024L),
  +   length(ports) == length(truth),
  +   all(ports == truth)
  + )
  > Sys.unsetenv("PORT4ME_TOOL")
  > 
  > 
  > message('- port4me(user = "alice", tool = "jupyter-notebook")')
  - port4me(user = "alice", tool = "jupyter-notebook")
  > truth <- 29525L
  > ports <- port4me(user = "alice", tool="jupyter-notebook")
  > print(ports)
  [1] 29525
  > stopifnot(
  +   is.integer(ports),
  +   all(is.finite(ports)),
  +   all(ports > 0L),
  +   all(ports <= 65535L),
  +   all(ports >= 1024L),
  +   length(ports) == length(truth),
  +   all(ports == truth)
  + )
  > 
  > message('- port4me() with PORT4ME_USER=alice')
  - port4me() with PORT4ME_USER=alice
  > Sys.setenv(PORT4ME_USER = "alice")
  > truth <- 30845L
  > ports <- port4me()
  > print(ports)
  [1] 30845
  > stopifnot(
  +   is.integer(ports),
  +   all(is.finite(ports)),
  +   all(ports > 0L),
  +   all(ports <= 65535L),
  +   all(ports >= 1024L),
  +   length(ports) == length(truth),
  +   all(ports == truth)
  + )
  > 
  > 
  > truth <- c(30845, 19654, 32310, 63992, 15273, 31420, 62779, 55372, 24143, 41300)
  > exclude <- c(30845, 32310)
  > message(sprintf("- port4me(exclude = c(%s))", paste(exclude, collapse = ", ")))
  - port4me(exclude = c(30845, 32310))
  > port <- port4me(exclude = exclude)
  > print(port)
  [1] 19654
  > stopifnot(
  +   length(port) == 1L,
  +   is.integer(port),
  +   is.finite(port),
  +   port > 0L,
  +   port <= 65535L,
  +   port >= 1024L,
  +   port == setdiff(truth, exclude)[1]
  + )
  > 
  > 
  > message(sprintf("- port4me() with PORT4ME_EXCLUDE=%s", paste(exclude, collapse = ", ")))
  - port4me() with PORT4ME_EXCLUDE=30845, 32310
  > Sys.setenv(PORT4ME_EXCLUDE = paste(exclude, collapse = ","))
  > port <- port4me()
  > print(port)
  [1] 19654
  > stopifnot(
  +   length(port) == 1L,
  +   is.integer(port),
  +   is.finite(port),
  +   port > 0L,
  +   port <= 65535L,
  +   port >= 1024L,
  +   port == setdiff(truth, exclude)[1]
  + )
  > Sys.unsetenv("PORT4ME_EXCLUDE")
  > 
  > 
  > include <- c(2000:2123, 4321, 10000:10999)
  > message("- port4me(include = c(2000:2123, 4321, 10000:10999))")
  - port4me(include = c(2000:2123, 4321, 10000:10999))
  > port <- port4me(include = include)
  > print(port)
  [1] 10451
  > stopifnot(
  +   length(port) == 1L,
  +   is.integer(port),
  +   is.finite(port),
  +   port > 0L,
  +   port <= 65535L,
  +   port >= 1024L,
  +   port == 10451L
  + )
  > 
  > 
  > include <- c(2000:2123, 4321, 10000:10999)
  > message("- port4me() with PORT4ME_INCLUDE=...")
  - port4me() with PORT4ME_INCLUDE=...
  > Sys.setenv(PORT4ME_INCLUDE = paste(include, collapse = ","))
  > port <- port4me()
  > print(port)
  [1] 10451
  > stopifnot(
  +   length(port) == 1L,
  +   is.integer(port),
  +   is.finite(port),
  +   port > 0L,
  +   port <= 65535L,
  +   port >= 1024L,
  +   port == 10451L
  + )
  > Sys.unsetenv("PORT4ME_INCLUDE")
  > 
  > 
  > message('- port4me(exclude = "1024-1099")')
  - port4me(exclude = "1024-1099")
  > port <- port4me(exclude = "1024-1099")
  > 
  > message('- port4me(include = "1024-1099")')
  - port4me(include = "1024-1099")
  > port <- port4me(include = "1024-1099")
  > 
  > message('- port4me(prepend = "1024-1099")')
  - port4me(prepend = "1024-1099")
  > port <- port4me(prepend = "1024-1099")
  > 
  > prepend <- c(2000:2123, 4321, 10000:10999)
  > message("- port4me(prepend = c(2000:2123, 4321, 10000:10999))")
  - port4me(prepend = c(2000:2123, 4321, 10000:10999))
  > port <- port4me(prepend = prepend)
  > print(port)
  [1] 2000
  > stopifnot(
  +   length(port) == 1L,
  +   is.integer(port),
  +   is.finite(port),
  +   port > 0L,
  +   port <= 65535L,
  +   port >= 1024L,
  +   port == prepend[1]
  + )
  > 
  > 
  > 
  > message("- port4me(skip = 1L)")
  - port4me(skip = 1L)
  > port <- port4me(user = "alice", skip = 1L)
  > print(port)
  [1] 19654
  > stopifnot(
  +   length(port) == 1L,
  +   is.integer(port),
  +   is.finite(port),
  +   port > 0L,
  +   port <= 65535L,
  +   port >= 1024L,
  +   port == 19654L
  + )
  > 
  > 
  > # -------------------------------------------------------
  > # Check TCP port
  > # -------------------------------------------------------
  > message("- port4me() can detect busy port")
  - port4me() can detect busy port
  > Sys.unsetenv("_PORT4ME_CHECK_AVAILABLE_PORTS_")
  > port <- NA_integer_
  > if (.Platform[["OS.type"]] == "unix" && Sys.info()[["sysname"]] != "Darwin") {
  +   ## Start dynamic help, if not already running, and get its port
  +   ## HELP WANTED: On both macOS and MS Windows, this port is still
  +   ## available. Why?
  +   ## system("python -m port4me --test=<port>") confirms this.
  +   ## /HB 2024-01-06
  +   port <- tools::startDynamicHelp(NA)
  +   message("Dynamic help port: ", port)
  + }
  > 
  > if (!is.na(port)) {
  +   Sys.setenv(PORT4ME_DEBUG = "true")
  +   
  +   res <- port4me(test = port)
  +   message(sprintf("port4me(test = %d) == %s", port, res))
  +   stopifnot(identical(res, FALSE))
  + 
  +   Sys.setenv(PORT4ME_TEST = port)
  +   res <- port4me()
  +   message(sprintf("Sys.setenv('PORT4ME_TEST'='%d'); port4me() == %s", port, res))
  +   stopifnot(identical(res, FALSE))
  +   Sys.unsetenv("PORT4ME_TEST")
  + 
  +   res <- tryCatch({
  +     port4me(include = port, exclude = setdiff(1:65535, port), max_tries = 1L)
  +   }, error = identity)
  +   stopifnot(inherits(res, "error"))
  + 
  +   res <- port4me(include = port, exclude = setdiff(1:65535, port), max_tries = 1L, must_work = FALSE)
  +   stopifnot(res == -1L)
  + 
  +   Sys.unsetenv("PORT4ME_DEBUG")
  + } else {
  +   message("Skipping; don't know how to test on ", sQuote(.Platform[["OS.type"]]))
  + }
  Skipping; don't know how to test on 'windows'
  > 
  > 
  > 
  > # -------------------------------------------------------
  > # Exceptions
  > # -------------------------------------------------------
  > message('- port4me(user = "") produces an error')
  - port4me(user = "") produces an error
  > res <- tryCatch({
  +   port4me(user = "")
  + }, error = identity)
  > stopifnot(inherits(res, "error"))
  > 
  > 
  > message('- port4me(include = "<invalid>") produces an error')
  - port4me(include = "<invalid>") produces an error
  > res <- tryCatch({
  +   port4me(include = "<invalid>")
  + }, error = identity)
  > stopifnot(inherits(res, "error"))
  > 
  > 
  > 
  > # -------------------------------------------------------
  > # Addition tests to increase test coverage
  > # -------------------------------------------------------
  > message('- port4me() with PORT4ME_DEBUG = true')
  - port4me() with PORT4ME_DEBUG = true
  > Sys.setenv(PORT4ME_DEBUG = "true")
  > port <- port4me()
  seed_str='alice'
  seed=92903040
  List of 3
   $ include: int(0) 
   $ exclude: int [1:80] 1 7 9 11 13 15 17 19 20 21 ...
   $ prepend: int(0) 
  port4me:::is_tcp_port_available(30845): available (can bind and listen)
  > print(port)
  [1] 30845
  > 
  > proc.time()
     user  system elapsed 
     0.50    0.06    0.56