Fossil

Check-in [b0081d97]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Further revise the 'test_start_server' and 'test_stop_server' test suite helper procedures to make it possible to actually delete the temporary output-capture file on Windows.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:b0081d9786a665d4587a0ba5c01ef76d95c688ae
User & Date: mistachkin 2016-10-15 04:56:58
Context
2016-10-15
05:02
Coding style, removing superfluous 'then' clauses from tester.tcl. check-in: 4946b5b1 user: mistachkin tags: trunk
04:56
Further revise the 'test_start_server' and 'test_stop_server' test suite helper procedures to make it possible to actually delete the temporary output-capture file on Windows. check-in: b0081d97 user: mistachkin tags: trunk
2016-10-14
22:49
Add the --localhost argument to the fossil server command invoked by test_start_server in test/tester.tcl. This change causes the server to only bind to localhost:8080, which does not trigger the Windows Firewall to panic about a program attempting to communicate with the world. Tested on a 64-bit binary built from VS2010, and a 32-bit binaray build from MinGW GCC 4.2.7, both under Windows 10 Pro. I expect the flag works and is harmless on other platforms. check-in: 6c8cec73 user: rberteig tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to test/tester.tcl.

772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789

790
791
792
793
794
795

796
797
798
799
800
801
802
803
...
804
805
806
807
808
809
810



811
812
813
814
815
816
817
...
824
825
826
827
828
829
830



831
832
833
834
835
836
837
  lappend command $repository >&$outFileName &
  set pid [eval $command]
  if {$::tcl_platform(platform) ne "windows"} {
    set stopArg $pid
  }
  after 1000; # output might not be there yet
  set output [read_file $outFileName]
  catch {file delete $outFileName}
  if {![regexp {Listening.*TCP port (\d+)} $output dummy port]} {
    puts stdout "Could not detect Fossil server port, using default..."
    set port 8080; # return the default port just in case
  }
  return [list $pid $port]
}

# This procedure stops a Fossil server instance that was previously started
# by the [test_start_server] procedure.  The value of the "stop argument"
# will vary by platform as will the exact method used to stop the server.

proc test_stop_server { stopArg pid } {
  if {$::tcl_platform(platform) eq "windows"} {
    #
    # NOTE: On Windows, the "stop argument" must be the name of a file
    #       that does NOT already exist.
    #

    if {![file exists $stopArg] && \
        [catch {write_file $stopArg [clock seconds]}] == 0} then {
      while {1} {
        if {[catch {
          #
          # NOTE: Using the TaskList utility requires Windows XP or
          #       later.
          #
................................................................................
          exec tasklist.exe /FI "PID eq $pid"
        } result] != 0 || ![regexp -- " $pid " $result]} then {
          break
        }
        after 1000; # wait a bit...
      }
      file delete $stopArg



      return true
    }
  } else {
    #
    # NOTE: On Unix, the "stop argument" must be an integer identifier
    #       that refers to an existing process.
    #
................................................................................
          #       Unix?  It should be, it's POSIX.
          #
          exec ps -p $pid
        } result] != 0 || ![regexp -- "(?:^$pid| $pid) " $result]} then {
          break
        }
        after 1000; # wait a bit...



      }
      return true
    }
  }
  return false
}








<




|





>
|





>
|







 







>
>
>







 







>
>
>







772
773
774
775
776
777
778

779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
...
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
...
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
  lappend command $repository >&$outFileName &
  set pid [eval $command]
  if {$::tcl_platform(platform) ne "windows"} {
    set stopArg $pid
  }
  after 1000; # output might not be there yet
  set output [read_file $outFileName]

  if {![regexp {Listening.*TCP port (\d+)} $output dummy port]} {
    puts stdout "Could not detect Fossil server port, using default..."
    set port 8080; # return the default port just in case
  }
  return [list $pid $port $outFileName]
}

# This procedure stops a Fossil server instance that was previously started
# by the [test_start_server] procedure.  The value of the "stop argument"
# will vary by platform as will the exact method used to stop the server.
# The fileName argument is the name of a temporary output file to delete.
proc test_stop_server { stopArg pid fileName } {
  if {$::tcl_platform(platform) eq "windows"} {
    #
    # NOTE: On Windows, the "stop argument" must be the name of a file
    #       that does NOT already exist.
    #
    if {[string length $stopArg] > 0 && \
        ![file exists $stopArg] && \
        [catch {write_file $stopArg [clock seconds]}] == 0} then {
      while {1} {
        if {[catch {
          #
          # NOTE: Using the TaskList utility requires Windows XP or
          #       later.
          #
................................................................................
          exec tasklist.exe /FI "PID eq $pid"
        } result] != 0 || ![regexp -- " $pid " $result]} then {
          break
        }
        after 1000; # wait a bit...
      }
      file delete $stopArg
      if {[string length $fileName] > 0} then {
        file delete $fileName
      }
      return true
    }
  } else {
    #
    # NOTE: On Unix, the "stop argument" must be an integer identifier
    #       that refers to an existing process.
    #
................................................................................
          #       Unix?  It should be, it's POSIX.
          #
          exec ps -p $pid
        } result] != 0 || ![regexp -- "(?:^$pid| $pid) " $result]} then {
          break
        }
        after 1000; # wait a bit...
      }
      if {[string length $fileName] > 0} then {
        file delete $fileName
      }
      return true
    }
  }
  return false
}

Changes to test/unversioned.test.

309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
...
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
set password [string trim [clock seconds] -]

fossil user new uvtester "Unversioned Test User" $password
fossil user capabilities uvtester oy

###############################################################################

foreach {pid port} [test_start_server $repository stopArg] {}
puts [appendArgs "Started Fossil server, pid \"" $pid \" ", port \"" $port \".]
set remote [appendArgs http://uvtester: $password @localhost: $port /]

###############################################################################

set clientDir [file join $tempPath [appendArgs \
    uvtest_ [string trim [clock seconds] -] _ [getSeqNo]]]
................................................................................

cd $savedPwd; unset savedPwd
file delete -force $clientDir
puts [appendArgs "Now in server directory \"" [pwd] \".]

###############################################################################

set stopped [test_stop_server $stopArg $pid]

puts [appendArgs \
    [expr {$stopped ? "Stopped" : "Could not stop"}] \
    " Fossil server, pid \"" $pid "\", using argument \"" \
    $stopArg \".]

###############################################################################







|







 







|







309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
...
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
set password [string trim [clock seconds] -]

fossil user new uvtester "Unversioned Test User" $password
fossil user capabilities uvtester oy

###############################################################################

foreach {pid port outTmpFile} [test_start_server $repository stopArg] {}
puts [appendArgs "Started Fossil server, pid \"" $pid \" ", port \"" $port \".]
set remote [appendArgs http://uvtester: $password @localhost: $port /]

###############################################################################

set clientDir [file join $tempPath [appendArgs \
    uvtest_ [string trim [clock seconds] -] _ [getSeqNo]]]
................................................................................

cd $savedPwd; unset savedPwd
file delete -force $clientDir
puts [appendArgs "Now in server directory \"" [pwd] \".]

###############################################################################

set stopped [test_stop_server $stopArg $pid $outTmpFile]

puts [appendArgs \
    [expr {$stopped ? "Stopped" : "Could not stop"}] \
    " Fossil server, pid \"" $pid "\", using argument \"" \
    $stopArg \".]

###############################################################################