11context(" status" )
22
3- make_testdir <- function () {
4- td <- tempfile()
5- dir.create(td )
6- teardown(unlink(td , recursive = TRUE , force = TRUE ))
7-
8- td
9- }
103
114test_that(" status functions accept explicit filename" , {
12- d <- make_testdir ()
5+ d <- withr :: local_tempdir ()
136 f <- file.path(d , " MY_STATUS" )
147
158 expect_silent(status.start(" TRAITS" , f ))
@@ -29,22 +22,22 @@ test_that("status functions accept explicit filename", {
2922})
3023
3124test_that(" status handles file = dir/" , {
32- d <- make_testdir ()
25+ d <- withr :: local_tempdir ()
3326 status.start(" NONE" , d )
3427 status.end(" DONE" , d )
3528 expect_equal(status.check(" NONE" , file.path(d , " STATUS" )), 1L )
3629})
3730
3831test_that(" status functions read from local settings" , {
39- settings <- list (outdir = make_testdir ())
32+ settings <- list (outdir = withr :: local_tempdir ())
4033 expect_silent(status.skip(" auto" ))
4134 expect_match(
4235 readLines(file.path(settings $ outdir , " STATUS" ))[[1 ]],
4336 " ^auto.*SKIPPED\\ s*$" )
4437})
4538
4639test_that(" status finds settings defined outside immediate calling scope" , {
47- settings <- list (outdir = make_testdir ())
40+ settings <- list (outdir = withr :: local_tempdir ())
4841 f <- function (name ) {
4942 status.start(name )
5043 status.end()
@@ -60,11 +53,11 @@ test_that("status finds settings defined outside immediate calling scope", {
6053
6154test_that(" status writes to stdout on bad filename" , {
6255 expect_output(status.start(" NOFILE" ), " NOFILE" )
63- settings <- list (outdir = file.path(make_testdir (), " fake" , " path" ))
56+ settings <- list (outdir = file.path(withr :: local_tempdir (), " fake" , " path" ))
6457 expect_output(status.end(), " \\ d{4}-\\ d{2}-\\ d{2}.*DONE" )
6558})
6659
6760test_that(" status.check returns 0 on bad filename" , {
6861 expect_equal(status.check(" NOFILE" ), 0L )
69- expect_equal(status.check(" NOFILE" , file.path(make_testdir (), " fake" )), 0L )
62+ expect_equal(status.check(" NOFILE" , file.path(withr :: local_tempdir (), " fake" )), 0L )
7063})
0 commit comments