summaryrefslogtreecommitdiffstats
path: root/tests/fCmd.test
diff options
context:
space:
mode:
authorapnadkarni <apnmbx-wits@yahoo.com>2022-08-06 03:12:49 (GMT)
committerapnadkarni <apnmbx-wits@yahoo.com>2022-08-06 03:12:49 (GMT)
commit90b60f208406b3811bad8f7327b663239fd1eea7 (patch)
tree8ec303940d6d62b3b8cb7bd7b183d65a3a33cf1e /tests/fCmd.test
parent6fa6c0b20139268bc5455dcdd3172b187b375476 (diff)
downloadtcl-90b60f208406b3811bad8f7327b663239fd1eea7.zip
tcl-90b60f208406b3811bad8f7327b663239fd1eea7.tar.gz
tcl-90b60f208406b3811bad8f7327b663239fd1eea7.tar.bz2
Added file home command for (possible) Tcl 9 TIP 602 migration
Diffstat (limited to 'tests/fCmd.test')
-rw-r--r--tests/fCmd.test51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/fCmd.test b/tests/fCmd.test
index 13f3720..72a3cd5 100644
--- a/tests/fCmd.test
+++ b/tests/fCmd.test
@@ -2556,6 +2556,57 @@ test fCmd-30.3 {file readable on 'pagefile.sys'} -constraints {win notInCIenv} -
}
return $r
} -result {exists 1 readable 0 stat 0 {}}
+
+test fCmd-31.1 {file home} -body {
+ file home
+} -result [file join $::env(HOME)]
+test fCmd-31.2 {file home - obeys env} -setup {
+ set ::env(HOME) $::env(HOME)/xxx
+} -cleanup {
+ set ::env(HOME) [file dirname $::env(HOME)]
+} -body {
+ file home
+} -result [file join $::env(HOME) xxx]
+test fCmd-31.3 {file home - \ -> /} -constraints win -setup {
+ set saved $::env(HOME)
+ set ::env(HOME) C:\\backslash\\path
+} -cleanup {
+ set ::env(HOME) $saved
+} -body {
+ file home
+} -result C:/backslash/path
+test fCmd-31.4 {file home - error} -setup {
+ set saved $::env(HOME)
+ unset ::env(HOME)
+} -cleanup {
+ set ::env(HOME) $saved
+} -body {
+ file home
+} -returnCodes error -result {couldn't find HOME environment variable to expand path}
+test fCmd-31.5 {
+ file home - relative path. Following 8.x ~ expansion behavior, relative
+ paths are not made absolute
+} -setup {
+ set saved $::env(HOME)
+ set ::env(HOME) relative/path
+} -cleanup {
+ set ::env(HOME) $saved
+} -body {
+ file home
+} -result relative/path
+test fCmd-31.6 {file home USER} -body {
+ # Note - as in 8.x this form does NOT necessarily give same result as
+ # env(HOME) even when user is current user. Assume result contains user
+ # name, else not sure how to check
+ file home $::tcl_platform(user)
+} -match glob -result "*$::tcl_platform(user)*"
+test fCmd-31.6 {file home UNKNOWNUSER} -body {
+ file home nosuchuser
+} -returnCodes error -result {user "nosuchuser" doesn't exist}
+test fCmd-31.7 {file home extra arg} -body {
+ file home $::tcl_platform(user) arg
+} -returnCodes error -result {wrong # args: should be "file home ?user?"}
+
# cleanup
cleanup