# NOT RUN {
# create a test file, in temp directory
tests <- "
addOne <- function(x) x + 2
Sys.setenv(lolz=2)
expect_true(addOne(0) > 0)
expect_equal(2, addOne(1))
Sys.unsetenv('lolz')
"
testfile <- tempfile(pattern="test_", fileext=".R")
write(tests, testfile)
# run test file
out <- run_test_file(testfile,color=FALSE)
out
# print everything in short format, include passes in print.
print(out, nlong=0, passes=TRUE)
# run test file, track supported side-effects
run_test_file(testfile, side_effects=TRUE)
# run test file, track only changes in working directory
run_test_file(testfile, side_effects=list(pwd=TRUE, envvar=FALSE))
# }
Run the code above in your browser using DataCamp Workspace