Fossil SCM

Update test_start_server procedure to return the port as well because fossil server dynamically allocates a port.

andybradford 2016-10-14 19:04 trunk
Commit b66d5bca70d9052c06c50607a49e81b7d2653f33
+12 -4
--- test/tester.tcl
+++ test/tester.tcl
@@ -749,30 +749,38 @@
749749
}
750750
return [string range $out 1 end]
751751
}
752752
753753
# This procedure executes the "fossil server" command. The return value
754
-# is the new process identifier. The varName argument refers to a variable
754
+# is a list comprised of the new process identifier and the port on which
755
+# the server started. The varName argument refers to a variable
755756
# where the "stop argument" is to be stored. This value must eventually be
756757
# passed to the [test_stop_server] procedure.
757758
proc test_start_server { repository {varName ""} } {
758
- global fossilexe
759
+ global fossilexe tempHomePath
759760
set command [list exec $fossilexe server]
760761
if {[string length $varName] > 0} {
761762
upvar 1 $varName stopArg
762763
}
763764
if {$::tcl_platform(platform) eq "windows"} {
764765
set stopArg [file join [getTemporaryPath] [appendArgs \
765766
[string trim [clock seconds] -] _ [getSeqNo] .stopper]]
766767
lappend command --stopper $stopArg
767768
}
768
- lappend command $repository &
769
+ set tmpFile [file join $tempHomePath [appendArgs \
770
+ uvtest_ [string trim [clock seconds] -] _ [getSeqNo]]].out
771
+ lappend command $repository >&$tmpFile &
769772
set pid [eval $command]
770773
if {$::tcl_platform(platform) ne "windows"} {
771774
set stopArg $pid
772775
}
773
- return $pid
776
+ after 1000; # output might not be there yet
777
+ set output [read_file $tmpFile]
778
+ catch {file delete $tmpFile}
779
+ set port 8080; # return the default port just in case
780
+ regexp {Listening.*TCP port (\d+)} $output m port
781
+ return [list $pid $port]
774782
}
775783
776784
# This procedure stops a Fossil server instance that was previously started
777785
# by the [test_start_server] procedure. The value of the "stop argument"
778786
# will vary by platform as will the exact method used to stop the server.
779787
--- test/tester.tcl
+++ test/tester.tcl
@@ -749,30 +749,38 @@
749 }
750 return [string range $out 1 end]
751 }
752
753 # This procedure executes the "fossil server" command. The return value
754 # is the new process identifier. The varName argument refers to a variable
 
