Debian Codegraph @

tests/unixFile.test

raw
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 if {"::tcltest" ni [namespace children]} {
13 package require tcltest 2.5
14 namespace import -force ::tcltest::*
15 }
16
17 ::tcltest::loadTestedCommands
18 catch [list package require -exact Tcltest [info patchlevel]]
19
20 testConstraint testfindexecutable [llength [info commands testfindexecutable]]
21
22 set oldpwd [pwd]
23 cd [temporaryDirectory]
24
25 catch {
26 set oldPath $env(PATH)
27 file attributes [makeFile "" junk] -perm 0o777
28 }
29 set absPath [file join [temporaryDirectory] junk]
30
31 test unixFile-1.1 {Tcl_FindExecutable} {testfindexecutable unix} {
32 set env(PATH) ""
33 testfindexecutable junk
34 } $absPath
35 test unixFile-1.2 {Tcl_FindExecutable} {testfindexecutable unix} {
36 set env(PATH) "/dummy"
37 testfindexecutable junk
38 } {}
39 test unixFile-1.3 {Tcl_FindExecutable} {testfindexecutable unix} {
40 set env(PATH) "/dummy:[pwd]"
41 testfindexecutable junk
42 } $absPath
43 test unixFile-1.4 {Tcl_FindExecutable} {testfindexecutable unix} {
44 set env(PATH) "/dummy:"
45 testfindexecutable junk
46 } $absPath
47 test unixFile-1.5 {Tcl_FindExecutable} {testfindexecutable unix} {
48 set env(PATH) "/dummy:/dummy"
49 testfindexecutable junk
50 } {}
51 test unixFile-1.6 {Tcl_FindExecutable} {testfindexecutable unix} {
52 set env(PATH) "/dummy::/dummy"
53 testfindexecutable junk
54 } $absPath
55 test unixFile-1.7 {Tcl_FindExecutable} {testfindexecutable unix} {
56 set env(PATH) ":/dummy"
57 testfindexecutable junk
58 } $absPath
59
60 # cleanup
61 catch {set env(PATH) $oldPath}
62 removeFile junk
63 cd $oldpwd
64 ::tcltest::cleanupTests
65 return