Captures system and session info, returns invisibly, and optionally writes to JSON file for later use. This JSON file is in the format expected by mrgvalidate::create_package_docs() and is intended to accompany a .csv of test results. See mrgvalidate::input_formats for details.

get_sys_info(
  out_path = NULL,
  executor = NULL,
  env_vars = NULL,
  sys_info = FALSE,
  session = FALSE
)

Arguments

out_path

File path for resulting JSON file. Will also return the R list invisibly. If NULL, only returns list and does not write to file.

executor

Person who is calling the function, and presumably running the test suite in question. If NULL, will pull Sys.getenv("USER").

env_vars

Character vector of enviroment variables to check and record, if present. Each will be a key in the [["info"]][["env_vars"]] element of the resulting json. Any that are not set at call time will be present with a value of "".

sys_info

Logical indicating whether to run Sys.info() and store the results under [["info"]][["sys"]]. Defaults to FALSE.

session

Logical indicating whether to run SessionInfo() and store the results under [["info"]][["session"]]. Defaults to FALSE.

Value

Invisibly returns named list with the elements described in "Details". This list is also written to JSON if a path is provided to out_path.

Details

Structure of returned (and written) list is as follows:

  • "date" -- Date and time when function is called.

  • "executor" -- String passed through from executor param.

  • "info" -- Contains system and session info in sub-elements:

    • "sys" (Optional) -- System info: sysname, version, release, machine.

    • "env_vars" (Optional) -- Environment variables passed by the user, with their current values at time of function call.

    • "session" (Optional) -- Character vector with output from sessionInfo() call. Only present if session = TRUE was passed.

Examples

str(get_sys_info(
  env_vars = c("USER", "METWORX_VERSION"),
  sys_info = TRUE
))
#> List of 3
#>  $ date    : chr "2022-12-07 14:36:46"
#>  $ executor: chr "sethg"
#>  $ info    :List of 2
#>   ..$ env_vars:List of 2
#>   .. ..$ USER           : chr "sethg"
#>   .. ..$ METWORX_VERSION: chr "22.09"
#>   ..$ sys     :List of 4
#>   .. ..$ sysname: chr "Linux"
#>   .. ..$ version: chr "#91~18.04.1-Ubuntu SMP Sun Aug 14 01:24:43 UTC 2022"
#>   .. ..$ release: chr "5.4.0-1084-aws"
#>   .. ..$ machine: chr "x86_64"