755 # where the "stop argument" is to be stored. This value must eventually be
756 # passed to the [test_stop_server] procedure.
757 proc test_start_server { repository {varName ""} } {
758 global fossilexe
759 set command [list exec $fossilexe server]
760 if {[string length $varName] > 0} {
761 upvar 1 $varName stopArg
762 }
763 if {$::tcl_platform(platform) eq "windows"} {
764 set stopArg [file join [getTemporaryPath] [appendArgs \
765 [string trim [clock seconds] -] _ [getSeqNo] .stopper]]
766 lappend command --stopper $stopArg
767 }
768 lappend command $repository &
 
 
769 set pid [eval $command]
770 if {$::tcl_platform(platform) ne "windows"} {
771 set stopArg $pid
772 }
773 return $pid
 
 
 
 
 
774 }
775
776 # This procedure stops a Fossil server instance that was previously started
777 # by the [test_start_server] procedure. The value of the "stop argument"
778 # will vary by platform as will the exact method used to stop the server.
779
--- test/tester.tcl
+++ test/tester.tcl
@@ -749,30 +749,38 @@
749 }
750 return [string range $out 1 end]
751 }
752
753 # This procedure executes the "fossil server" command. The return value
754 # is a list comprised of the new process identifier and the port on which
755 # the server started. The varName argument refers to a variable
756 # where the "stop argument" is to be stored. This value must eventually be
757 # passed to the [test_stop_server] procedure.
758 proc test_start_server { repository {varName ""} } {
759 global fossilexe tempHomePath
760 set command [list exec $fossilexe server]
761 if {[string length $varName] > 0} {
762 upvar 1 $varName stopArg
763 }
764 if {$::tcl_platform(platform) eq "windows"} {
765 set stopArg [file join [getTemporaryPath] [appendArgs \
766 [string trim [clock seconds] -] _ [getSeqNo] .stopper]]
767 lappend command --stopper $stopArg
768 }
769 set tmpFile [file join $tempHomePath [appendArgs \
770 uvtest_ [string trim [clock seconds] -] _ [getSeqNo]]].out
771 lappend command $repository >&$tmpFile &
772 set pid [eval $command]
773 if {$::tcl_platform(platform) ne "windows"} {
774 set stopArg $pid
775 }
776 after 1000; # output might not be there yet
777 set output [read_file $tmpFile]
778 catch {file delete $tmpFile}
779 set port 8080; # return the default port just in case
780 regexp {Listening.*TCP port (\d+)} $output m port
781 return [list $pid $port]
782 }
783
784 # This procedure stops a Fossil server instance that was previously started
785 # by the [test_start_server] procedure. The value of the "stop argument"
786 # will vary by platform as will the exact method used to stop the server.
787
--- test/unversioned.test
+++ test/unversioned.test
@@ -305,19 +305,19 @@
305305
unversioned5\.txt$} [normalize_result]]}
306306
307307
###############################################################################
308308
309309
set password [string trim [clock seconds] -]
310
-set remote [appendArgs http://uvtester: $password @localhost:8080/]
311310
312311
fossil user new uvtester "Unversioned Test User" $password
313312
fossil user capabilities uvtester oy
314313
315314
###############################################################################
316315
317
-set pid [test_start_server $repository stopArg]
318
-puts [appendArgs "Started Fossil server, pid \"" $pid \".]
316
+foreach {pid port} [test_start_server $repository stopArg] {}
317
+puts [appendArgs "Started Fossil server, pid \"" $pid \" ", port \"" $port \".]
318
+set remote [appendArgs http://uvtester: $password @localhost: $port /]
319319
320320
###############################################################################
321321
322322
set clientDir [file join $tempPath [appendArgs \
323323
uvtest_ [string trim [clock seconds] -] _ [getSeqNo]]]
324324
--- test/unversioned.test
+++ test/unversioned.test
@@ -305,19 +305,19 @@
305 unversioned5\.txt$} [normalize_result]]}
306
307 ###############################################################################
308
309 set password [string trim [clock seconds] -]
310 set remote [appendArgs http://uvtester: $password @localhost:8080/]
311
312 fossil user new uvtester "Unversioned Test User" $password
313 fossil user capabilities uvtester oy
314
315 ###############################################################################
316
317 set pid [test_start_server $repository stopArg]
318 puts [appendArgs "Started Fossil server, pid \"" $pid \".]
 
319
320 ###############################################################################
321
322 set clientDir [file join $tempPath [appendArgs \
323 uvtest_ [string trim [clock seconds] -] _ [getSeqNo]]]
324
--- test/unversioned.test
+++ test/unversioned.test
@@ -305,19 +305,19 @@
305 unversioned5\.txt$} [normalize_result]]}
306
307 ###############################################################################
308
309 set password [string trim [clock seconds] -]
 
310
311 fossil user new uvtester "Unversioned Test User" $password
312 fossil user capabilities uvtester oy
313
314 ###############################################################################
315
316 foreach {pid port} [test_start_server $repository stopArg] {}
317 puts [appendArgs "Started Fossil server, pid \"" $pid \" ", port \"" $port \".]
318 set remote [appendArgs http://uvtester: $password @localhost: $port /]
319
320 ###############################################################################
321
322 set clientDir [file join $tempPath [appendArgs \
323 uvtest_ [string trim [clock seconds] -] _ [getSeqNo]]]
324

Keyboard Shortcuts

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