Subject: tab-bar-tests-quit-restore-window sometimes fails in *compilation* buffer

From: Paul Eggert <[email-masked]>
Date: Sat, 19 Jul 2025 15:48:44 -0700

This is a timing related bug. To try to reproduce it on Ubuntu 25.04 
x86-64, I start up Emacs, then build Emacs from master (commit 
291cd2d3419c7be20200db3f0ee5936661ab79f2), then cd to the test 
subdirectory, then run:

M-x compile RET make check LOGFILES=lisp/tab-bar-tests.log RET

Sometimes it works, although it outputs a stray 
"^[[H^[[J^[[H^[[J^[[H^[[J^[[H^[[J" string (sans trailing newline) to 
stdout, where "^[" stands for ESC. This string is a minor bug in the 
test: it shouldn't output junk to stdout.

Sometimes it fails, resulting in the following *compilation* buffer, 
where "^[" again represents an ESC character.

The test always seems to work if I run it in a *shell* window, so 
apparently it has something with whether Emacs has a controlling tty, or 
something like that.

–-*- mode: compilation; default-directory: 
"~/src/gnu/emacs/static-checking/test/" -*-
Compilation started at Sat Jul 19 15:36:46

make check LOGFILES=lisp/tab-bar-tests.log
rm -f ./*.tmp
make[1]: Entering directory 
'/home/eggert/src/gnu/emacs/static-checking/test'
make[2]: Entering directory 
'/home/eggert/src/gnu/emacs/static-checking/test'
   GEN      lisp/tab-bar-tests.log
^[[H^[[JRunning 3 tests (2025-07-19 15:36:46-0700, selector ‘(not (or 
(tag :expensive-test) (tag :unstable) (tag :nativecomp)))’)
Renamed tab to ’1’
No more closed tabs to undo
    passed  1/3  tab-bar-tests-close-other-tabs-default (0.001130 sec)
No more closed tabs to undo
No more closed tabs to undo
No more closed tabs to undo
No more closed tabs to undo
No more closed tabs to undo
    passed  2/3  tab-bar-tests-close-other-tabs-with-arg (0.001069 sec)
Display next command buffer in a new frame...
Composing main Info directory...
Composing main Info directory...done
Test tab-bar-tests-quit-restore-window backtrace:
   signal(ert-test-failed (((should (eq (length (window-list)) 2)) :for
   ert-fail(((should (eq (length (window-list)) 2)) :form (eq 1 2) :val
   #f(compiled-function () #<bytecode -0x57ca7793bcf5d97>)()
   #f(compiled-function () #<bytecode 0xf90bd418f219aee>)()
   handler-bind-1(#f(compiled-function () #<bytecode 0xf90bd418f219aee>
   ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
   ert-run-test(#s(ert-test :name tab-bar-tests-quit-restore-window :do
   ert-run-or-rerun-test(#s(ert--stats :selector (not (or ... ... ...))
   ert-run-tests((not (or (tag :expensive-test) (tag :unstable) (tag :n
   ert-run-tests-batch((not (or (tag :expensive-test) (tag :unstable) (
   ert-run-tests-batch-and-exit((not (or (tag :expensive-test) (tag :un
   eval((ert-run-tests-batch-and-exit '(not (or (tag :expensive-test) (
   command-line-1(("-L" ":." "-l" "ert" "--eval" "(setq treesit-extra-l
   command-line()
   normal-top-level()
Test tab-bar-tests-quit-restore-window condition:
     (ert-test-failed
      ((should (eq (length ...) 2)) :form (eq 1 2) :value nil))
    FAILED  3/3  tab-bar-tests-quit-restore-window (0.017622 sec) at 
lisp/tab-bar-tests.el:54

Ran 3 tests, 2 results as expected, 1 unexpected (2025-07-19 
15:36:46-0700, 0.062801 sec)

1 unexpected results:
    FAILED  tab-bar-tests-quit-restore-window

make[2]: *** [Makefile:185: lisp/tab-bar-tests.log] Error 1
make[2]: Leaving directory '/home/eggert/src/gnu/emacs/static-checking/test'
make[1]: [Makefile:348: check-doit] Error 2 (ignored)

SUMMARY OF TEST RESULTS
-----------------------
Files examined: 1
Ran 3 tests, 2 results as expected, 1 unexpected, 0 skipped
1 files contained unexpected results:
   lisp/tab-bar-tests.log
make[1]: *** [Makefile:349: check-doit] Error 1
make[1]: Leaving directory '/home/eggert/src/gnu/emacs/static-checking/test'
make: *** [Makefile:315: check] Error 2

Compilation exited abnormally with code 2 at Sat Jul 19 15:36:47, 
duration 1.37 s