Open
Description
First, assume that getwd()
returns "pkg". Then if I run tests via run_test_dir("tests")
, and use call_wd()
to access the previous working directory, it will return "pkg/tests" instead of "pkg".
I believe that the bug can be traced to https://github.com/markvanderloo/tinytest/blob/master/pkg/R/tinytest.R#L20
While set_call_wd()
contains logic to not update CALLDIR if it is already set, it does not have logic to prevent it from being unset prematurely. The logic flow looks like this:
run_test_dir("tests")
callsset_call_wd("pkg")
and changes directory to "tests" => CALLDIR set to "pkg"run_test_file("test-a.R")
callsset_call_wd("pkg/tests")
and changes directory to "tests" => CALLDIR not changedrun_test_file("test-a.R")
callsset_call_wd("")
on exit and changes directory to "tests" => CALLDIR set to ""run_test_file("test-b.R")
callsset_call_wd("pkg/tests")
and changes directory to "tests" => CALLDIR set to "pkg/tests"
I think the simplest solution would be:
set_call_wd(dir)
to pushdir
onto the back ofCALLDIR
andset_call_wd("")
to pop the back ofCALLDIR
- And get_call_wd() only return
CALLDIR[1]
Metadata
Metadata
Assignees
Labels
No labels