os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/macFCmd.test
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
# This file tests the tclfCmd.c file.
sl@0
     2
#
sl@0
     3
# This file contains a collection of tests for one or more of the Tcl
sl@0
     4
# built-in commands.  Sourcing this file into Tcl runs the tests and
sl@0
     5
# generates output for errors.  No output means no errors were found.
sl@0
     6
#
sl@0
     7
# Copyright (c) 1997 Sun Microsystems, Inc.
sl@0
     8
# Copyright (c) 1998-1999 by Scriptics Corporation.
sl@0
     9
#
sl@0
    10
# See the file "license.terms" for information on usage and redistribution
sl@0
    11
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
sl@0
    12
#
sl@0
    13
# RCS: @(#) $Id: macFCmd.test,v 1.10 2002/07/05 10:38:43 dkf Exp $
sl@0
    14
#
sl@0
    15
sl@0
    16
if {[lsearch [namespace children] ::tcltest] == -1} {
sl@0
    17
    package require tcltest
sl@0
    18
    namespace import -force ::tcltest::*
sl@0
    19
}
sl@0
    20
sl@0
    21
# These tests really need to be run from a writable directory, which
sl@0
    22
# it is assumed [temporaryDirectory] is.
sl@0
    23
set oldcwd [pwd]
sl@0
    24
cd [temporaryDirectory]
sl@0
    25
sl@0
    26
catch {file delete -force foo.dir}
sl@0
    27
file mkdir foo.dir
sl@0
    28
if {[catch {file attributes foo.dir -readonly 1}]} {
sl@0
    29
    set ::tcltest::testConstraints(fileSharing) 0
sl@0
    30
    set ::tcltest::testConstraints(notFileSharing) 1
sl@0
    31
} else {
sl@0
    32
    set ::tcltest::testConstraints(fileSharing) 1
sl@0
    33
    set ::tcltest::testConstraints(notFileSharing) 0
sl@0
    34
}
sl@0
    35
file delete -force foo.dir
sl@0
    36
sl@0
    37
test macFCmd-1.1 {GetFileFinderAttributes - no file} {macOnly} {
sl@0
    38
    catch {file delete -force foo.file}
sl@0
    39
    list [catch {file attributes foo.file -creator} msg] $msg
sl@0
    40
} {1 {could not read "foo.file": no such file or directory}}
sl@0
    41
test macFCmd-1.2 {GetFileFinderAttributes - creator} {macOnly} {
sl@0
    42
    catch {file delete -force foo.file}
sl@0
    43
    catch {close [open foo.file w]}
sl@0
    44
    list [catch {file attributes foo.file -creator} msg] \
sl@0
    45
	    [regexp {MPW |CWIE} $msg] [file delete -force foo.file]
sl@0
    46
} {0 1 {}}
sl@0
    47
test macFCmd-1.3 {GetFileFinderAttributes - type} {macOnly} {
sl@0
    48
    catch {file delete -force foo.file}
sl@0
    49
    catch {close [open foo.file w]}
sl@0
    50
    list [catch {file attributes foo.file -type} msg] $msg \
sl@0
    51
	    [file delete -force foo.file]
sl@0
    52
} {0 TEXT {}}
sl@0
    53
test macFCmd-1.4 {GetFileFinderAttributes - not hidden} {macOnly} {
sl@0
    54
    catch {file delete -force foo.file}
sl@0
    55
    catch {close [open foo.file w]}
sl@0
    56
    list [catch {file attributes foo.file -hidden} msg] $msg \
sl@0
    57
	    [file delete -force foo.file]
sl@0
    58
} {0 0 {}}
sl@0
    59
test macFCmd-1.5 {GetFileFinderAttributes - hidden} {macOnly} {
sl@0
    60
    catch {file delete -force foo.file}
sl@0
    61
    catch {close [open foo.file w]}
sl@0
    62
    file attributes foo.file -hidden 1
sl@0
    63
    list [catch {file attributes foo.file -hidden} msg] $msg \
sl@0
    64
	    [file delete -force foo.file]
sl@0
    65
} {0 1 {}}
sl@0
    66
test macFCmd-1.6 {GetFileFinderAttributes - folder creator} {macOnly} {
sl@0
    67
    catch {file delete -force foo.dir}
sl@0
    68
    file mkdir foo.dir
sl@0
    69
    list [catch {file attributes foo.dir -creator} msg] $msg \
sl@0
    70
	    [file delete -force foo.dir]
sl@0
    71
} {0 Fldr {}}
sl@0
    72
