Convert unnecessary usage of posix external utilities in tests to use native tcl...
[jimtcl.git] / tests / filecopy.test
blobfea3d334927a10e624c24005e3393a6bdfec6eb6
1 source [file dirname [info script]]/testing.tcl
3 needs constraint jim
4 needs cmd file
5 needs cmd exec
6 needs cmd parray tclcompat
8 cd [file dirname [info script]]
10 file mkdir tempdir
12 test filecopy-1.1 "Simple case" {
13         file copy testio.in tempfile
14 } {}
16 test filecopy-1.2 "Target exists" {
17         list [catch {file copy testio.in tempfile} msg] $msg
18 } {1 {error copying "testio.in" to "tempfile": file already exists}}
20 test filecopy-1.3 "Source doesn't exist" {
21         list [catch {file copy missing tempfile} msg] $msg
22 } {1 {missing: No such file or directory}}
24 test filecopy-1.4 "Can't write to target" {
25         list [catch {file copy testio.in tempdir} msg] $msg
26 } {1 {error copying "testio.in" to "tempdir": file already exists}}
28 test filecopy-1.5 "Source doesn't exist and can't write to target" {
29         list [catch {file copy missing tempdir} msg] $msg
30 } {1 {missing: No such file or directory}}
32 test filecopy-1.6 "Wrong args" {
33         list [catch {file copy onearg} msg] $msg
34 } {1 {wrong # args: should be "file copy ?-force? source dest"}}
36 test filecopy-1.7 "Wrong args" {
37         list [catch {file copy too many args here} msg] $msg
38 } {1 {wrong # args: should be "file copy ?-force? source dest"}}
40 test filecopy-1.8 "Wrong args" {
41         list [catch {file copy -blah testio.in tempfile} msg] $msg
42 } {1 {bad option "-blah": should be -force}}
44 file delete tempfile
46 test filecopy-2.1 "Simple case (-force)" {
47         file copy -force testio.in tempfile
48 } {}
50 test filecopy-2.2 "Target exists (-force)" {
51         file copy -force testio.in tempfile
52 } {}
54 test filecopy-2.3 "Source doesn't exist (-force)" {
55         list [catch {file copy -force missing tempfile} msg] $msg
56 } {1 {missing: No such file or directory}}
58 test filecopy-2.4 "Can't write to target (-force)" -body {
59         file copy -force testio.in tempdir
60 } -returnCodes error -match glob -result {tempdir: *}
62 test filecopy-2.5 "Source doesn't exist and can't write to target (-force)" {
63         list [catch {file copy -force missing tempdir} msg] $msg
64 } {1 {missing: No such file or directory}}
66 test filecopy-2.6 "Source and target identical (-force)" {
67         file copy -force tempfile tempfile
68         file size tempfile
69 } 16
71 file delete tempfile
72 file delete --force tempdir
74 testreport