Fossil SCM

Cached the result of "$tcl_platform(platform) eq "windows"" in test/tester.tcl and replaced all of the repetitions of this expression with a test of the variable.

wyoung 2018-09-02 23:05 trunk
Commit 2e4143aa4b8800dc7b6453bc612386371a5b4960e9a26dcebdd5121e417da3ed
1 file changed +8 -7
+8 -7
--- test/tester.tcl
+++ test/tester.tcl
@@ -29,12 +29,13 @@
2929
3030
set testfiledir [file normalize [file dirname [info script]]]
3131
set testrundir [pwd]
3232
set testdir [file normalize [file dirname $argv0]]
3333
set fossilexe [file normalize [lindex $argv 0]]
34
+set is_windows [expr {$::tcl_platform(platform) eq "windows"}]
3435
35
-if {$tcl_platform(platform) eq "windows" && \
36
+if {$is_windows && \
3637
[string length [file extension $fossilexe]] == 0} {
3738
append fossilexe .exe
3839
}
3940
4041
set argv [lrange $argv 1 end]
@@ -443,11 +444,11 @@
443444
if {![info exists ::tempKeepHome]} {delete_temporary_home}
444445
}
445446
446447
proc delete_temporary_home {} {
447448
if {$::KEEP} {return}; # All cleanup disabled?
448
- if {$::tcl_platform(platform) eq "windows"} {
449
+ if {$::is_windows} {
449450
robust_delete [file join $::tempHomePath _fossil]
450451
} else {
451452
robust_delete [file join $::tempHomePath .fossil]
452453
}
453454
robust_delete $::tempHomePath
@@ -628,11 +629,11 @@
628629
}
629630
630631
#
631632
# NOTE: On non-Windows systems, fallback to /tmp if it is usable.
632633
#
633
- if {$::tcl_platform(platform) ne "windows"} {
634
+ if {!$::is_windows} {
634635
set value /tmp
635636
636637
if {[file exists $value] && [file isdirectory $value]} {
637638
return $value
638639
}
@@ -800,21 +801,21 @@
800801
global fossilexe tempPath
801802
set command [list exec $fossilexe server --localhost]
802803
if {[string length $varName] > 0} {
803804
upvar 1 $varName stopArg
804805
}
805
- if {$::tcl_platform(platform) eq "windows"} {
806
+ if {$::is_windows} {
806807
set stopArg [file join [getTemporaryPath] [appendArgs \
807808
[string trim [clock seconds] -] _ [getSeqNo] .stopper]]
808809
lappend command --stopper $stopArg
809810
}
810811
set outFileName [file join $tempPath [appendArgs \
811812
fossil_server_ [string trim [clock seconds] -] _ \
812813
[getSeqNo]]].out
813814
lappend command $repository >&$outFileName &
814815
set pid [eval $command]
815
- if {$::tcl_platform(platform) ne "windows"} {
816
+ if {!$::is_windows} {
816817
set stopArg $pid
817818
}
818819
after 1000; # output might not be there yet
819820
set output [read_file $outFileName]
820821
if {![regexp {Listening.*TCP port (\d+)} $output dummy port]} {
@@ -827,11 +828,11 @@
827828
# This procedure stops a Fossil server instance that was previously started
828829
# by the [test_start_server] procedure. The value of the "stop argument"
829830
# will vary by platform as will the exact method used to stop the server.
830831
# The fileName argument is the name of a temporary output file to delete.
831832
proc test_stop_server { stopArg pid fileName } {
832
- if {$::tcl_platform(platform) eq "windows"} {
833
+ if {$::is_windows} {
833834
#
834835
# NOTE: On Windows, the "stop argument" must be the name of a file
835836
# that does NOT already exist.
836837
#
837838
if {[string length $stopArg] > 0 && \
@@ -954,11 +955,11 @@
954955
return [lindex [split [normalize_result] \n] end-2]
955956
}
956957
957958
set tempPath [getTemporaryPath]
958959
959
-if {$tcl_platform(platform) eq "windows"} {
960
+if {$is_windows} {
960961
set tempPath [string map [list \\ /] $tempPath]
961962
}
962963
963964
if {[catch {
964965
set tempFile [file join $tempPath temporary.txt]
965966
--- test/tester.tcl
+++ test/tester.tcl
@@ -29,12 +29,13 @@
29
30 set testfiledir [file normalize [file dirname [info script]]]
31 set testrundir [pwd]
32 set testdir [file normalize [file dirname $argv0]]
33 set fossilexe [file normalize [lindex $argv 0]]
 
34
35 if {$tcl_platform(platform) eq "windows" && \
36 [string length [file extension $fossilexe]] == 0} {
37 append fossilexe .exe
38 }
39
40 set argv [lrange $argv 1 end]
@@ -443,11 +444,11 @@
443 if {![info exists ::tempKeepHome]} {delete_temporary_home}
444 }
445
446 proc delete_temporary_home {} {
447 if {$::KEEP} {return}; # All cleanup disabled?
448 if {$::tcl_platform(platform) eq "windows"} {
449 robust_delete [file join $::tempHomePath _fossil]
450 } else {
451 robust_delete [file join $::tempHomePath .fossil]
452 }
453 robust_delete $::tempHomePath
@@ -628,11 +629,11 @@
628 }
629
630 #
631 # NOTE: On non-Windows systems, fallback to /tmp if it is usable.
632 #
633 if {$::tcl_platform(platform) ne "windows"} {
634 set value /tmp
635
636 if {[file exists $value] && [file isdirectory $value]} {
637 return $value
638 }
@@ -800,21 +801,21 @@
800 global fossilexe tempPath
801 set command [list exec $fossilexe server --localhost]
802 if {[string length $varName] > 0} {
803 upvar 1 $varName stopArg
804 }
805 if {$::tcl_platform(platform) eq "windows"} {
806 set stopArg [file join [getTemporaryPath] [appendArgs \
807 [string trim [clock seconds] -] _ [getSeqNo] .stopper]]
808 lappend command --stopper $stopArg
809 }
810 set outFileName [file join $tempPath [appendArgs \
811 fossil_server_ [string trim [clock seconds] -] _ \
812 [getSeqNo]]].out
813 lappend command $repository >&$outFileName &
814 set pid [eval $command]
815 if {$::tcl_platform(platform) ne "windows"} {
816 set stopArg $pid
817 }
818 after 1000; # output might not be there yet
819 set output [read_file $outFileName]
820 if {![regexp {Listening.*TCP port (\d+)} $output dummy port]} {
@@ -827,11 +828,11 @@
827 # This procedure stops a Fossil server instance that was previously started
828 # by the [test_start_server] procedure. The value of the "stop argument"
829 # will vary by platform as will the exact method used to stop the server.
830 # The fileName argument is the name of a temporary output file to delete.
831 proc test_stop_server { stopArg pid fileName } {
832 if {$::tcl_platform(platform) eq "windows"} {
833 #
834 # NOTE: On Windows, the "stop argument" must be the name of a file
835 # that does NOT already exist.
836 #
837 if {[string length $stopArg] > 0 && \
@@ -954,11 +955,11 @@
954 return [lindex [split [normalize_result] \n] end-2]
955 }
956
957 set tempPath [getTemporaryPath]
958
959 if {$tcl_platform(platform) eq "windows"} {
960 set tempPath [string map [list \\ /] $tempPath]
961 }
962
963 if {[catch {
964 set tempFile [file join $tempPath temporary.txt]
965
--- test/tester.tcl
+++ test/tester.tcl
@@ -29,12 +29,13 @@
29
30 set testfiledir [file normalize [file dirname [info script]]]
31 set testrundir [pwd]
32 set testdir [file normalize [file dirname $argv0]]
33 set fossilexe [file normalize [lindex $argv 0]]
34 set is_windows [expr {$::tcl_platform(platform) eq "windows"}]
35
36 if {$is_windows && \
37 [string length [file extension $fossilexe]] == 0} {
38 append fossilexe .exe
39 }
40
41 set argv [lrange $argv 1 end]
@@ -443,11 +444,11 @@
444 if {![info exists ::tempKeepHome]} {delete_temporary_home}
445 }
446
447 proc delete_temporary_home {} {
448 if {$::KEEP} {return}; # All cleanup disabled?
449 if {$::is_windows} {
450 robust_delete [file join $::tempHomePath _fossil]
451 } else {
452 robust_delete [file join $::tempHomePath .fossil]
453 }
454 robust_delete $::tempHomePath
@@ -628,11 +629,11 @@
629 }
630
631 #
632 # NOTE: On non-Windows systems, fallback to /tmp if it is usable.
633 #
634 if {!$::is_windows} {
635 set value /tmp
636
637 if {[file exists $value] && [file isdirectory $value]} {
638 return $value
639 }
@@ -800,21 +801,21 @@
801 global fossilexe tempPath
802 set command [list exec $fossilexe server --localhost]
803 if {[string length $varName] > 0} {
804 upvar 1 $varName stopArg
805 }
806 if {$::is_windows} {
807 set stopArg [file join [getTemporaryPath] [appendArgs \
808 [string trim [clock seconds] -] _ [getSeqNo] .stopper]]
809 lappend command --stopper $stopArg
810 }
811 set outFileName [file join $tempPath [appendArgs \
812 fossil_server_ [string trim [clock seconds] -] _ \
813 [getSeqNo]]].out
814 lappend command $repository >&$outFileName &
815 set pid [eval $command]
816 if {!$::is_windows} {
817 set stopArg $pid
818 }
819 after 1000; # output might not be there yet
820 set output [read_file $outFileName]
821 if {![regexp {Listening.*TCP port (\d+)} $output dummy port]} {
@@ -827,11 +828,11 @@
828 # This procedure stops a Fossil server instance that was previously started
829 # by the [test_start_server] procedure. The value of the "stop argument"
830 # will vary by platform as will the exact method used to stop the server.
831 # The fileName argument is the name of a temporary output file to delete.
832 proc test_stop_server { stopArg pid fileName } {
833 if {$::is_windows} {
834 #
835 # NOTE: On Windows, the "stop argument" must be the name of a file
836 # that does NOT already exist.
837 #
838 if {[string length $stopArg] > 0 && \
@@ -954,11 +955,11 @@
955 return [lindex [split [normalize_result] \n] end-2]
956 }
957
958 set tempPath [getTemporaryPath]
959
960 if {$is_windows} {
961 set tempPath [string map [list \\ /] $tempPath]
962 }
963
964 if {[catch {
965 set tempFile [file join $tempPath temporary.txt]
966

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button