diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/fCmd.test | 104 | ||||
-rw-r--r-- | tests/fileSystem.test | 75 | ||||
-rw-r--r-- | tests/winFile.test | 14 |
3 files changed, 160 insertions, 33 deletions
diff --git a/tests/fCmd.test b/tests/fCmd.test index 9b3d997..b04262f 100644 --- a/tests/fCmd.test +++ b/tests/fCmd.test @@ -10,7 +10,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: fCmd.test,v 1.11 2001/09/04 18:06:34 vincentdarley Exp $ +# RCS: @(#) $Id: fCmd.test,v 1.12 2002/06/13 09:40:00 vincentdarley Exp $ # if {[lsearch [namespace children] ::tcltest] == -1} { @@ -2163,6 +2163,108 @@ test fCmd-27.6 {TclFileAttrsCmd - setting more than one option} {foundGroup} { list [catch {eval file attributes foo.tmp [lrange $attrs 0 3]} msg] $msg [file delete -force -- foo.tmp] } {0 {} {}} +if {[string equal testfilelink [info commands testfilelink]]} { + tcltest::testConstraint testfilelink 1 + + if {[string equal $tcl_platform(platform) "windows"]} { + if {[string index $tcl_platform(osVersion) 0] >= 5 \ + && ([lindex [file system [temporaryDirectory]] 1] == "NTFS")} { + tcltest::testConstraint linkDirectory 1 + tcltest::testConstraint linkFile 1 + } else { + tcltest::testConstraint linkDirectory 0 + tcltest::testConstraint linkFile 0 + } + } else { + tcltest::testConstraint linkFile 1 + tcltest::testConstraint linkDirectory 1 + } + +} else { + tcltest::testConstraint testfilelink 0 + tcltest::testConstraint linkDirectory 0 + tcltest::testConstraint linkFile 0 +} + +test fCmd-28.1 {testfilelink} {testfilelink} { + list [catch {testfilelink} msg] $msg +} {1 {wrong # args: should be "testfilelink source ?target?"}} + +test fCmd-28.2 {testfilelink} {testfilelink} { + list [catch {testfilelink a b c d} msg] $msg +} {1 {wrong # args: should be "testfilelink source ?target?"}} + +catch {file delete -force abc.dir} +catch {file delete -force abc2.dir} +makeDirectory abc.dir +makeDirectory abc2.dir +makeFile contents abc.file +makeFile contents abc2.file + +test fCmd-28.3 {testfilelink} {linkDirectory} { + list [catch {testfilelink abc.dir abc2.dir} msg] $msg +} {1 {could not create link from "abc.dir" to "abc2.dir": file already exists}} + +test fCmd-28.4 {testfilelink} {linkFile} { + list [catch {testfilelink abc.file abc2.file} msg] $msg +} {1 {could not create link from "abc.file" to "abc2.file": file already exists}} + +test fCmd-28.5 {testfilelink} {linkFile} { + file delete -force abc.link + list [catch {testfilelink abc.link abc.file} msg] $msg +} {0 abc.file} + +catch {file delete -force abc.link} + +test fCmd-28.6 {testfilelink} {linkDirectory} { + file delete -force abc.link + list [catch {testfilelink abc.link abc2.doesnt} msg] $msg +} {1 {could not create link from "abc.link" to "abc2.doesnt": no such file or directory}} + +test fCmd-28.7 {testfilelink} {linkDirectory} { + file delete -force abc.link + list [catch {testfilelink abc.link abc.dir} msg] $msg +} {0 abc.dir} + +test fCmd-28.7.1 {testfilelink} {linkDirectory} { + # duplicate link throws error + list [catch {testfilelink abc.link abc.dir} msg] $msg +} {1 {could not create link from "abc.link" to "abc.dir": file already exists}} + +test fCmd-28.8 {testfilelink: deletes link not dir} {linkDirectory} { + file delete -force abc.link + list [file exists abc.link] [file exists abc.dir] +} {0 1} + +test fCmd-28.9 {testfilelink: copies link not dir} {linkDirectory} { + file delete -force abc.link + testfilelink abc.link abc.dir + file copy abc.link abc2.link + list [file type abc2.link] [file tail [testfilelink abc2.link]] +} {link abc.dir} + +file delete -force abc.link +file delete -force abc2.link + +file copy abc.file abc.dir +file copy abc2.file abc.dir + +test fCmd-28.10 {testfilelink: glob inside link} {linkDirectory} { + file delete -force abc.link + testfilelink abc.link abc.dir + glob -dir abc.link -tails * +} {abc.file abc2.file} + +test fCmd-28.11 {testfilelink: glob -type l} {linkDirectory} { + glob -dir [pwd] -type l -tails abc* +} {abc.link} + +test fCmd-28.12 {testfilelink: glob -type d} {linkDirectory} { + lsort [glob -dir [pwd] -type d -tails abc*] +} [lsort [list abc.link abc.dir abc2.dir]] + +file delete -force abc.link + # cleanup cleanup ::tcltest::cleanupTests diff --git a/tests/fileSystem.test b/tests/fileSystem.test index 5a0713a..eb3f6cb 100644 --- a/tests/fileSystem.test +++ b/tests/fileSystem.test @@ -12,57 +12,78 @@ package require tcltest namespace eval ::tcl::test::fileSystem { - namespace import ::tcltest::cleanupTests - namespace import ::tcltest::makeDirectory - namespace import ::tcltest::makeFile - namespace import ::tcltest::removeDirectory - namespace import ::tcltest::removeFile - namespace import ::tcltest::test + catch { + namespace import ::tcltest::cleanupTests + namespace import ::tcltest::makeDirectory + namespace import ::tcltest::makeFile + namespace import ::tcltest::removeDirectory + namespace import ::tcltest::removeFile + namespace import ::tcltest::test + } + + catch { + file delete -force link.file + file delete -force dir.link + file delete -force [file join dir.file linkinside.file] + } makeFile "test file" gorp.file makeDirectory dir.file makeFile "test file in directory" [file join dir.file inside.file] -# It would be good to be able to make these work on MacOS too. -# If we added 'file link from to' we could easily do that. -catch {exec ln -s gorp.file link.file} -catch {exec ln -s inside.file dir.file/linkinside.file} -catch {exec ln -s dir.file dir.link} +if {[catch { + testfilelink link.file gorp.file + testfilelink \ + [file join dir.file linkinside.file] \ + [file join dir.file inside.file] + testfilelink dir.link dir.file +}]} { + tcltest::testConstraint links 0 +} else { + tcltest::testConstraint links 1 +} -test filesystem-1.0 {link normalisation} {unixOnly} { +test filesystem-1.0 {link normalisation} {links} { string equal [file normalize gorp.file] [file normalize link.file] } {0} -test filesystem-1.1 {link normalisation} {unixOnly} { +test filesystem-1.1 {link normalisation} {links} { string equal [file normalize dir.file] [file normalize dir.link] } {0} -test filesystem-1.2 {link normalisation} {unixOnly} { - string equal [file normalize gorp.file/foo] [file normalize link.file/foo] +test filesystem-1.2 {link normalisation} {links macOrUnix} { + string equal [file normalize [file join gorp.file foo]] \ + [file normalize [file join link.file foo]] } {1} -test filesystem-1.3 {link normalisation} {unixOnly} { - string equal [file normalize dir.file/foo] [file normalize dir.link/foo] +test filesystem-1.3 {link normalisation} {links} { + string equal [file normalize [file join dir.file foo]] \ + [file normalize [file join dir.link foo]] } {1} -test filesystem-1.4 {link normalisation} {unixOnly} { - string equal [file normalize dir.file/inside.file] [file normalize dir.link/inside.file] +test filesystem-1.4 {link normalisation} {links} { + string equal [file normalize [file join dir.file inside.file]] \ + [file normalize [file join dir.link inside.file]] } {1} -test filesystem-1.5 {link normalisation} {unixOnly} { - string equal [file normalize dir.file/linkinside.file] [file normalize dir.file/linkinside.file] +test filesystem-1.5 {link normalisation} {links} { + string equal [file normalize [file join dir.file linkinside.file]] \ + [file normalize [file join dir.file linkinside.file]] } {1} -test filesystem-1.6 {link normalisation} {unixOnly} { - string equal [file normalize dir.file/linkinside.file] [file normalize dir.link/inside.file] +test filesystem-1.6 {link normalisation} {links} { + string equal [file normalize [file join dir.file linkinside.file]] \ + [file normalize [file join dir.link inside.file]] } {0} -test filesystem-1.7 {link normalisation} {unixOnly} { - string equal [file normalize dir.link/linkinside.file/foo] [file normalize dir.file/inside.file/foo] +test filesystem-1.7 {link normalisation} {links macOrUnix} { + string equal [file normalize [file join dir.link linkinside.file foo]] \ + [file normalize [file join dir.file inside.file foo]] } {1} -test filesystem-1.8 {link normalisation} {unixOnly} { - string equal [file normalize dir.file/linkinside.filefoo] [file normalize dir.link/inside.filefoo] +test filesystem-1.8 {link normalisation} {links} { + string equal [file normalize [file join dir.file linkinside.filefoo]] \ + [file normalize [file join dir.link inside.filefoo]] } {0} file delete -force link.file dir.link diff --git a/tests/winFile.test b/tests/winFile.test index 0cf76e2..c0b26e3 100644 --- a/tests/winFile.test +++ b/tests/winFile.test @@ -10,7 +10,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: winFile.test,v 1.7 2002/05/02 20:15:20 vincentdarley Exp $ +# RCS: @(#) $Id: winFile.test,v 1.8 2002/06/13 09:40:00 vincentdarley Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -65,10 +65,14 @@ test winFile-2.2 {TclpMatchFiles: case sensitivity} {pcOnly} { test winFile-3.1 {file system} {pcOnly} { set res "volume types ok" foreach vol [file volumes] { - if {![string equal [lindex [file system $vol] 1] [testvolumetype $vol]]} { - set res "For $vol, we found [file system $vol]\ - and [testvolumetype $vol] are different" - break + # Have to catch in case there is a removable drive (CDROM, floppy) + # with nothing in it. + catch { + if {![string equal [lindex [file system $vol] 1] [testvolumetype $vol]]} { + set res "For $vol, we found [file system $vol]\ + and [testvolumetype $vol] are different" + break + } } } set res |