1 | # This file contains tests for the routines in the file tclUnixFile.c |
---|
2 | # |
---|
3 | # This file contains a collection of tests for one or more of the Tcl |
---|
4 | # built-in commands. Sourcing this file into Tcl runs the tests and |
---|
5 | # generates output for errors. No output means no errors were found. |
---|
6 | # |
---|
7 | # Copyright (c) 1998-1999 by Scriptics Corporation. |
---|
8 | # |
---|
9 | # See the file "license.terms" for information on usage and redistribution |
---|
10 | # of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
11 | # |
---|
12 | # RCS: @(#) $Id: unixFile.test,v 1.9 2004/06/23 15:36:58 dkf Exp $ |
---|
13 | |
---|
14 | if {[lsearch [namespace children] ::tcltest] == -1} { |
---|
15 | package require tcltest |
---|
16 | namespace import -force ::tcltest::* |
---|
17 | } |
---|
18 | |
---|
19 | testConstraint testfindexecutable [llength [info commands testfindexecutable]] |
---|
20 | |
---|
21 | set oldpwd [pwd] |
---|
22 | cd [temporaryDirectory] |
---|
23 | |
---|
24 | catch { |
---|
25 | set oldPath $env(PATH) |
---|
26 | file attributes [makeFile "" junk] -perm 0777 |
---|
27 | } |
---|
28 | set absPath [file join [temporaryDirectory] junk] |
---|
29 | |
---|
30 | test unixFile-1.1 {Tcl_FindExecutable} {testfindexecutable unix} { |
---|
31 | set env(PATH) "" |
---|
32 | testfindexecutable junk |
---|
33 | } $absPath |
---|
34 | test unixFile-1.2 {Tcl_FindExecutable} {testfindexecutable unix} { |
---|
35 | set env(PATH) "/dummy" |
---|
36 | testfindexecutable junk |
---|
37 | } {} |
---|
38 | test unixFile-1.3 {Tcl_FindExecutable} {testfindexecutable unix} { |
---|
39 | set env(PATH) "/dummy:[pwd]" |
---|
40 | testfindexecutable junk |
---|
41 | } $absPath |
---|
42 | test unixFile-1.4 {Tcl_FindExecutable} {testfindexecutable unix} { |
---|
43 | set env(PATH) "/dummy:" |
---|
44 | testfindexecutable junk |
---|
45 | } $absPath |
---|
46 | test unixFile-1.5 {Tcl_FindExecutable} {testfindexecutable unix} { |
---|
47 | set env(PATH) "/dummy:/dummy" |
---|
48 | testfindexecutable junk |
---|
49 | } {} |
---|
50 | test unixFile-1.6 {Tcl_FindExecutable} {testfindexecutable unix} { |
---|
51 | set env(PATH) "/dummy::/dummy" |
---|
52 | testfindexecutable junk |
---|
53 | } $absPath |
---|
54 | test unixFile-1.7 {Tcl_FindExecutable} {testfindexecutable unix} { |
---|
55 | set env(PATH) ":/dummy" |
---|
56 | testfindexecutable junk |
---|
57 | } $absPath |
---|
58 | |
---|
59 | # cleanup |
---|
60 | catch {set env(PATH) $oldPath} |
---|
61 | removeFile junk |
---|
62 | cd $oldpwd |
---|
63 | ::tcltest::cleanupTests |
---|
64 | return |
---|