Gets the on R CMD check if the current R session was launched by it.

queryRCmdCheck(...)

Arguments

...

Not used.

Value

Returns character string

"checkingTests" if 'R CMD check' runs one one of the package tests, and "checkingExamples" if it runs one of the package examples. If the current R session was not launched by 'R CMD check', then "notRunning" is returned.

Limitations

This function only works if the working directory has not been changed.

Author

Henrik Bengtsson

Examples


status <- queryRCmdCheck()
if (status != "notRunning") {
  cat("The current R session was launched by R CMD check. Status: ", status, "\n")
} else {
  cat("The current R session was not launched by R CMD check.\n")
}
#> The current R session was not launched by R CMD check.

# Display how R was launched
print(base::commandArgs())
#> [1] "/home/henrik/shared/software/CBI/_ubuntu22_04/R-4.3.2-gcc11/lib/R/bin/exec/R"
#> [2] "--slave"                                                                     
#> [3] "--no-save"                                                                   
#> [4] "--no-restore"                                                                
#> [5] "-f"                                                                          
#> [6] "/tmp/henrik/RtmpsaLUi7/callr-scr-230bf2582fd15"                              

# Display loaded packages etc.
print(search())
#>  [1] ".GlobalEnv"          "package:R.utils"     "package:R.oo"       
#>  [4] "package:R.methodsS3" "package:stats"       "package:graphics"   
#>  [7] "package:grDevices"   "package:datasets"    "package:utils"      
#> [10] "package:methods"     "Autoloads"           "tools:callr"        
#> [13] "package:base"       

# Display current working directory
print(getwd())
#> [1] "/tmp/henrik/RtmpsaLUi7/R.utils/docs/reference"