test macFCmd-1.7 {GetFileFinderAttributes - folder type} {macOnly} {
sl@0
    73
    catch {file delete -force foo.dir}
sl@0
    74
    file mkdir foo.dir
sl@0
    75
    list [catch {file attributes foo.dir -type} msg] $msg \
sl@0
    76
	    [file delete -force foo.dir]
sl@0
    77
} {0 Fldr {}}
sl@0
    78
test macFCmd-1.8 {GetFileFinderAttributes - folder hidden} {macOnly} {
sl@0
    79
    catch {file delete -force foo.dir}
sl@0
    80
    file mkdir foo.dir
sl@0
    81
    list [catch {file attributes foo.dir -hidden} msg] $msg \
sl@0
    82
	    [file delete -force foo.dir]
sl@0
    83
} {0 0 {}}
sl@0
    84
sl@0
    85
test macFCmd-2.1 {GetFileReadOnly - bad file} {macOnly} {
sl@0
    86
    catch {file delete -force foo.file}
sl@0
    87
    list [catch {file attributes foo.file -readonly} msg] $msg
sl@0
    88
} {1 {could not read "foo.file": no such file or directory}}
sl@0
    89
test macFCmd-2.2 {GetFileReadOnly - file not read only} {macOnly} {
sl@0
    90
    catch {file delete -force foo.file}
sl@0
    91
    close [open foo.file w]
sl@0
    92
    list [catch {file attributes foo.file -readonly} msg] $msg \
sl@0
    93
	    [file delete -force foo.file]
sl@0
    94
} {0 0 {}}
sl@0
    95
test macFCmd-2.3 {GetFileReadOnly - file read only} {macOnly} {
sl@0
    96
    catch {file delete -force foo.file}
sl@0
    97
    close [open foo.file w]
sl@0
    98
    file attributes foo.file -readonly 1
sl@0
    99
    list [catch {file attributes foo.file -readonly} msg] $msg \
sl@0
   100
	    [file delete -force foo.file]
sl@0
   101
} {0 1 {}}
sl@0
   102
test macFCmd-2.4 {GetFileReadOnly - directory not read only} {macOnly} {
sl@0
   103
    catch {file delete -force foo.dir}
sl@0
   104
    file mkdir foo.dir
sl@0
   105
    list [catch {file attributes foo.dir -readonly} msg] $msg \
sl@0
   106
	    [file delete -force foo.dir]
sl@0
   107
} {0 0 {}}
sl@0
   108
test macFCmd-2.5 {GetFileReadOnly - directory read only} {macOnly fileSharing} {
sl@0
   109
    catch {file delete -force foo.dir}
sl@0
   110
    file mkdir foo.dir
sl@0
   111
    file attributes foo.dir -readonly 1
sl@0
   112
    list [catch {file attributes foo.dir -readonly} msg] $msg \
sl@0
   113
	    [file delete -force foo.dir]
sl@0
   114
} {0 1 {}}
sl@0
   115
sl@0
   116
test macFCmd-3.1 {SetFileFinderAttributes - bad file} {macOnly} {
sl@0
   117
    catch {file delete -force foo.file}
sl@0
   118
    list [catch {file attributes foo.file -creator FOOO} msg] $msg
sl@0
   119
} {1 {could not read "foo.file": no such file or directory}}
sl@0
   120
test macFCmd-3.2 {SetFileFinderAttributes - creator} {macOnly} {
sl@0
   121
    catch {file delete -force foo.file}
sl@0
   122
    close [open foo.file w]
sl@0
   123
    list [catch {file attributes foo.file -creator FOOO} msg] $msg \
sl@0
   124
	    [file attributes foo.file -creator] [file delete -force foo.file]
sl@0
   125
} {0 {} FOOO {}}
sl@0
   126
test macFCmd-3.3 {SetFileFinderAttributes - bad creator} {macOnly} {
sl@0
   127
    catch {file delete -force foo.file}
sl@0
   128
    close [open foo.file w]
sl@0
   129
    list [catch {file attributes foo.file -creator 0} msg] $msg \
sl@0
   130
	    [file delete -force foo.file]
sl@0
   131
} {1 {expected Macintosh OS type but got "0"} {}}
sl@0
   132
test macFCmd-3.4 {SetFileFinderAttributes - hidden} {macOnly} {
sl@0
   133
    catch {file delete -force foo.file}
sl@0
   134
    close [open foo.file w]
sl@0
   135
    list [catch {file attributes foo.file -hidden 1} msg] $msg \
sl@0
   136
	    [file attributes foo.file -hidden] [file delete -force foo.file]
sl@0
   137
} {0 {} 1 {}}
sl@0
   138
