Fossil SCM
Update test_start_server procedure to return the port as well because fossil server dynamically allocates a port.
Commit
b66d5bca70d9052c06c50607a49e81b7d2653f33
Parent
4a0c94838a1d532…
2 files changed
+12
-4
+3
-3
+12
-4
| --- test/tester.tcl | ||
| +++ test/tester.tcl | ||
| @@ -749,30 +749,38 @@ | ||
| 749 | 749 | } |
| 750 | 750 | return [string range $out 1 end] |
| 751 | 751 | } |
| 752 | 752 | |
| 753 | 753 | # 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 | |
| 755 | 756 | # where the "stop argument" is to be stored. This value must eventually be |
| 756 | 757 | # passed to the [test_stop_server] procedure. |
| 757 | 758 | proc test_start_server { repository {varName ""} } { |
| 758 | - global fossilexe | |
| 759 | + global fossilexe tempHomePath | |
| 759 | 760 | set command [list exec $fossilexe server] |
| 760 | 761 | if {[string length $varName] > 0} { |
| 761 | 762 | upvar 1 $varName stopArg |
| 762 | 763 | } |
| 763 | 764 | if {$::tcl_platform(platform) eq "windows"} { |
| 764 | 765 | set stopArg [file join [getTemporaryPath] [appendArgs \ |
| 765 | 766 | [string trim [clock seconds] -] _ [getSeqNo] .stopper]] |
| 766 | 767 | lappend command --stopper $stopArg |
| 767 | 768 | } |
| 768 | - lappend command $repository & | |
| 769 | + set tmpFile [file join $tempHomePath [appendArgs \ | |
| 770 | + uvtest_ [string trim [clock seconds] -] _ [getSeqNo]]].out | |
| 771 | + lappend command $repository >&$tmpFile & | |
| 769 | 772 | set pid [eval $command] |
| 770 | 773 | if {$::tcl_platform(platform) ne "windows"} { |
| 771 | 774 | set stopArg $pid |
| 772 | 775 | } |
| 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] | |
| 774 | 782 | } |
| 775 | 783 | |
| 776 | 784 | # This procedure stops a Fossil server instance that was previously started |
| 777 | 785 | # by the [test_start_server] procedure. The value of the "stop argument" |
| 778 | 786 | # will vary by platform as will the exact method used to stop the server. |
| 779 | 787 |
| --- 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 |
+3
-3
| --- test/unversioned.test | ||
| +++ test/unversioned.test | ||
| @@ -305,19 +305,19 @@ | ||
| 305 | 305 | unversioned5\.txt$} [normalize_result]]} |
| 306 | 306 | |
| 307 | 307 | ############################################################################### |
| 308 | 308 | |
| 309 | 309 | set password [string trim [clock seconds] -] |
| 310 | -set remote [appendArgs http://uvtester: $password @localhost:8080/] | |
| 311 | 310 | |
| 312 | 311 | fossil user new uvtester "Unversioned Test User" $password |
| 313 | 312 | fossil user capabilities uvtester oy |
| 314 | 313 | |
| 315 | 314 | ############################################################################### |
| 316 | 315 | |
| 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 /] | |
| 319 | 319 | |
| 320 | 320 | ############################################################################### |
| 321 | 321 | |
| 322 | 322 | set clientDir [file join $tempPath [appendArgs \ |
| 323 | 323 | uvtest_ [string trim [clock seconds] -] _ [getSeqNo]]] |
| 324 | 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 | 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 |