File: tclTestDriver.tcl.in

package info (click to toggle)
insighttoolkit4 4.13.3withdata-dfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 489,260 kB
  • sloc: cpp: 557,342; ansic: 146,850; fortran: 34,788; python: 16,572; sh: 2,187; lisp: 2,070; tcl: 993; java: 362; perl: 200; makefile: 129; csh: 81; pascal: 69; xml: 19; ruby: 10
file content (178 lines) | stat: -rw-r--r-- 4,498 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
## 0:only return value
## 1:minimal output
## 2:full output
set DEBUG 2


####################
##swig and tcl directories
##
####################
set SWIG_DIR "@CONFIG_ITK_WRAP_TCL_SWIG_DIR@"
set TCL_DIR "@CONFIG_ITK_WRAP_TCL_DIR@"


####################
##Define executables
##-Currently this is a full path.
##-Careful with win platforms to get this right
####################

####################
##Could eventually be replaced with cmake variables??
####################
set TCL_EXEC "@CONFIG_WRAP_ITK_ITKWISH_DIR@/itkwish"
set IMG_COMPARE_EXEC "@IMAGE_COMPARE@"

####################
##This assumes full paths - could be rewritten if needed.
####################
if {![file exists $TCL_EXEC]} {
        if {$DEBUG} {
                puts "Tcl Exec -- $TCL_EXEC -- is not valid"
        }
        exit 1
}

if {![file exists $IMG_COMPARE_EXEC]} {
        if {$DEBUG} {
                puts "Image Comapre Exec -- $IMG_COMPARE_EXEC -- is not valid"
        }
        exit 1
}


####################
##Setup paths
##
####################

switch -glob $tcl_platform(os) {
        Darwin* {
                if {[info exists env(DYLD_LIBRARY_PATH)]} {
                        set env(DYLD_LIBRARY_PATH) "$SWIG_DIR:$env(DYLD_LIBRARY_PATH)"
                } else {
                        set env(DYLD_LIBRARY_PATH) "$SWIG_DIR"
                }
        }
        Win* {
                if {[info exists env(PATH)]} {
                        set env(PATH) "$SWIG_DIR;$env(PATH)"
                } else {
                        set env(PATH) "$SWIG_DIR"
                }
        }
        default {
                if {[info exists env(LD_LIBRARY_PATH)]} {
                        set env(LD_LIBRARY_PATH) "$SWIG_DIR:$env(LD_LIBRARY_PATH)"
                } else {
                        set env(LD_LIBRARY_PATH) "$SWIG_DIR"
                }
        }
}


if {[info exists env(TCLLIBPATH)]} {
        set env(TCLLIBPATH) "$TCL_DIR $env(TCLLIBPATH)"
} else {
        set env(TCLLIBPATH) "$TCL_DIR"
}




##Skip -- if it exists
if {[lindex $argv 0] == "--"} {
        set argv [lrange $argv 1 end]
        incr argc -1
}

##Find all of the comparisons and store them
set compareList {}
set argList {}
for {set i 0} {$i < $argc} {incr i} {

        if {[lindex $argv $i] == "--compare"} {
                if {[expr $i+2] >= $argc} {
                        if {$DEBUG} {
                                puts "Syntax error: Consider rewriting"
                        }
                        exit 1
                }
                incr i
                set inputImage [lindex $argv $i]
                incr i
                set outputImage [lindex $argv $i]
                lappend compareList [list $inputImage $outputImage]
        } else {
                lappend argList [lindex $argv $i]
        }
}

if {[llength $argList] < 1} {
        if {$DEBUG} {
                puts "You must give a command to run"
        }
        exit 1
}


if {![file exists [lindex $argList 0]]} {
        if {$DEBUG} {
                puts "Tcl script -- [lindex $argList 0] -- is not valid"
        }
        exit 1
}

if {$DEBUG} {
        puts -nonewline "Running test...."
}
if {[catch {eval "exec $TCL_EXEC [lindex $argList " "]"} err]} {
        if {$DEBUG} {
                puts "Failed with Error:"
        }
        if {$DEBUG > 1} {
                puts "=================="
                puts $err
                puts "=================="
        }
        exit 1
} else {
        if {$DEBUG} {
                puts "Succesful with Result:"
        }
        if {$DEBUG > 1} {
                puts "=================="
                puts $err
                puts "=================="
        }
}


foreach compare $compareList {
        if {$DEBUG} {
                puts -nonewline "Running comparisons..."
        }
        if {[catch {eval "exec $IMG_COMPARE_EXEC [join $compare " "]"} err]} {
                if {$DEBUG} {
                        puts "Failed with Error:"
                }
        if {$DEBUG > 1} {
                puts "=================="
                puts $err
                puts "=================="
        }
                exit 1
        } else {
                if {$DEBUG} {
                        puts "Succesful with Result:"
                }
                if {$DEBUG > 1} {
                        puts "=================="
                        puts $err
                        puts "=================="
                }
        }
}

exit 0