tinytest (version 1.1.0)

report_side_effects: Report side effects for expressions in test files

Description

Call this function from within a test file to report side effects.

Usage

report_side_effects(report = TRUE, envvar = report, pwd = report,
  files = report)

Arguments

report

[logical] report all side-effects

envvar

[logical] changes in environment variables

pwd

[logical] changes in working directory

files

[logical] changes in files in the directory where the test file lives. Also watches subdirectories.

Value

A named logical, indicating which aspects of the environment are tracked, invisibly.

Details

A side effect causes a change in an external variable outside of the scope of a function, or test file. This includes environment variables, global options, global R variables, creating files or directories, and so on.

If this function is called in a test file, side effects are monitored from that point in the file and only for that file. The state of the environment before and after running every expression in the file are compared.

There is some performance penalty in tracking external variables especially those that require a system call.

Examples

Run this code
# NOT RUN {
# switch on
report_side_effects()
# switch off
report_side_effects(FALSE)

# only report changes in environment variables
report_side_effects(pwd=FALSE)

# }

Run the code above in your browser using DataCamp Workspace