summaryrefslogtreecommitdiffstats
path: root/tool/merge-test.tcl
blob: 2010d67657a9c46b8e1f26f0d42b62a4a49a1e14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/tcl
#
# Run this script to test to see that the latest trunk changes can be
# merged into LTS branches without breaking anything.
#
# To Use:
#
#   *  Copy this script into a directory above the sqlite checkout
#   *  Run "fossil update trunk" and "fossil revert"
#   *  Run "tclsh ../merge-test.tcl"  (in other words run this script)
#
# Operation:
#
# This script changes to each LTS branch to be tested, merges the latest
# trunk changes into the branch (without committing them) and then
# runs "make test".  Any errors are stored in local files.
#
# Limitations:
#
# Some LTS branches are not synced directly from trunk but rather from
# other LTS branches.  These other branches cannot be tested because
# there is no good way to generate the intermediate merges.
#
###############################################################################

# Run a shell command contained in arguments.  Put the return code in
# global variable ::res and the output string in global variable ::result
#
proc safeexec {args} {
  global res result
  set res [catch "exec $args" result]
}

# Run the shell command contained in arguments.  Print an error and exit
# if anything goes wrong.
#
proc mustbeok {args} {
  global res result
  set res [catch "exec $args" result]
  if {$res} {
    puts "FAILED: $args"
    puts $result
    exit 1
  }
}

# Write $content into a file named $filename.  The file is overwritten if it
# already exist.  The file is create if it does not already exist.
#
proc writefile {filename content} {
  set fd [open $filename wb]
  puts $fd $content
  close $fd
}

# Run the merge-test
#
foreach {branch configopts} {
  begin-concurrent         {--enable-json1}
  begin-concurrent-pnu     {--enable-json1}
  wal2                     {--enable-all}
  reuse-schema             {--enable-all}
} {
  puts $branch
  set errorfile ${branch}-error.txt
  mustbeok fossil revert
  mustbeok fossil up $branch
  safeexec fossil merge trunk
  if {$res} {
    puts "   merge failed - see $errorfile"
    writefile $errorfile $result
  } else {
    puts "   merge ok"
    safeexec  ./configure --enable-debug {*}$configopts
    if {$res} {
      puts "   configure failed - see $errorfile"
      writefile $errorfile $result
    } else {
      puts "   configure ok"
      safeexec make fuzzcheck sqlite3 testfixture
      if {$res} {
        puts "   build failed - see $errorfile"
        writefile $errorfile $result
      } else {
        puts "   build ok"
        safeexec make test
        if {$res} {
          puts "   test failed - see $errorfile"
          writefile $errorfile $result
        } else {
          puts "   test ok"
        }
      }
    }
  }
}
mustbeok fossil revert
mustbeok fossil up trunk
puts "reset back to trunk"