From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Daniel Colascione Newsgroups: gmane.emacs.devel Subject: Regression finding via bzr bisection (with application to a cc-mode bug) Date: Sat, 16 Jan 2010 12:39:44 -0500 Organization: Censorship Research Center Message-ID: <4B51F9E0.80200@censorshipresearch.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1263663611 15530 80.91.229.12 (16 Jan 2010 17:40:11 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 16 Jan 2010 17:40:11 +0000 (UTC) To: Emacs development discussions Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jan 16 18:40:03 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NWCcy-0003q2-Vi for ged-emacs-devel@m.gmane.org; Sat, 16 Jan 2010 18:40:01 +0100 Original-Received: from localhost ([127.0.0.1]:44640 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NWCcw-0003Sj-KZ for ged-emacs-devel@m.gmane.org; Sat, 16 Jan 2010 12:39:58 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NWCcr-0003SD-KH for emacs-devel@gnu.org; Sat, 16 Jan 2010 12:39:53 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NWCcq-0003Rq-8O for emacs-devel@gnu.org; Sat, 16 Jan 2010 12:39:53 -0500 Original-Received: from [199.232.76.173] (port=46944 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NWCcq-0003Rk-2C for emacs-devel@gnu.org; Sat, 16 Jan 2010 12:39:52 -0500 Original-Received: from haystack.austinheap.com ([70.32.98.68]:36480 helo=haystacknetwork.com) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NWCcp-0002dW-Da for emacs-devel@gnu.org; Sat, 16 Jan 2010 12:39:51 -0500 User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.5) Gecko/20091204 Thunderbird/3.0 X-Enigmail-Version: 1.0 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:120112 Archived-At: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I've been frustrated by a cc-mode bug, and had no idea where to look in order to fix it. So, I wrote a bisection tool that will find bugs automatically called, imaginatively, emacs-bisect. To use the program, you'll need a bzr checkout and a rough idea of when the bug appeared. Below is a typescript that demonstrates how to use the program. Its usage information has more details. The cc-mode bug I was looking for manifests itself by raising an error after typing a '>' in a cpp macro. In batch mode, that will make Emacs exit with a non-zero status. Here's my test.el: (message "Testing cc-mode insertion bug") (with-temp-buffer "test" (c++-mode) (insert "#include ")) (By the way: the program assumes revision numbers within a branch are monotonically increasing. Can a bzr expert tell me whether that's a valid assumption?) Usage example: ~/software/emacs$ time MAKE='make -j2' CC='ccache cc' ./emacs-bisect -t foo test.el 'date:2009-12-01' emacs-bisect: high revision is 99342 (2010-01-16 10:40:57 +0100) emacs-bisect: building revision 99342 (2010-01-16 10:40:57 +0100) emacs-bisect: good: bug present in revision 99342 (2010-01-16 10:40:57 +0100) emacs-bisect: low revision is 98887 (2009-12-01 07:07:13 +0000) emacs-bisect: building revision 98887 (2009-12-01 07:07:13 +0000) emacs-bisect: good: bug not present in revision 98887 (2009-12-01 07:07:13 +0000) emacs-bisect: examining revisions 98887 - 99342: 455 revisions emacs-bisect: --> 98887 (2009-12-01 07:07:13 +0000) - 99342 (2010-01-16 10:40:57 +0100) emacs-bisect: building revision 99114 (2009-12-14 06:39:39 +0000) emacs-bisect: testing 99114 (2009-12-14 06:39:39 +0000)... emacs-bisect: bug present in 99114 (2009-12-14 06:39:39 +0000) emacs-bisect: examining revisions 98887 - 99114: 227 revisions emacs-bisect: --> 98887 (2009-12-01 07:07:13 +0000) - 99114 (2009-12-14 06:39:39 +0000) emacs-bisect: building revision 99000 (2009-12-06 15:33:09 +0000) emacs-bisect: testing 99000 (2009-12-06 15:33:09 +0000)... emacs-bisect: bug present in 99000 (2009-12-06 15:33:09 +0000) emacs-bisect: examining revisions 98887 - 99000: 113 revisions emacs-bisect: --> 98887 (2009-12-01 07:07:13 +0000) - 99000 (2009-12-06 15:33:09 +0000) emacs-bisect: building revision 98943 (2009-12-03 19:12:52 +0000) emacs-bisect: testing 98943 (2009-12-03 19:12:52 +0000)... emacs-bisect: bug present in 98943 (2009-12-03 19:12:52 +0000) emacs-bisect: examining revisions 98887 - 98943: 56 revisions emacs-bisect: --> 98887 (2009-12-01 07:07:13 +0000) - 98943 (2009-12-03 19:12:52 +0000) emacs-bisect: building revision 98915 (2009-12-02 03:05:14 +0000) emacs-bisect: testing 98915 (2009-12-02 03:05:14 +0000)... emacs-bisect: bug not present in revision 98915 (2009-12-02 03:05:14 +0000) emacs-bisect: examining revisions 98915 - 98943: 28 revisions emacs-bisect: --> 98915 (2009-12-02 03:05:14 +0000) - 98943 (2009-12-03 19:12:52 +0000) emacs-bisect: building revision 98929 (2009-12-03 05:41:17 +0000) emacs-bisect: testing 98929 (2009-12-03 05:41:17 +0000)... emacs-bisect: bug not present in revision 98929 (2009-12-03 05:41:17 +0000) emacs-bisect: examining revisions 98929 - 98943: 14 revisions emacs-bisect: --> 98929 (2009-12-03 05:41:17 +0000) - 98943 (2009-12-03 19:12:52 +0000) emacs-bisect: building revision 98936 (2009-12-03 14:34:04 +0000) emacs-bisect: testing 98936 (2009-12-03 14:34:04 +0000)... emacs-bisect: bug not present in revision 98936 (2009-12-03 14:34:04 +0000) emacs-bisect: examining revisions 98936 - 98943: 7 revisions emacs-bisect: --> 98936 (2009-12-03 14:34:04 +0000) - 98943 (2009-12-03 19:12:52 +0000) emacs-bisect: building revision 98939 (2009-12-03 16:02:10 +0000) emacs-bisect: testing 98939 (2009-12-03 16:02:10 +0000)... emacs-bisect: bug present in 98939 (2009-12-03 16:02:10 +0000) emacs-bisect: examining revisions 98936 - 98939: 3 revisions emacs-bisect: --> 98936 (2009-12-03 14:34:04 +0000) - 98939 (2009-12-03 16:02:10 +0000) emacs-bisect: building revision 98937 (2009-12-03 15:52:37 +0000) emacs-bisect: testing 98937 (2009-12-03 15:52:37 +0000)... emacs-bisect: bug not present in revision 98937 (2009-12-03 15:52:37 +0000) emacs-bisect: examining revisions 98937 - 98939: 2 revisions emacs-bisect: --> 98937 (2009-12-03 15:52:37 +0000) - 98939 (2009-12-03 16:02:10 +0000) emacs-bisect: building revision 98938 (2009-12-03 15:56:29 +0000) emacs-bisect: testing 98938 (2009-12-03 15:56:29 +0000)... emacs-bisect: bug not present in revision 98938 (2009-12-03 15:56:29 +0000) emacs-bisect: examining revisions 98938 - 98939: 1 revisions emacs-bisect: --> 98938 (2009-12-03 15:56:29 +0000) - 98939 (2009-12-03 16:02:10 +0000) emacs-bisect: DONE: bug was introduced between revisions 98938 (2009-12-03 15:56:29 +0000) and 98939 (2009-12-03 16:02:10 +0000) real 17m21.698s user 8m46.602s sys 4m21.798s Program: #!/bin/bash set -e ########## # # Automated bug detection for Emacs using bisection from bzr repositories. # # See usage message for details. # ########## ############ # Globals declare BZR=bzr declare LOG="$PWD/emacs-bisect.log" if [[ -z $MAKE ]]; then declare MAKE='make' fi # Temporary branch name declare tmp='bisect-tmp' # Parent branch name declare parent='trunk' # Name of file containing elisp test code declare test= # If true, the build itself is the test declare buildonly=0 # Current revision number, date, and human-readable description declare current_revno= declare current_devdate= declare current_revdesc= # whether the current checkout is built declare built=0 # Whether we actually do cleanup on exit declare do_cleanup=1 # If true, always build a fully bootstrapped and byte-compiled # Emacs before testing declare fullbuild=0 # where user-visible messages go declare msgfd=2 # internal tempory directory declare tmpdir=$(mktemp -d -t emacs-bisect) ########### # Code msg() { echo >&$msgfd "$(basename $0): $*" } err() { local help=0 local usage=0 if [[ $1 = '-h' ]]; then help=1 shift fi if [[ $1 = '-u' ]]; then usage=1 shift fi if [[ -n $1 ]]; then msg "$1" fi if ((usage)); then cat >&$msgfd <&$msgfd <&2 # FD 7 goes to log exec 7>"$LOG" # FD 8 goes to both (process substitution doesn't work on OS X) mkfifo "$tmpdir/log-and-user" <"$tmpdir/log-and-user" tee /dev/fd/7 & exec 8>"$tmpdir/log-and-user" # stdout and stderr go to the log exec 1>&7 exec 2>&7 msgfd=8 trap cleanup 0 checkout "$high" unset high local highrevno=$current_revno local highrevdesc=$current_revdesc msg "high revision is $current_revdesc" if ! is_feasible_rev; then err "couldn't build HIGH revision $current_revdesc" fi if is_good_rev; then err "bug not present in HIGH revision $current_revdesc" fi msg "good: bug present in revision $current_revdesc" checkout "$low" unset low local lowrevno=$current_revno local lowrevdesc=$current_revdesc msg "low revision is $current_revdesc" # Find the first usable branch while ! is_feasible_rev && (( lowrevno < highrevno )); do msg "skipping infeasible revision $current_revdesc" (( lowrevno++ )) done if (( lowrevno == highrevno )); then err 'no feasible revisions' fi if ! is_good_rev; then err "bug present in LOW revision $current_revdesc Try going further back." fi msg "good: bug not present in revision $current_revdesc" while true; do msg "examining revisions $lowrevno - $highrevno: " \ "$((highrevno - lowrevno)) revisions" msg " --> $lowrevdesc - $highrevdesc" if ! find_pivot $lowrevno $highrevno; then break fi msg "testing $current_revdesc..." if is_good_rev; then msg "bug not present in revision $current_revdesc" lowrevno=$current_revno lowrevdesc=$current_revdesc else msg "bug present in $current_revdesc" highrevno=$current_revno highrevdesc=$current_revdesc fi done msg "DONE: bug was introduced between revisions $lowrevdesc and $highrevdesc" } main "$@" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (Darwin) iEYEARECAAYFAktR+eAACgkQ17c2LVA10Vv7cgCfToY7KHhE21nfSTZN12AAKc/s cHIAnR8U0E/ZsScQgW9o7LE3EDx7hcPH =sEgu -----END PGP SIGNATURE-----