summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authordas <das>2003-05-14 19:21:20 (GMT)
committerdas <das>2003-05-14 19:21:20 (GMT)
commite7e62365449aec7d4e02ab0a58d7b185a74342e8 (patch)
tree18a23b38b5ab18b3714c78cd1f0f131855938b1f /tests
parent12f7a06929318bdfae5af285f1502aa2f5d4aa86 (diff)
downloadtcl-e7e62365449aec7d4e02ab0a58d7b185a74342e8.zip
tcl-e7e62365449aec7d4e02ab0a58d7b185a74342e8.tar.gz
tcl-e7e62365449aec7d4e02ab0a58d7b185a74342e8.tar.bz2
Implementation of TIP 118:
* generic/tclFCmd.c (TclFileAttrsCmd): return the list of attributes that can be retrieved without error for a given file, instead of aborting the whole command when any error occurs. * unix/tclUnixFCmd.c: added support for new file attributes and for copying Mac OS X file attributes & resource fork during [file copy]. * generic/tclInt.decls: added declarations of new external commands needed by new file attributes support in tclUnixFCmd.c. * macosx/tclMacOSXFCmd.c (new): Mac OS X specific implementation of new file attributes and of attribute & resource fork copying. * mac/tclMacFCmd.c: added implementation of -rsrclength attribute & fixes to other attributes for consistency with OSX implementation. * mac/tclMacResource.c: fixes to OSType handling. * doc/file.n: documentation of [file attributes] changes. * unix/configure.in: check for APIs needed by new file attributes. * unix/Makefile.in: * unix/tcl.m4: added new platform specifc tclMacOSXFCmd.c source. * unix/configure: * generic/tclStubInit.c: * generic/tclIntPlatDecls.h: regen. * tools/genStubs.tcl: fixes to completely broken code trying to prevent overlap of "aqua", "macosx", "x11" and "unix" stub entries. * tests/unixFCmd.test: added tests of -readonly attribute. * tests/macOSXFCmd.test (new): tests of macosx file attributes and of preservation of attributes & resource fork during [file copy]. * tests/macFCmd.test: restore -readonly attribute of test dir, as otherwise its removal can fail on unices supporting -readonly.
Diffstat (limited to 'tests')
-rw-r--r--tests/macFCmd.test3
-rw-r--r--tests/macOSXFCmd.test143
-rw-r--r--tests/unixFCmd.test40
3 files changed, 184 insertions, 2 deletions
diff --git a/tests/macFCmd.test b/tests/macFCmd.test
index a6c7fa0..f50e7b9 100644
--- a/tests/macFCmd.test
+++ b/tests/macFCmd.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: macFCmd.test,v 1.10 2002/07/05 10:38:43 dkf Exp $
+# RCS: @(#) $Id: macFCmd.test,v 1.11 2003/05/14 19:21:24 das Exp $
#
if {[lsearch [namespace children] ::tcltest] == -1} {
@@ -31,6 +31,7 @@ if {[catch {file attributes foo.dir -readonly 1}]} {
} else {
set ::tcltest::testConstraints(fileSharing) 1
set ::tcltest::testConstraints(notFileSharing) 0
+ file attributes foo.dir -readonly 0
}
file delete -force foo.dir
diff --git a/tests/macOSXFCmd.test b/tests/macOSXFCmd.test
new file mode 100644
index 0000000..0bc6d30
--- /dev/null
+++ b/tests/macOSXFCmd.test
@@ -0,0 +1,143 @@
+# This file tests the tclMacOSXFCmd.c file.
+#
+# This file contains a collection of tests for one or more of the Tcl
+# built-in commands. Sourcing this file into Tcl runs the tests and
+# generates output for errors. No output means no errors were found.
+#
+# Copyright (c) 2003 Tcl Core Team.
+#
+# See the file "license.terms" for information on usage and redistribution
+# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+#
+# RCS: @(#) $Id: macOSXFCmd.test,v 1.1 2003/05/14 19:21:25 das Exp $
+#
+
+if {[lsearch [namespace children] ::tcltest] == -1} {
+ package require tcltest
+ namespace import -force ::tcltest::*
+}
+
+# These tests really need to be run from a writable directory, which
+# it is assumed [temporaryDirectory] is.
+set oldcwd [pwd]
+cd [temporaryDirectory]
+
+# check whether macosx file attributes are supported
+set ::tcltest::testConstraints(macosxFileAttr) 0
+if {$tcl_platform(platform) eq "unix" && \
+ $tcl_platform(os) eq "Darwin"} {
+ catch {file delete -force -- foo.test}
+ close [open foo.test w]
+ catch {
+ file attributes foo.test -creator
+ set ::tcltest::testConstraints(macosxFileAttr) 1
+ }
+ file delete -force -- foo.test
+}
+
+test macOSXFCmd-1.1 {MacOSXGetFileAttribute - file not found} {macosxFileAttr notRoot} {
+ catch {file delete -force -- foo.test}
+ list [catch {file attributes foo.test -creator} msg] $msg
+} {1 {could not read "foo.test": no such file or directory}}
+test macOSXFCmd-1.2 {MacOSXGetFileAttribute - creator} {macosxFileAttr notRoot} {
+ catch {file delete -force -- foo.test}
+ close [open foo.test w]
+ list [catch {file attributes foo.test -creator} msg] $msg \
+ [file delete -force -- foo.test]
+} {0 {} {}}
+test macOSXFCmd-1.3 {MacOSXGetFileAttribute - type} {macosxFileAttr notRoot} {
+ catch {file delete -force -- foo.test}
+ close [open foo.test w]
+ list [catch {file attributes foo.test -type} msg] $msg \
+ [file delete -force -- foo.test]
+} {0 {} {}}
+test macOSXFCmd-1.4 {MacOSXGetFileAttribute - hidden} {macosxFileAttr notRoot} {
+ catch {file delete -force -- foo.test}
+ close [open foo.test w]
+ list [catch {file attributes foo.test -hidden} msg] $msg \
+ [file delete -force -- foo.test]
+} {0 0 {}}
+test macOSXFCmd-1.5 {MacOSXGetFileAttribute - rsrclength} {macosxFileAttr notRoot} {
+ catch {file delete -force -- foo.test}
+ close [open foo.test w]
+ list [catch {file attributes foo.test -rsrclength} msg] $msg \
+ [file delete -force -- foo.test]
+} {0 0 {}}
+
+test macOSXFCmd-2.1 {MacOSXSetFileAttribute - file not found} {macosxFileAttr notRoot} {
+ catch {file delete -force -- foo.test}
+ list [catch {file attributes foo.test -creator FOOO} msg] $msg
+} {1 {could not read "foo.test": no such file or directory}}
+test macOSXFCmd-2.2 {MacOSXSetFileAttribute - creator} {macosxFileAttr notRoot} {
+ catch {file delete -force -- foo.test}
+ close [open foo.test w]
+ list [catch {file attributes foo.test -creator FOOO} msg] $msg \
+ [catch {file attributes foo.test -creator} msg] $msg \
+ [file delete -force -- foo.test]
+} {0 {} 0 FOOO {}}
+test macOSXFCmd-2.3 {MacOSXSetFileAttribute - empty creator} {macosxFileAttr notRoot} {
+ catch {file delete -force -- foo.test}
+ close [open foo.test w]
+ list [catch {file attributes foo.test -creator {}} msg] $msg \
+ [catch {file attributes foo.test -creator} msg] $msg \
+ [file delete -force -- foo.test]
+} {0 {} 0 {} {}}
+test macOSXFCmd-2.4 {MacOSXSetFileAttribute - type} {macosxFileAttr notRoot} {
+ catch {file delete -force -- foo.test}
+ close [open foo.test w]
+ list [catch {file attributes foo.test -type FOOO} msg] $msg \
+ [catch {file attributes foo.test -type} msg] $msg \
+ [file delete -force -- foo.test]
+} {0 {} 0 FOOO {}}
+test macOSXFCmd-2.5 {MacOSXSetFileAttribute - empty type} {macosxFileAttr notRoot} {
+ catch {file delete -force -- foo.test}
+ close [open foo.test w]
+ list [catch {file attributes foo.test -type {}} msg] $msg \
+ [catch {file attributes foo.test -type} msg] $msg \
+ [file delete -force -- foo.test]
+} {0 {} 0 {} {}}
+test macOSXFCmd-2.6 {MacOSXSetFileAttribute - hidden} {macosxFileAttr notRoot} {
+ catch {file delete -force -- foo.test}
+ close [open foo.test w]
+ list [catch {file attributes foo.test -hidden 1} msg] $msg \
+ [catch {file attributes foo.test -hidden} msg] $msg \
+ [file delete -force -- foo.test]
+} {0 {} 0 1 {}}
+test macOSXFCmd-2.7 {MacOSXSetFileAttribute - rsrclength} {macosxFileAttr notRoot} {
+ catch {file delete -force -- foo.test}
+ close [open foo.test w]
+ catch {
+ set f [open foo.test/rsrc w]
+ fconfigure $f -translation lf -eofchar {}
+ puts -nonewline $f "foo"
+ close $f
+ }
+ list [catch {file attributes foo.test -rsrclength} msg] $msg \
+ [catch {file attributes foo.test -rsrclength 0} msg] $msg \
+ [catch {file attributes foo.test -rsrclength} msg] $msg \
+ [file delete -force -- foo.test]
+} {0 3 0 {} 0 0 {}}
+
+test macOSXFCmd-3.1 {MacOSXCopyFileAttributes} {macosxFileAttr notRoot} {
+ catch {file delete -force -- foo.test}
+ catch {file delete -force -- bar.test}
+ close [open foo.test w]
+ catch {
+ file attributes foo.test -creator FOOO -type FOOO -hidden 1
+ set f [open foo.test/rsrc w]
+ fconfigure $f -translation lf -eofchar {}
+ puts -nonewline $f "foo"
+ close $f
+ file copy foo.test bar.test
+ }
+ list [catch {file attributes bar.test -creator} msg] $msg \
+ [catch {file attributes bar.test -type} msg] $msg \
+ [catch {file attributes bar.test -hidden} msg] $msg \
+ [catch {file attributes bar.test -rsrclength} msg] $msg \
+ [file delete -force -- foo.test bar.test]
+} {0 FOOO 0 FOOO 0 1 0 3 {}}
+
+# cleanup
+cd $oldcwd
+::tcltest::cleanupTests
+return
diff --git a/tests/unixFCmd.test b/tests/unixFCmd.test
index 574c5cc..e863d3b 100644
--- a/tests/unixFCmd.test
+++ b/tests/unixFCmd.test
@@ -9,7 +9,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: unixFCmd.test,v 1.18 2003/04/11 16:00:02 vincentdarley Exp $
+# RCS: @(#) $Id: unixFCmd.test,v 1.19 2003/05/14 19:21:25 das Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
@@ -325,6 +325,44 @@ test unixFCmd-18.1 {Unix pwd} {nonPortable unixOnly notRoot} {
set r
} {1 {error getting working directory name:}}
+# check whether -readonly attribute is supported
+set ::tcltest::testConstraints(readonlyAttr) 0
+if {$tcl_platform(platform) == "unix"} {
+ catch {file delete -force -- foo.test}
+ close [open foo.test w]
+ catch {
+ file attributes foo.test -readonly
+ set ::tcltest::testConstraints(readonlyAttr) 1
+ }
+ file delete -force -- foo.test
+}
+
+test unixFCmd-19.1 {GetReadOnlyAttribute - file not found} {unixOnly notRoot readonlyAttr} {
+ catch {file delete -force -- foo.test}
+ list [catch {file attributes foo.test -readonly} msg] $msg
+} {1 {could not read "foo.test": no such file or directory}}
+test unixFCmd-19.2 {GetReadOnlyAttribute} {unixOnly notRoot readonlyAttr} {
+ catch {file delete -force -- foo.test}
+ close [open foo.test w]
+ list [catch {file attribute foo.test -readonly} msg] $msg \
+ [file delete -force -- foo.test]
+} {0 0 {}}
+
+test unixFCmd-20.1 {SetReadOnlyAttribute} {unixOnly notRoot readonlyAttr} {
+ catch {file delete -force -- foo.test}
+ close [open foo.test w]
+ list [catch {file attributes foo.test -readonly 1} msg] $msg \
+ [catch {file attribute foo.test -readonly} msg] $msg \
+ [catch {file delete -force -- foo.test}] \
+ [catch {file attributes foo.test -readonly 0} msg] $msg \
+ [catch {file attribute foo.test -readonly} msg] $msg \
+ [file delete -force -- foo.test]
+} {0 {} 0 1 1 0 {} 0 0 {}}
+test unixFCmd-20.2 {SetReadOnlyAttribute} {unixOnly notRoot readonlyAttr} {
+ catch {file delete -force -- foo.test}
+ list [catch {file attributes foo.test -readonly 1} msg] $msg
+} {1 {could not read "foo.test": no such file or directory}}
+
# cleanup
cleanup
cd $oldcwd