Skip to content

Commit

Permalink
unit test to confirm no source dir modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
bburns632 committed May 17, 2024
1 parent 390434b commit 39d2345
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/testthat.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ if(identical(Sys.getenv("NOT_CRAN"), "true")){

}

# Record modifaction time of package directory to be checked at end of testing
# in test-Z-test-no-source-modifcations.R
tmp_pkgnet_path <- file.path(Sys.getenv('PKGNET_TEST_LIB'), 'pkgnet')
Sys.setenv(PKGNET_LATEST_MOD = file.info(tmp_pkgnet_path)$mtime)

# This withr statement should be redundant.
# This is within a test environment in which .libpaths() has been altered to include PKGNET_TEST_LIB.
# Yet, it appears to be necessary.
Expand Down
17 changes: 17 additions & 0 deletions tests/testthat/test-Z-test-no-source-modifcations.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Inditended to be run last, this is to confirm that no files
# within the package directory are modified during the normal
# operation of pkgnet during these tests. This includes the
# creation and deletion of temp files for rendering.

test_that('No modificatoin to pkgnet directory during testing',{
startModTime <- Sys.getenv('PKGNET_LATEST_MOD')

tmp_pkgnet_path <- file.path(Sys.getenv('PKGNET_TEST_LIB'), 'pkgnet')
currentModTime <- file.info(tmp_pkgnet_path)$mtime

expect_equal(object = currentModTime
, expected = startModTime
, info = "The source directory was modified during the execution of tests."
)

})

0 comments on commit 39d2345

Please sign in to comment.