xref: /sqlite-3.40.0/tool/merge-test.tcl (revision 48a296c5)
1#!/usr/bin/tcl
2#
3# Run this script to test to see that the latest trunk changes can be
4# merged into LTS branches without breaking anything.
5#
6# To Use:
7#
8#   *  Copy this script into a directory above the sqlite checkout
9#   *  Run "fossil update trunk" and "fossil revert"
10#   *  Run "tclsh ../merge-test.tcl"  (in other words run this script)
11#
12# Operation:
13#
14# This script changes to each LTS branch to be tested, merges the latest
15# trunk changes into the branch (without committing them) and then
16# runs "make test".  Any errors are stored in local files.
17#
18# Limitations:
19#
20# Some LTS branches are not synced directly from trunk but rather from
21# other LTS branches.  These other branches cannot be tested because
22# there is no good way to generate the intermediate merges.
23#
24###############################################################################
25
26# Run a shell command contained in arguments.  Put the return code in
27# global variable ::res and the output string in global variable ::result
28#
29proc safeexec {args} {
30  global res result
31  set res [catch "exec $args" result]
32}
33
34# Run the shell command contained in arguments.  Print an error and exit
35# if anything goes wrong.
36#
37proc mustbeok {args} {
38  global res result
39  set res [catch "exec $args" result]
40  if {$res} {
41    puts "FAILED: $args"
42    puts $result
43    exit 1
44  }
45}
46
47# Write $content into a file named $filename.  The file is overwritten if it
48# already exist.  The file is create if it does not already exist.
49#
50proc writefile {filename content} {
51  set fd [open $filename wb]
52  puts $fd $content
53  close $fd
54}
55
56# Run the merge-test
57#
58foreach {branch configopts} {
59  begin-concurrent         {--enable-json1}
60  begin-concurrent-pnu     {--enable-json1}
61  wal2                     {--enable-all}
62  reuse-schema             {--enable-all}
63} {
64  puts $branch
65  set errorfile ${branch}-error.txt
66  mustbeok fossil revert
67  mustbeok fossil up $branch
68  safeexec fossil merge trunk
69  if {$res} {
70    puts "   merge failed - see $errorfile"
71    writefile $errorfile $result
72  } else {
73    puts "   merge ok"
74    safeexec  ./configure --enable-debug {*}$configopts
75    if {$res} {
76      puts "   configure failed - see $errorfile"
77      writefile $errorfile $result
78    } else {
79      puts "   configure ok"
80      safeexec make fuzzcheck sqlite3 testfixture
81      if {$res} {
82        puts "   build failed - see $errorfile"
83        writefile $errorfile $result
84      } else {
85        puts "   build ok"
86        safeexec make test
87        if {$res} {
88          puts "   test failed - see $errorfile"
89          writefile $errorfile $result
90        } else {
91          puts "   test ok"
92        }
93      }
94    }
95  }
96}
97mustbeok fossil revert
98mustbeok fossil up trunk
99puts "reset back to trunk"
100