Fossil

Check-in [1a4e87dc]
Login

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

Overview
Comment:Extracted the logic that was in tester.tcl's new outside_fossil_repo proc to the global level which just saves the result to a global variable so the logic doesn't have to be re-run for each test that relies on it. The result doesn't change from one call to the next, as you'd hope for a proc without parameters.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | wrap-run_in_checkout
Files: files | file ages | folders
SHA3-256:1a4e87dcc118aa5c0e10602a4a9b65c89368e8bd895a6603e7d94cae491022aa
User & Date: wyoung 2018-09-03 02:57:47
Context
2018-09-03
06:13
Fixed a Tcl logic error committed with [33efa2fa]. check-in: 02430597 user: wyoung tags: wrap-run_in_checkout
02:57
Extracted the logic that was in tester.tcl's new outside_fossil_repo proc to the global level which just saves the result to a global variable so the logic doesn't have to be re-run for each test that relies on it. The result doesn't change from one call to the next, as you'd hope for a proc without parameters. check-in: 1a4e87dc user: wyoung tags: wrap-run_in_checkout
00:40
Replaced most of the direct calls to run_in_checkout from within the test suite with one of two wrapper functions that skip those tests when you run "make test" outside a Fossil repository checkout directory, such as from a directory containing an unpacked source release tarball. (The two remaining direct calls to that proc from test/*.test are preceded by a check that skips the whole file they're in, since that whole file does nothing else.) This is being checked in on a branch because it is not yet thoroughly tested, yet I need the checkpoint. check-in: 33efa2fa user: wyoung tags: wrap-run_in_checkout
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to test/tester.tcl.

29
30
31
32
33
34
35
36
37
38




39
40
41
42
43
44
45
...
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
...
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567

set testfiledir [file normalize [file dirname [info script]]]
set testrundir [pwd]
set testdir [file normalize [file dirname $argv0]]
set fossilexe [file normalize [lindex $argv 0]]
set is_windows [expr {$::tcl_platform(platform) eq "windows"}]

if {$is_windows && \
    [string length [file extension $fossilexe]] == 0} {
  append fossilexe .exe




}

set argv [lrange $argv 1 end]

set i [lsearch $argv -keep]
if {$i>=0} {
  set KEEP 1
................................................................................
}

# Run the given command script inside the Fossil source repo checkout.
#
# Callers of this function must ensure two things:
#
# 1. This test run is in fact being done from within a Fossil repo
#    checkout directory.  If you are unsure, call outside_fossil_repo
#    or one of the test_* wrappers below it which do call it first.
#
#    As a rule, you should not be calling this function directly!
#
# 2. The test does NOT modify the Fossil checkout tree in any way.
proc run_in_checkout { script {dir ""} } {
  if {[string length $dir] == 0} {set dir $::testfiledir}
  set savedPwd [pwd]; cd $dir
................................................................................
  set code [catch {
    uplevel 1 $script
  } result]
  cd $savedPwd; unset savedPwd
  return -code $code $result
}

# Return zero if we're being run from within a Fossil repo checkout.
# Used to skip uses of run_in_checkout so that those tests don't fail
# when run elsewhere, such as from a release tarball checkout.
proc outside_fossil_repo {} {
  if {$::is_windows} {
    return ![file exists "$::testfiledir\\..\\_FOSSIL_"]
  } else {
    return ![file exists "$::testfiledir/../.fslckout"]
  }
}

# Wrapper for the above function pair.  The tscript parameter is an
# optional post-run test script.  Some callers choose instead to put
# the tests inline with the rscript commands.
#
# Be sure to adhere to the requirements of run_in_checkout!
proc test_block_in_checkout { name rscript {tscript ""} } {
  if {[outside_fossil_repo]} {
    puts "Skipping $name test: not in Fossil repo checkout."
  } else {
    run_in_checkout $rscript
    if {[string length $tscript] == 0} {
      return ""
    } else {
      set code [catch {







|
|
|
>
>
>
>







 







|
|







 







<
<
<
<
<
<
<
<
<
<
<






|







29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
...
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
...
540
541
542
543
544
545
546











547
548
549
550
551
552
553
554
555
556
557
558
559
560

set testfiledir [file normalize [file dirname [info script]]]
set testrundir [pwd]
set testdir [file normalize [file dirname $argv0]]
set fossilexe [file normalize [lindex $argv 0]]
set is_windows [expr {$::tcl_platform(platform) eq "windows"}]

if {$::is_windows} {
  if {[string length [file extension $fossilexe]] == 0} {
    append fossilexe .exe
  }
  set outside_fossil_repo ![file exists "$::testfiledir\\..\\_FOSSIL_"]
} else {
  set outside_fossil_repo ![file exists "$::testfiledir/../.fslckout"]
}

set argv [lrange $argv 1 end]

set i [lsearch $argv -keep]
if {$i>=0} {
  set KEEP 1
................................................................................
}

# Run the given command script inside the Fossil source repo checkout.
#
# Callers of this function must ensure two things:
#
# 1. This test run is in fact being done from within a Fossil repo
#    checkout directory.  If you are unsure, test $::outside_fossil_repo
#    or call one of the test_* wrappers below which do that for you.
#
#    As a rule, you should not be calling this function directly!
#
# 2. The test does NOT modify the Fossil checkout tree in any way.
proc run_in_checkout { script {dir ""} } {
  if {[string length $dir] == 0} {set dir $::testfiledir}
  set savedPwd [pwd]; cd $dir
................................................................................
  set code [catch {
    uplevel 1 $script
  } result]
  cd $savedPwd; unset savedPwd
  return -code $code $result
}












# Wrapper for the above function pair.  The tscript parameter is an
# optional post-run test script.  Some callers choose instead to put
# the tests inline with the rscript commands.
#
# Be sure to adhere to the requirements of run_in_checkout!
proc test_block_in_checkout { name rscript {tscript ""} } {
  if {$::outside_fossil_repo} {
    puts "Skipping $name test: not in Fossil repo checkout."
  } else {
    run_in_checkout $rscript
    if {[string length $tscript] == 0} {
      return ""
    } else {
      set code [catch {

Changes to test/th1-docs.test.

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#   http://www.hwaci.com/drh/
#
############################################################################
#
# TH1 Docs
#

if {[outside_fossil_repo]} {
  puts "Skipping th1-docs-* tests: not in Fossil repo checkout."
  test_cleanup_then_return
}

fossil test-th-eval "hasfeature th1Docs"

if {[normalize_result] ne "1"} {







|







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#   http://www.hwaci.com/drh/
#
############################################################################
#
# TH1 Docs
#

if {$::outside_fossil_repo} {
  puts "Skipping th1-docs-* tests: not in Fossil repo checkout."
  test_cleanup_then_return
}

fossil test-th-eval "hasfeature th1Docs"

if {[normalize_result] ne "1"} {