You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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".
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") calls set_call_wd("pkg") and changes directory to "tests" => CALLDIR set to "pkg"
run_test_file("test-a.R") calls set_call_wd("pkg/tests") and changes directory to "tests" => CALLDIR not changed
run_test_file("test-a.R") calls set_call_wd("") on exit and changes directory to "tests" => CALLDIR set to ""
run_test_file("test-b.R") calls set_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 push dir onto the back of CALLDIR and
set_call_wd("") to pop the back of CALLDIR
And get_call_wd() only return CALLDIR[1]
The text was updated successfully, but these errors were encountered:
First, assume that
getwd()
returns "pkg". Then if I run tests viarun_test_dir("tests")
, and usecall_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
CALLDIR[1]
The text was updated successfully, but these errors were encountered: