-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding path expansion tests for tractor.session
- Loading branch information
1 parent
631a5d8
commit 2fbaff8
Showing
3 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
reportr::setOutputLevel(Info) | ||
options(reportrStderrLevel=reportr::OL$Fatal) | ||
|
||
# Fake session path (including tractor subdirectory to reduce repetition) | ||
fsp <- normalizePath(tempdir()) | ||
fstp <- file.path(fsp, "tractor") | ||
dir.create(fstp, recursive=TRUE) | ||
|
||
resolvePath <- function (path, ...) { | ||
path <- gsub("FSP", fsp, path, perl=TRUE) | ||
structure(tractor.base::resolvePath(path, ...), names=NULL) | ||
} | ||
|
||
wd <- getwd() | ||
on.exit(setwd(wd)) | ||
|
||
# Unambiguous image name | ||
expect_equal(resolvePath("FSP@fa"), file.path(fstp,"diffusion","dti_FA")) | ||
|
||
# Indexed image name | ||
expect_equal(resolvePath("FSP@eigenvalue",index=2), file.path(fstp,"diffusion","dti_eigval2")) | ||
|
||
# Directory path | ||
expect_equal(resolvePath("FSP@diffusion/"), file.path(fstp,"diffusion")) | ||
|
||
# Ambiguous image name, requiring subdirectory to be specified | ||
expect_equal(resolvePath("FSP@diffusion/data"), file.path(fstp,"diffusion","data")) | ||
expect_equal(resolvePath("FSP@functional/data"), file.path(fstp,"functional","data")) | ||
|
||
# Non-image path, relying on fallback | ||
expect_equal(resolvePath("FSP@diffusion/directions.txt",index=2), file.path(fstp,"diffusion","directions.txt")) | ||
|
||
# Shorthand for when the session directory is the current directory | ||
setwd(fsp) | ||
expect_equal(resolvePath("@MD"), file.path(fstp,"diffusion","dti_MD")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
if ( requireNamespace("tinytest", quietly=TRUE) ){ | ||
tinytest::test_package("tractor.session") | ||
} | ||
|