test macFCmd-3.5 {SetFileFinderAttributes - type} {macOnly} {
sl@0
   139
    catch {file delete -force foo.file}
sl@0
   140
    close [open foo.file w]
sl@0
   141
    list [catch {file attributes foo.file -type FOOO} msg] $msg \
sl@0
   142
	    [file attributes foo.file -type] [file delete -force foo.file]
sl@0
   143
} {0 {} FOOO {}}
sl@0
   144
test macFCmd-3.6 {SetFileFinderAttributes - bad type} {macOnly} {
sl@0
   145
    catch {file delete -force foo.file}
sl@0
   146
    close [open foo.file w]
sl@0
   147
    list [catch {file attributes foo.file -type 0} msg] $msg \
sl@0
   148
	    [file delete -force foo.file]
sl@0
   149
} {1 {expected Macintosh OS type but got "0"} {}}
sl@0
   150
test macFCmd-3.7 {SetFileFinderAttributes - directory} {macOnly} {
sl@0
   151
    catch {file delete -force foo.dir}
sl@0
   152
    file mkdir foo.dir
sl@0
   153
    list [catch {file attributes foo.dir -creator FOOO} msg] \
sl@0
   154
	    $msg [file delete -force foo.dir]
sl@0
   155
} {1 {cannot set -creator: "foo.dir" is a directory} {}}
sl@0
   156
sl@0
   157
test macFCmd-4.1 {SetFileReadOnly - bad file} {macOnly} {
sl@0
   158
    catch {file delete -force foo.file}
sl@0
   159
    list [catch {file attributes foo.file -readonly 1} msg] $msg
sl@0
   160
} {1 {could not read "foo.file": no such file or directory}}
sl@0
   161
test macFCmd-4.2 {SetFileReadOnly - file not readonly} {macOnly} {
sl@0
   162
    catch {file delete -force foo.file}
sl@0
   163
    close [open foo.file w]
sl@0
   164
    list [catch {file attributes foo.file -readonly 0} msg] \
sl@0
   165
	    $msg [file attributes foo.file -readonly] [file delete -force foo.file]
sl@0
   166
} {0 {} 0 {}}
sl@0
   167
test macFCmd-4.3 {SetFileReadOnly - file readonly} {macOnly} {
sl@0
   168
    catch {file delete -force foo.file}
sl@0
   169
    close [open foo.file w]
sl@0
   170
    list [catch {file attributes foo.file -readonly 1} msg] \
sl@0
   171
	    $msg [file attributes foo.file -readonly] [file delete -force foo.file]
sl@0
   172
} {0 {} 1 {}}
sl@0
   173
test macFCmd-4.4 {SetFileReadOnly - directory not readonly} \
sl@0
   174
	{macOnly fileSharing} {
sl@0
   175
    catch {file delete -force foo.dir}
sl@0
   176
    file mkdir foo.dir
sl@0
   177
    list [catch {file attributes foo.dir -readonly 0} msg] \
sl@0
   178
	    $msg [file attributes foo.dir -readonly] [file delete -force foo.dir]
sl@0
   179
} {0 {} 0 {}}
sl@0
   180
test macFCmd-4.5 {SetFileReadOnly - directory not readonly} \
sl@0
   181
	{macOnly notFileSharing} {
sl@0
   182
    catch {file delete -force foo.dir}
sl@0
   183
    file mkdir foo.dir
sl@0
   184
    list [catch {file attributes foo.dir -readonly 0} msg] $msg \
sl@0
   185
	    [file delete -force foo.dir]
sl@0
   186
} {1 {cannot set a directory to read-only when File Sharing is turned off} {}}
sl@0
   187
test macFCmd-4.6 {SetFileReadOnly - directory readonly} {macOnly fileSharing} {
sl@0
   188
    catch {file delete -force foo.dir}
sl@0
   189
    file mkdir foo.dir
sl@0
   190
    list [catch {file attributes foo.dir -readonly 1} msg] $msg \
sl@0
   191
	    [file attributes foo.dir -readonly] [file delete -force foo.dir]
sl@0
   192
} {0 {} 1 {}}
sl@0
   193
test macFCmd-4.7 {SetFileReadOnly - directory readonly} {macOnly notFileSharing} {
sl@0
   194
    catch {file delete -force foo.dir}
sl@0
   195
    file mkdir foo.dir
sl@0
   196
    list [catch {file attributes foo.dir -readonly 1} msg] $msg \
sl@0
   197
	    [file delete -force foo.dir]
sl@0
   198
} {1 {cannot set a directory to read-only when File Sharing is turned off} {}}
sl@0
   199
sl@0
   200
# cleanup
sl@0
   201
cd $oldcwd
sl@0
   202
::tcltest::cleanupTests
sl@0
   203
return