Now on revision 106088. Conflicting tags: mh-e-doc-8.3 mh-e-8.3 ------------------------------------------------------------ revno: 106088 committer: martin rudalics branch nick: trunk timestamp: Sat 2011-10-15 12:12:00 +0200 message: Rewrite and delabelize vertical border check. (Bug#5357) (Bug#9618) * window.c (coordinates_in_window): Rewrite and delabelize vertical border check. (Bug#5357) (Bug#9618) diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2011-10-14 17:44:39 +0000 +++ src/ChangeLog 2011-10-15 10:12:00 +0000 @@ -1,3 +1,8 @@ +2011-10-15 Martin Rudalics + + * window.c (coordinates_in_window): Rewrite and delabelize + vertical border check. (Bug#5357) (Bug#9618) + 2011-10-14 Stefan Monnier * xterm.c (frame_highlight, frame_unhighlight): Ignore unexplained === modified file 'src/window.c' --- src/window.c 2011-09-24 22:51:36 +0000 +++ src/window.c 2011-10-15 10:12:00 +0000 @@ -919,22 +919,45 @@ coordinates_in_window (register struct window *w, int x, int y) { struct frame *f = XFRAME (WINDOW_FRAME (w)); - int left_x, right_x; enum window_part part; int ux = FRAME_COLUMN_WIDTH (f); - int x0 = WINDOW_LEFT_EDGE_X (w); - int x1 = WINDOW_RIGHT_EDGE_X (w); + int left_x = WINDOW_LEFT_EDGE_X (w); + int right_x = WINDOW_RIGHT_EDGE_X (w); + int top_y = WINDOW_TOP_EDGE_Y (w); + int bottom_y = WINDOW_BOTTOM_EDGE_Y (w); /* The width of the area where the vertical line can be dragged. (Between mode lines for instance. */ int grabbable_width = ux; int lmargin_width, rmargin_width, text_left, text_right; - int top_y = WINDOW_TOP_EDGE_Y (w); - int bottom_y = WINDOW_BOTTOM_EDGE_Y (w); - /* Outside any interesting row? */ - if (y < top_y || y >= bottom_y) + /* Outside any interesting row or column? */ + if (y < top_y || y >= bottom_y || x < left_x || x >= right_x) return ON_NOTHING; + /* On the mode line or header line? */ + if ((WINDOW_WANTS_MODELINE_P (w) + && y >= bottom_y - CURRENT_MODE_LINE_HEIGHT (w) + && (part = ON_MODE_LINE)) + || (WINDOW_WANTS_HEADER_LINE_P (w) + && y < top_y + CURRENT_HEADER_LINE_HEIGHT (w) + && (part = ON_HEADER_LINE))) + { + /* If it's under/over the scroll bar portion of the mode/header + line, say it's on the vertical line. That's to be able to + resize windows horizontally in case we're using toolkit scroll + bars. Note: If scrollbars are on the left, the window that + must be eventually resized is that on the left of WINDOW. */ + if ((WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w) + && !WINDOW_LEFTMOST_P (w) + && eabs (x - left_x) < grabbable_width) + || (!WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w) + && !WINDOW_RIGHTMOST_P (w) + && eabs (x - right_x) < grabbable_width)) + return ON_VERTICAL_BORDER; + else + return part; + } + /* In what's below, we subtract 1 when computing right_x because we want the rightmost pixel, which is given by left_pixel+width-1. */ if (w->pseudo_window_p) @@ -948,50 +971,6 @@ right_x = WINDOW_BOX_RIGHT_EDGE_X (w) - 1; } - /* On the mode line or header line? If it's near the start of - the mode or header line of window that's has a horizontal - sibling, say it's on the vertical line. That's to be able - to resize windows horizontally in case we're using toolkit - scroll bars. */ - - if (WINDOW_WANTS_MODELINE_P (w) - && y >= bottom_y - CURRENT_MODE_LINE_HEIGHT (w)) - { - part = ON_MODE_LINE; - - header_vertical_border_check: - /* We're somewhere on the mode line. We consider the place - between mode lines of horizontally adjacent mode lines - as the vertical border. If scroll bars on the left, - return the right window. */ - if ((WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w) - || WINDOW_RIGHTMOST_P (w)) - && !WINDOW_LEFTMOST_P (w) - && eabs (x - x0) < grabbable_width) - return ON_VERTICAL_BORDER; - - /* Make sure we're not at the rightmost position of a - mode-/header-line and there's yet another window on the - right. (Bug#1372) */ - else if ((WINDOW_RIGHTMOST_P (w) || x < x1) - && eabs (x - x1) < grabbable_width) - return ON_VERTICAL_BORDER; - - if (x < x0 || x >= x1) - return ON_NOTHING; - - return part; - } - - if (WINDOW_WANTS_HEADER_LINE_P (w) - && y < top_y + CURRENT_HEADER_LINE_HEIGHT (w)) - { - part = ON_HEADER_LINE; - goto header_vertical_border_check; - } - - if (x < x0 || x >= x1) return ON_NOTHING; - /* Outside any interesting column? */ if (x < left_x || x > right_x) return ON_SCROLL_BAR; ------------------------------------------------------------ revno: 106087 committer: Stefan Monnier branch nick: trunk timestamp: Fri 2011-10-14 14:39:16 -0400 message: * lisp/pcmpl-unix.el (pcomplete/ssh): SSH does allow ganging. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-10-14 18:37:53 +0000 +++ lisp/ChangeLog 2011-10-14 18:39:16 +0000 @@ -1,5 +1,7 @@ 2011-10-14 Stefan Monnier + * pcmpl-unix.el (pcomplete/ssh): SSH does allow ganging. + * mpc.el (mpc-songs-jump-to): Don't burp if the user clicks in an empty buffer. === modified file 'lisp/pcmpl-unix.el' --- lisp/pcmpl-unix.el 2011-10-03 16:49:56 +0000 +++ lisp/pcmpl-unix.el 2011-10-14 18:39:16 +0000 @@ -185,7 +185,7 @@ ;;;###autoload (defun pcomplete/ssh () "Completion rules for the `ssh' command." - (pcomplete-opt "1246AaCfgKkMNnqsTtVvXxYbcDeFiLlmOopRSw" nil t) + (pcomplete-opt "1246AaCfgKkMNnqsTtVvXxYbcDeFiLlmOopRSw") (pcomplete-here (pcmpl-ssh-hosts))) ;;;###autoload ------------------------------------------------------------ revno: 106086 committer: Stefan Monnier branch nick: trunk timestamp: Fri 2011-10-14 14:37:53 -0400 message: * lisp/mpc.el (mpc-songs-jump-to): Don't burp if the user clicks in an empty buffer. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-10-14 18:36:33 +0000 +++ lisp/ChangeLog 2011-10-14 18:37:53 +0000 @@ -1,5 +1,8 @@ 2011-10-14 Stefan Monnier + * mpc.el (mpc-songs-jump-to): Don't burp if the user clicks in an + empty buffer. + * mouse.el (mouse-drag-mode-line-1): Modify the end-event we pushed on unread-command-events rather than pushing yet-another event. === modified file 'lisp/mpc.el' --- lisp/mpc.el 2011-10-05 00:56:26 +0000 +++ lisp/mpc.el 2011-10-14 18:37:53 +0000 @@ -1996,12 +1996,14 @@ (list (get-text-property (point) 'mpc-file) posn)))) (let* ((plbuf (mpc-proc-cmd "playlist")) - (re (concat "^\\([0-9]+\\):" (regexp-quote song-file) "$")) + (re (if song-file + (concat "^\\([0-9]+\\):" (regexp-quote song-file) "$"))) (sn (with-current-buffer plbuf (goto-char (point-min)) - (when (re-search-forward re nil t) + (when (and re (re-search-forward re nil t)) (match-string 1))))) (cond + ((null re) (posn-set-point posn)) ((null sn) (error "This song is not in the playlist")) ((null (with-current-buffer plbuf (re-search-forward re nil t))) ;; song-file only appears once in the playlist: no ambiguity, ------------------------------------------------------------ revno: 106085 committer: Stefan Monnier branch nick: trunk timestamp: Fri 2011-10-14 14:36:33 -0400 message: * lisp/mouse.el (mouse-drag-mode-line-1): Modify the end-event we pushed on unread-command-events rather than pushing yet-another event. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-10-14 13:49:32 +0000 +++ lisp/ChangeLog 2011-10-14 18:36:33 +0000 @@ -1,3 +1,8 @@ +2011-10-14 Stefan Monnier + + * mouse.el (mouse-drag-mode-line-1): Modify the end-event we pushed on + unread-command-events rather than pushing yet-another event. + 2011-10-14 Eli Zaretskii * mail/sendmail.el (sendmail-query-once): Improve the wording of === modified file 'lisp/mouse.el' --- lisp/mouse.el 2011-09-24 18:38:20 +0000 +++ lisp/mouse.el 2011-10-14 18:36:33 +0000 @@ -540,11 +540,13 @@ ;; be `mouse-1', whereas if this did move the mouse, it should be ;; a `drag-mouse-1'. In any case `on-link' would have been nulled ;; above if there had been any significant mouse movement. - (when (and on-link (eq 'mouse-1 (car-safe event))) + (when (and on-link + (eq 'mouse-1 (car-safe (car unread-command-events)))) ;; If mouse-2 has never been done by the user, it doesn't ;; have the necessary property to be interpreted correctly. (put 'mouse-2 'event-kind 'mouse-click) - (push (cons 'mouse-2 (cdr event)) unread-command-events)))))) + (setcar unread-command-events + (cons 'mouse-2 (cdar unread-command-events)))))))) (defun mouse-drag-mode-line (start-event) "Change the height of a window by dragging on the mode line." ------------------------------------------------------------ revno: 106084 fixes bug(s): http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9310 committer: Stefan Monnier branch nick: trunk timestamp: Fri 2011-10-14 13:44:39 -0400 message: * src/xterm.c (frame_highlight, frame_unhighlight): Ignore unexplained errors in XSetWindowBorder. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2011-10-13 14:55:46 +0000 +++ src/ChangeLog 2011-10-14 17:44:39 +0000 @@ -1,3 +1,8 @@ +2011-10-14 Stefan Monnier + + * xterm.c (frame_highlight, frame_unhighlight): Ignore unexplained + errors in XSetWindowBorder (bug#9310). + 2011-10-13 Dmitry Antipov * editfns.c (Fset_time_zone_rule): Replace free with xfree to @@ -71,8 +76,8 @@ 2011-10-07 Stefan Monnier - * buffer.c (syms_of_buffer) : Don't - advertise functionality which we discourage or doesn't work. + * buffer.c (syms_of_buffer) : + Don't advertise functionality which we discourage or doesn't work. 2011-10-07 Paul Eggert @@ -338,8 +343,7 @@ 2011-09-17 Eli Zaretskii * xdisp.c (reseat_at_next_visible_line_start): Keep information - about the current paragraph and restore it after the call to - reseat. + about the current paragraph and restore it after the call to reseat. * bidi.c (MAX_PARAGRAPH_SEARCH): New macro. (bidi_find_paragraph_start): Search back for paragraph beginning @@ -559,7 +563,7 @@ * doprnt.c (doprnt): Support printing ptrdiff_t and intmax_t values. (esprintf, exprintf, evxprintf): New functions. * keyboard.c (command_loop_level): Now EMACS_INT, not int. - (cmd_error): kbd macro iterations count is now EMACS_INT, not int. + (cmd_error): Kbd macro iterations count is now EMACS_INT, not int. (modify_event_symbol): Do not assume that the length of name_alist_or_stem is safe to alloca and fits in int. (Fexecute_extended_command): Likewise for function name and binding. @@ -1303,8 +1307,7 @@ 2011-08-18 Andreas Schwab - * process.c (Fnetwork_interface_list): Correctly determine buffer - size. + * process.c (Fnetwork_interface_list): Correctly determine buffer size. 2011-08-17 Chong Yidong @@ -1349,15 +1352,10 @@ 2011-08-15 Eli Zaretskii - * biditype.h: File removed. - - * bidimirror.h: File removed. - - * deps.mk (bidi.o): Remove biditype.h and - bidimirror.h. - - * makefile.w32-in ($(BLD)/bidi.$(O)): Remove biditype.h and - bidimirror.h. + * bidimirror.h: + * biditype.h: Remove file. + * makefile.w32-in ($(BLD)/bidi.$(O)): + * deps.mk (bidi.o): Remove biditype.h and bidimirror.h. * dispextern.h: Fix a typo in the comment to bidi_type_t. @@ -1532,8 +1530,7 @@ 2011-08-04 Andreas Schwab - * regex.c (re_iswctype): Remove some redundant boolean - conversions. + * regex.c (re_iswctype): Remove some redundant boolean conversions. 2011-08-04 Jan Djärv @@ -2070,8 +2067,7 @@ 2011-07-15 Eli Zaretskii * xdisp.c (move_it_in_display_line_to): Fix vertical motion with - bidi redisplay when a line includes both an image and is - truncated. + bidi redisplay when a line includes both an image and is truncated. 2011-07-14 Paul Eggert === modified file 'src/xterm.c' --- src/xterm.c 2011-09-15 16:22:58 +0000 +++ src/xterm.c 2011-10-14 17:44:39 +0000 @@ -3355,8 +3355,14 @@ and border pixel are window attributes which are "private to the client", so we can always change it to whatever we want. */ BLOCK_INPUT; + /* I recently started to get errors in this XSetWindowBorder, depending on + the window-manager in use, tho something more is at play since I've been + using that same window-manager binary for ever. Let's not crash just + because of this (bug#9310). */ + x_catch_errors (FRAME_X_DISPLAY (f)); XSetWindowBorder (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), f->output_data.x->border_pixel); + x_uncatch_errors (); UNBLOCK_INPUT; x_update_cursor (f, 1); x_set_frame_alpha (f); @@ -3370,8 +3376,11 @@ and border pixel are window attributes which are "private to the client", so we can always change it to whatever we want. */ BLOCK_INPUT; + /* Same as above for XSetWindowBorder (bug#9310). */ + x_catch_errors (FRAME_X_DISPLAY (f)); XSetWindowBorderPixmap (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), f->output_data.x->border_tile); + x_uncatch_errors (); UNBLOCK_INPUT; x_update_cursor (f, 1); x_set_frame_alpha (f); ------------------------------------------------------------ revno: 106083 committer: Eli Zaretskii branch nick: trunk timestamp: Fri 2011-10-14 15:49:32 +0200 message: Improve wording in sendmail-query-once description of options. lisp/mail/sendmail.el (sendmail-query-once): Improve the wording of the explanation of the possible choices. Make the options passed to completing-read shorter. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-10-13 18:37:57 +0000 +++ lisp/ChangeLog 2011-10-14 13:49:32 +0000 @@ -1,3 +1,9 @@ +2011-10-14 Eli Zaretskii + + * mail/sendmail.el (sendmail-query-once): Improve the wording of + the explanation of the possible choices. Make the options passed + to completing-read shorter. + 2011-10-13 Agustín Martín Domingo * textmodes/flyspell.el (flyspell-large-region): Make sure === modified file 'lisp/mail/sendmail.el' --- lisp/mail/sendmail.el 2011-10-11 21:31:22 +0000 +++ lisp/mail/sendmail.el 2011-10-14 13:49:32 +0000 @@ -513,21 +513,34 @@ ;; a second time, probably because someone's using an old value ;; of send-mail-function. (when (eq send-mail-function 'sendmail-query-once) - (let* ((options `(("My favorite mail client" . mailclient-send-it) - ("Configuring Emacs's SMTP variables" . smtpmail-send-it) + (let* ((options `(("Mail client" . mailclient-send-it) ,@(when (and sendmail-program (executable-find sendmail-program)) - '(("The system's mail transport agent" - . sendmail-send-it))))) + '(("Mail transport agent" . sendmail-send-it))) + ("SMTP server" . smtpmail-send-it))) (choice ;; Query the user. (with-temp-buffer - (rename-buffer "*Mail Help*" t) - (insert "Emacs has not been set up for sending mail.\n -It can be told to send mail either via your favorite mail client, -or via the system's mail transport agent (\"sendmail\"), if any, -or it can send email on its own by configuring the SMTP parameters.\n -To change your decision later, customize `send-mail-function'.\n") + (rename-buffer "*Emacs Mail Setup Help*" t) + (insert "\ + Emacs is about to send an email message. However, it was not configured + for sending email. You can instruct Emacs to send email in one of the + following ways: + + - Start your default mail client and pass to it the message text. + Type \"Mail client\" at the prompt below to select this option.\n\n") + (if (and sendmail-program + (executable-find sendmail-program)) + (insert "\ + - Invoke the system's mail transport agent (\"sendmail\"). + Type \"Mail transport agent\" at the prompt below to select this option.\n\n")) + (insert "\ + - Send mail directly by communicating with your mail server + (this requires setting up SMTP parameters). + Type \"SMTP server\" at the prompt below to select this option. + + Emacs will record your selection and will use it thereafter. To change + your selection later, customize the option `send-mail-function'.\n") (goto-char (point-min)) (display-buffer (current-buffer)) (let ((completion-ignore-case t)) ------------------------------------------------------------ revno: 106082 committer: Glenn Morris branch nick: trunk timestamp: Fri 2011-10-14 00:16:56 -0700 message: Minor rewording of some sections of the ERT manual. * doc/misc/ert.texi (Introduction, How to Run Tests) (Running Tests Interactively, Expected Failures) (Tests and Their Environment, Useful Techniques) (Interactive Debugging, Fixtures and Test Suites): Minor rephrasings. (Running Tests Interactively, The @code{should} Macro): Add xrefs. (Running Tests in Batch Mode): Simplify loading instructions. (Test Selectors): Clarify some selectors. (Expected Failures, Useful Techniques): Make examples fit in 80 columns. Remove unused "LocalWords". diff: === modified file 'doc/misc/ChangeLog' --- doc/misc/ChangeLog 2011-10-13 02:50:58 +0000 +++ doc/misc/ChangeLog 2011-10-14 07:16:56 +0000 @@ -1,3 +1,16 @@ +2011-10-14 Glenn Morris + + * ert.texi (Introduction, How to Run Tests) + (Running Tests Interactively, Expected Failures) + (Tests and Their Environment, Useful Techniques) + (Interactive Debugging, Fixtures and Test Suites): + Minor rephrasings. + (Running Tests Interactively, The @code{should} Macro): Add xrefs. + (Running Tests in Batch Mode): Simplify loading instructions. + (Test Selectors): Clarify some selectors. + (Expected Failures, Useful Techniques): + Make examples fit in 80 columns. + 2011-10-13 Jay Belanger * calc.texi (Basic Operations on Units): Discuss temperature === modified file 'doc/misc/ert.texi' --- doc/misc/ert.texi 2011-10-12 04:37:25 +0000 +++ doc/misc/ert.texi 2011-10-14 07:16:56 +0000 @@ -82,8 +82,8 @@ Other Testing Concepts -* Mocks and Stubs:: Stubbing out code that is irrelevant to the test. -* Fixtures and Test Suites:: How ERT differs from tools for other languages. +* Mocks and Stubs:: Stubbing out code that is irrelevant to the test. +* Fixtures and Test Suites:: How ERT differs from tools for other languages. @end detailmenu @end menu @@ -133,8 +133,8 @@ @code{should} is a macro with the same meaning as @code{assert} but better error reporting. @xref{The @code{should} Macro}. -Each test should have a name that describes what functionality the -test tests. Test names can be chosen arbitrarily --- they are in a +Each test should have a name that describes what functionality it tests. +Test names can be chosen arbitrarily --- they are in a namespace separate from functions and variables --- but should follow the usual Emacs Lisp convention of having a prefix that indicates which package they belong to. Test names are displayed by ERT when @@ -142,7 +142,7 @@ The empty parentheses @code{()} in the first line don't currently have any meaning and are reserved for future extension. They also make -@code{ert-deftest}'s syntax more similar to @code{defun}. +the syntax of @code{ert-deftest} more similar to that of @code{defun}. The docstring describes what feature this test tests. When running tests interactively, the first line of the docstring is displayed for @@ -163,14 +163,14 @@ command line in a separate Emacs process in batch mode (i.e., with no user interface). The former mode is convenient during interactive development, the latter is useful to make sure that tests pass -independently of your customizations, allows tests to be invoked from -makefiles and scripts to be written that run tests in several +independently of your customizations; and it allows you to invoke +tests from makefiles, and to write scripts that run tests in several different Emacs versions. @menu * Running Tests Interactively:: Run tests in your current Emacs. * Running Tests in Batch Mode:: Run tests in emacs -Q. -* Test Selectors:: Choose which tests to run. +* Test Selectors:: Choose which tests to run. @end menu @@ -178,7 +178,8 @@ @section Running Tests Interactively You can run the tests that are currently defined in your Emacs with -the command @kbd{@kbd{M-x} ert @kbd{RET} t @kbd{RET}}. ERT will pop +the command @kbd{@kbd{M-x} ert @kbd{RET} t @kbd{RET}}. (For an +explanation of the @code{t} argument, @pxref{Test Selectors}.) ERT will pop up a new buffer, the ERT results buffer, showing the results of the tests run. It looks like this: @@ -219,10 +220,10 @@ (different-atoms c d)))) @end example -At the top, there is a summary of the results: We ran all tests in the -current Emacs (@code{Selector: t}), 31 of them passed, and 2 failed -unexpectedly. @xref{Expected Failures}, for an explanation of the -term @emph{unexpected} in this context. +At the top, there is a summary of the results: we ran all tests defined +in the current Emacs (@code{Selector: t}), 31 of them passed, and 2 +failed unexpectedly. @xref{Expected Failures}, for an explanation of +the term @emph{unexpected} in this context. The line of dots and @code{F}s is a progress bar where each character represents one test; it fills while the tests are running. A dot @@ -261,7 +262,7 @@ They can be used like this: @example -emacs -batch -L /path/to/ert -l ert.el -l my-tests.el -f ert-run-tests-batch-and-exit +emacs -batch -l ert -l my-tests.el -f ert-run-tests-batch-and-exit @end example This command will start up Emacs in batch mode, load ERT, load @@ -270,9 +271,10 @@ failed or if anything else went wrong. It will also print progress messages and error diagnostics to standard output. -You may need additional @code{-L} flags to ensure that -@code{my-tests.el} and all the files that it requires are on your -@code{load-path}. +If ERT is not part of your Emacs distribution, you may need to use +@code{-L /path/to/ert/} so that Emacs can find it. You may need +additional @code{-L} flags to ensure that @code{my-tests.el} and all the +files that it requires are on your @code{load-path}. @node Test Selectors, , Running Tests in Batch Mode, How to Run Tests @@ -288,23 +290,26 @@ @item @code{:new} selects all tests that have not been run yet. @item @code{:failed} and @code{:passed} select tests according to their most recent result. @item @code{:expected}, @code{:unexpected} select tests according to their most recent result. -@item A string selects all tests that have a name that matches the string, a regexp. -@item A test selects that test. +@item A string is a regular expression that selects all tests with matching names. +@item A test (i.e., an object of @code{ert-test} data type) selects that test. @item A symbol selects the test that the symbol names. -@item @code{(member TESTS...)} selects TESTS, a list of tests or symbols naming tests. +@item @code{(member TESTS...)} selects the elements of TESTS, a list of +tests or symbols naming tests. @item @code{(eql TEST)} selects TEST, a test or a symbol naming a test. @item @code{(and SELECTORS...)} selects the tests that match all SELECTORS. @item @code{(or SELECTORS...)} selects the tests that match any SELECTOR. @item @code{(not SELECTOR)} selects all tests that do not match SELECTOR. @item @code{(tag TAG)} selects all tests that have TAG on their tags list. -@item @code{(satisfies PREDICATE)} Selects all tests that satisfy PREDICATE. +(Tags are optional labels you can apply to tests when you define them.) +@item @code{(satisfies PREDICATE)} selects all tests that satisfy PREDICATE, +a function that takes a test as argument and returns non-nil if it is selected. @end itemize Selectors that are frequently useful when selecting tests to run include @code{t} to run all tests that are currently defined in Emacs, -@code{"^foo-"} to run all tests in package @code{foo} --- this assumes -that package @code{foo} uses the prefix @code{foo-} for its test names ----, result-based selectors such as @code{(or :new :unexpected)} to +@code{"^foo-"} to run all tests in package @code{foo} (this assumes +that package @code{foo} uses the prefix @code{foo-} for its test names), +result-based selectors such as @code{(or :new :unexpected)} to run all tests that have either not run yet or that had an unexpected result in the last run, and tag-based selectors such as @code{(not (tag :causes-redisplay))} to run all tests that are not tagged @@ -325,9 +330,9 @@ @menu -* The @code{should} Macro:: A powerful way to express assertions. +* The @code{should} Macro:: A powerful way to express assertions. * Expected Failures:: Tests for known bugs. -* Tests and Their Environment:: Don't depend on customizations; no side effects. +* Tests and Their Environment:: Don't depend on customizations; no side effects. * Useful Techniques:: Some examples. @end menu @@ -335,10 +340,12 @@ @section The @code{should} Macro Test bodies can include arbitrary code; but to be useful, they need to -have checks whether the code being tested (or @emph{code under test}) +check whether the code being tested (or @emph{code under test}) does what it is supposed to do. The macro @code{should} is similar to -@code{assert} from the cl package, but analyzes its argument form and -records information that ERT can display to help debugging. +@code{assert} from the cl package +(@pxref{Assertions,,, cl, Common Lisp Extensions}), +but analyzes its argument form and records information that ERT can +display to help debugging. This test definition @@ -396,7 +403,7 @@ @node Expected Failures, Tests and Their Environment, The @code{should} Macro, How to Write Tests @section Expected Failures -Some bugs are complicated to fix or not very important and are left as +Some bugs are complicated to fix, or not very important, and are left as @emph{known bugs}. If there is a test case that triggers the bug and fails, ERT will alert you of this failure every time you run all tests. For known bugs, this alert is a distraction. The way to @@ -406,7 +413,7 @@ @lisp (ert-deftest future-bug () "Test `time-forward' with negative arguments. -Since this functionality isn't implemented yet, the test is known to fail." +Since this functionality isn't implemented, the test is known to fail." :expected-result :failed (time-forward -1)) @end lisp @@ -427,7 +434,7 @@ prevent future regressions. ERT displays the same kind of alerts for tests that pass unexpectedly -that it displays for unexpected failures. This way, if you make code +as it displays for unexpected failures. This way, if you make code changes that happen to fix a bug that you weren't aware of, you will know to remove the @code{:expected-result} clause of that test and close the corresponding bug report, if any. @@ -453,8 +460,8 @@ of the environment, and each test should leave its environment in the same state it found it in. In particular, a test should not depend on any Emacs customization variables or hooks, and if it has to make any -changes to Emacs' state or state external to Emacs such as the file -system, it should undo these changes before it returns, regardless of +changes to Emacs's state or state external to Emacs (such as the file +system), it should undo these changes before it returns, regardless of whether it passed or failed. Tests should not depend on the environment because any such @@ -462,14 +469,14 @@ only under certain circumstances and are hard to reproduce. Of course, the code under test may have settings that affect its behavior. In that case, it is best to make the test @code{let}-bind -all such settings variables to set up a specific configuration for the +all such setting variables to set up a specific configuration for the duration of the test. The test can also set up a number of different configurations and run the code under test with each. Tests that have side effects on their environment should restore it to its original state because any side effects that persist after the test can disrupt the workflow of the programmer running the tests. If -the code under test has side effects on Emacs' current state, such as +the code under test has side effects on Emacs's current state, such as on the current buffer or window configuration, the test should create a temporary buffer for the code to manipulate (using @code{with-temp-buffer}), or save and restore the window configuration @@ -490,13 +497,13 @@ @code{auto-mode-alist}. It is difficult to write a meaningful test if its behavior can be affected by so many external factors. Also, @code{find-file} has side effects that are hard to predict and thus -hard to undo: It may create a new buffer or may reuse an existing +hard to undo: It may create a new buffer or reuse an existing buffer if one is already visiting the requested file; and it runs @code{find-file-hook}, which can have arbitrary side effects. Instead, it is better to use lower-level mechanisms with simple and predictable semantics like @code{with-temp-buffer}, @code{insert} or -@code{insert-file-contents-literally}, and activating the desired mode +@code{insert-file-contents-literally}, and to activate any desired mode by calling the corresponding function directly --- after binding the hook variables to nil. This avoids the above problems. @@ -534,8 +541,10 @@ (ert--print-backtrace (ert-test-failed-backtrace result)) (goto-char (point-min)) (end-of-line) - (let ((first-line (buffer-substring-no-properties (point-min) (point)))) - (should (equal first-line " signal(ert-test-failed (\"foo\"))"))))))) + (let ((first-line (buffer-substring-no-properties + (point-min) (point)))) + (should (equal first-line + " signal(ert-test-failed (\"foo\"))"))))))) @end lisp This test creates a test object using @code{make-ert-test} whose body @@ -562,7 +571,7 @@ For example, if @code{ert-run-test} accepted only symbols that name tests rather than test objects, the test would need a name for the failing test, which would have to be a temporary symbol generated with -@code{make-symbol}, to avoid side effects on Emacs' state. Choosing +@code{make-symbol}, to avoid side effects on Emacs's state. Choosing the right interface for @code{ert-run-tests} allows the test to be simpler. @@ -663,7 +672,7 @@ @node Interactive Debugging, , Understanding Explanations, How to Debug Tests @section Interactive Debugging -Debugging failed tests works essentially the same way as debugging any +Debugging failed tests essentially works the same way as debugging any other problems with Lisp code. Here are a few tricks specific to tests: @@ -673,8 +682,8 @@ deterministic before spending any time looking for a cause. In the ERT results buffer, @kbd{r} re-runs the selected test. -@item Use @kbd{.} to jump to the source code of the test to find out what -exactly it does. Perhaps the test is broken rather than the code +@item Use @kbd{.} to jump to the source code of the test to find out exactly +what it does. Perhaps the test is broken rather than the code under test. @item If the test contains a series of @code{should} forms and you can't @@ -699,8 +708,8 @@ @item If you have been editing and rearranging tests, it is possible that ERT remembers an old test that you have since renamed or removed --- renamings or removals of definitions in the source code leave around a -stray definition under the old name in the running process, this is a -common problem in Lisp. In such a situation, hit @kbd{D} to let ERT +stray definition under the old name in the running process (this is a +common problem in Lisp). In such a situation, hit @kbd{D} to let ERT forget about the obsolete test. @end itemize @@ -739,14 +748,13 @@ Both @code{ert-run-tests-interactively} and @code{ert-run-tests-batch} are implemented on top of the lower-level test handling code in the -sections named ``Facilities for running a single test'', ``Test -selectors'', and ``Facilities for running a whole set of tests''. +sections of @file{ert.el} labelled ``Facilities for running a single test'', +``Test selectors'', and ``Facilities for running a whole set of tests''. If you want to write code that works with ERT tests, you should take a look at this lower-level code. Symbols that start with @code{ert--} -are internal to ERT, those that start with @code{ert-} but not -@code{ert--} are meant to be usable by other code. But there is no -mature API yet. +are internal to ERT, whereas those that start with @code{ert-} are +meant to be usable by other code. But there is no mature API yet. Contributions to ERT are welcome. @@ -758,8 +766,8 @@ @menu -* Mocks and Stubs:: Stubbing out code that is irrelevant to the test. -* Fixtures and Test Suites:: How ERT differs from tools for other languages. +* Mocks and Stubs:: Stubbing out code that is irrelevant to the test. +* Fixtures and Test Suites:: How ERT differs from tools for other languages. @end menu @node Mocks and Stubs, Fixtures and Test Suites, Other Testing Concepts, Other Testing Concepts @@ -782,8 +790,8 @@ SUnit or JUnit. However, two features commonly found in such frameworks are notably absent from ERT: fixtures and test suites. -Fixtures, as used e.g. in SUnit or JUnit, are mainly used to provide -an environment for a set of tests, and consist of set-up and tear-down +Fixtures are mainly used (e.g., in SUnit or JUnit) to provide an +environment for a set of tests, and consist of set-up and tear-down functions. While fixtures are a useful syntactic simplification in other @@ -829,13 +837,13 @@ solve this by allowing regexp matching on test names; e.g., the selector "^ert-" selects ERT's self-tests. -Other uses include grouping tests by their expected execution time to -run quick tests during interactive development and slow tests less -frequently. This can be achieved with the @code{:tag} argument to +Other uses include grouping tests by their expected execution time, +e.g. to run quick tests during interactive development and slow tests less +often. This can be achieved with the @code{:tag} argument to @code{ert-deftest} and @code{tag} test selectors. @bye -@c LocalWords: ERT Hagelberg Ohler JUnit namespace docstring ERT's +@c LocalWords: ERT JUnit namespace docstring ERT's @c LocalWords: backtrace makefiles workflow backtraces API SUnit @c LocalWords: subexpressions