Commit graph

1430 commits

Author SHA1 Message Date
Pip Cet
94dbab2fe4 Fix 'do_casify_natnum' for events with all flags set
* src/casefiddle.c (do_casify_natnum): Extend range a little, to cover
character events with all modifier flags set.
* test/src/casefiddle-tests.el (casefiddle-allflags): New test.
2026-05-24 10:11:33 +00:00
Pip Cet
c146e3643c Fix off-by-one error in 'styled_format'
This would (rarely) result in composition properties being shared
across the concatenation of two copies of a string.

* src/editfns.c (styled_format): Include the first argument in the
range.
* test/src/editfns-tests.el (editfns-tests--format-composition-property):
New.
2026-05-24 09:23:05 +00:00
Jim Porter
d4cb550dba ; Improve last change
* test/src/process-tests.el (process-tests/broken-pipe): Use
CONNECTION-TYPE.
(process-tests/broken-pipe/pipe-all)
(process-tests/broken-pipe/pipe-stdin): Skip via 'skip-when'.
(process-tests/broken-pipe/pty)
(process-tests/broken-pipe/pty-stdin): Remove these invalid tests; EPIPE
from a PTY doesn't make sense.
2026-05-18 08:37:42 -07:00
Jim Porter
e381cf1fc9 Allow child processes to continue after EPIPE
This ensures that if the child process closed its stdin and Emacs tries
to write to it, the process can still do any remaining work and exit
normally.  In practice, this can occur with commands like "head(1)"
(bug#79079).

* src/fileio.c (file_for_stream): New function, extracted from...
(Fset_binary_mode): ... here.
(Ffile__close_stream): New function.

* src/process.c (send_process): When encountering EPIPE, only close the
fd for the pipe to the child process's stdin.

* lisp/eshell/esh-io.el (eshell-output-object-to-target): Don't check
for process liveness anymore.

* test/src/process-tests.el (process-tests/broken-pipe): New function.
(process-tests/broken-pipe/pipe, process-tests/broken-pipe/pty)
(process-tests/broken-pipe/pipe-stdin)
(process-tests/broken-pipe/pty-stdin): New tests.

* etc/NEWS: Announce this change.
2026-05-17 17:24:10 -07:00
Jim Porter
a557bf69b4 Ensure that process-tests clean up test processes
* test/src/process-tests.el (start-process-should-not-modify-arguments):
Clean up test process.
(process-test--check-pipe-process): New macro...
(process-test-make-pipe-process-no-buffer): ... call it.
2026-05-17 17:24:10 -07:00
Stefan Monnier
ff96db93f2 keyboard-tests.el: Try and fix the failure on EMBA
* test/src/keyboard-tests.el (keyboard-sigint-to-quit): Fix a small
race condition and avoid `sit-for` returning early.
2026-05-13 11:10:15 -04:00
Sean Whitton
fdab8a9185 ; Revert Eric's commits from February.
These will be resubmitted as patches for review.

Revert "Repair another test bollixed by aggressive optimization."
This reverts commit 47735e0243.

Revert "Repair ab ecal test by making a variable kexical,"
This reverts commit ca42055b0c.

Revert "Complete the test set for floatfns,c."
This reverts commit 1b0c8d6b95.

Revert "Tesrts for the portable primitives in fileio.c."
This reverts commit a339c6827c.

Revert "Tests for primitives in coding.c and charset.c."
This reverts commit 5749b2e4f4.

Revert "Tests for primitives from the character.c module."
This reverts commit b09f8df206.

Revert "Tests for the lreaf.c amd print.c primitives."
This reverts commit d7a3d442b4.

Revert "Tests for remaining functions iun eval.c."
This reverts commit cd038e5617.

Revert "Completing test coverage for dataa.c orimitives."
This reverts commit a6e19d6179.

Revert "More correctness tesrs for orinitives from fns.c."
This reverts commit 40ff4512ad.

Revert "More tests for edit functions, buffers, and markers."
This reverts commit 67e8f87562.

Revert "Added more buffer/marker/editing test coverage."
This reverts commit 3dda4b85e8.

Revert "Category/charset/coding + char-table tests."
This reverts commit 7a93a7b334.

Revert "More test coverage improvements."
This reverts commit fc7339c46d.

Revert "More test coverage improvements."
This reverts commit 95329bf445.

Revert "More test coverage improvements for ERT."
This reverts commit e42c579a54.

Revert "Crrections to tedt coverrage extensuion after bootstrap build."
This reverts commit 90af3295c7.

Revert "Improve test coverage of builtin predicates."
This reverts commit 6eb170b007.

Revert "Tests for 2 marker primitives previously not covered."
This reverts commit 6d7f0acf9c.

Revert "Tests for 7 editor primitives previously not covered."
This reverts commit bb403e70ae.
2026-05-07 15:29:53 +01:00
Stefan Monnier
a952324e9b keyboard.c: Allow SIGINT to quit in batch mode, instead of exit
In terminal sessions, SIGINT is turned into a `quit` ELisp signal,
but in batch it has traditionally killed Emacs.  It can be very
useful to cause a `quit` from outside the process when running
in batch (e.g. for "batch" sessions that provide a REPL via stdin/out),
so add a new var 'kill-emacs-on-sigint' to control that behavior.
(bug#80942)

* src/keyboard.c (handle_interrupt_signal): Obey `kill_emacs_on_sigint`.
(init_keyboard): Use `deliver_interrupt_signal` for SIGINT also for
batch sessions.
(syms_of_keyboard): New variable `kill_emacs_on_sigint`.

* test/src/keyboard-tests.el (keyboard-sigint-to-quit): New test.

* doc/emacs/cmdargs.texi (Initial Options): Mention the effect of
`kill-emacs-on-sigint` in batch mode.
2026-05-04 12:49:35 -04:00
Chris Roberts
b376c405aa ; Add a test for sqlite-close
* test/src/sqlite-tests.el (sqlite-closed-db): Add test.
(Bug#80908)

Copyright-paperwork-exempt: yes
2026-05-02 14:20:42 +03:00
Paul Eggert
4fcc8a473a ; Spelling fixes. 2026-04-29 22:45:51 -07:00
Vladimir Kazanov
27a18cfd7e Add ERT coverage for read_key_sequence behaviour
* test/src/keyboard-tests.el
(keyboard-tests--rks-fake-posn)
(keyboard-tests--rks-observe)
(keyboard-tests--rks-execute)
(keyboard-tests--rks-with-function-key-bindings)
(keyboard-tests--rks-with-event-kinds)
(keyboard-tests--rks-call-with-live-window-maps): Test helpers.
(keyboard-tests-rks-prefix-then-key)
(keyboard-tests-rks-unbound-returns-sequence)
(keyboard-tests-rks-bound-sequence-ends-read)
(keyboard-tests-rks-decode-fires-without-binding)
(keyboard-tests-rks-input-decode-map)
(keyboard-tests-rks-function-key-map)
(keyboard-tests-rks-function-key-map-on-undefined)
(keyboard-tests-rks-key-translation-before-function-key)
(keyboard-tests-rks-function-key-skipped-when-bound)
(keyboard-tests-rks-input-decode-after-function-key)
(keyboard-tests-rks-key-translation-overrides-bound-sequence)
(keyboard-tests-rks-upcase-fallback)
(keyboard-tests-rks-no-upcase-fallback)
(keyboard-tests-rks-dont-downcase-last)
(keyboard-tests-rks-shifted-function-key-fallback)
(keyboard-tests-rks-switch-frame-delayed)
(keyboard-tests-rks-unbound-down-mouse-dropped)
(keyboard-tests-rks-mode-line-fake-prefix)
(keyboard-tests-rks-mode-line-fake-prefix-continued)
(keyboard-tests-rks-clicked-buffer-switch)
(keyboard-tests-rks-help-char): Tests covering for read_key_sequence.
2026-04-29 23:31:29 -04:00
Yuan Fu
9e70acea67
Fix tree-sitter embedded parser range
If a host parser has some ranges, and an embedded parser also
has some ranges, the final range used by the embedded parser
should be an intersection of the two.  This patch adds this
logic.

* lisp/treesit.el (treesit--range-verbose): New variable.
(treesit--intersect-ranges):
(treesit--set-embed-ranges): New function.
(treesit--update-ranges-non-local):
(treesit--update-ranges-local): Use the new functions.
* test/src/treesit-tests.el:
(treesit-intersect-ranges): New test.
2026-04-27 02:14:49 -07:00
Aaron L. Zeng
e4633e657a Support Elisp debugging and backtraces in code called by modules
* src/lisp.h (handlertype) <CATCHER_ALL_DEBUGGABLE>: New enumeration
value.
* src/emacs-module.c (MODULE_HANDLE_NONLOCAL_EXIT):
* src/eval.c (Fthrow, signal_or_quit): Use it.

* test/src/emacs-module-tests.el
(mod-test-non-local-exit-funcall-debug-on-error): New test.

Bug#80714

Copyright-paperwork-exempt: yes.
2026-04-26 15:20:28 +03:00
Yuan Fu
d3debef28d
Make :range-fn in treesit-range-rules actually work
* lisp/treesit.el (treesit--range-start):
(treesit--range-end):
(treesit--flatten-ranges): New helpers.
(treesit-query-range):
(treesit-query-range-by-language): Don't flatten the ranges
returned by each range-fn.
(treesit--update-ranges-non-local):
(treesit--update-ranges-local): Handle the case where the range
is a complicated ((START . END)...).
* test/src/treesit-tests.el (treesit-range-helper): New test.
2026-04-25 10:49:26 -07:00
Yuan Fu
5ea181a75e
Accept marker as position in treesit.c functions (bug#80830)
* src/treesit.c (treesit_check_positive_integer): Remove.
(treesit_check_position):
(Ftreesit_node_first_child_for_pos):
(Ftreesit_node_descendant_for_range):
(Ftreesit_query_capture):
(Ftreesit__linecol_at): Use fix_position.

* test/src/treesit-tests.el:
(treesit-query-marker-position): Test.
2026-04-16 23:23:12 -07:00
Eli Zaretskii
93f40d1bb7 ; Fix recently-added treesit test
* test/src/treesit-tests.el (treesit-query-node-only-and-grouped):
Remove unused variables.
2026-04-05 09:52:56 +03:00
Yuan Fu
45d7678ca3
Fix treesit-query-capture's NODE-ONLY param
Before the fix, if user uses the NODE-ONLY option, we don't keep
the capture names in the results, then predicates won't work
because they can't reference capture names.

* src/treesit.c (query_capture_remove_capture_name): New
function.
(Ftreesit_query_capture): Use the new function to remove capture
names AFTER running the predicate.
* test/src/treesit-tests.el:
(treesit-query-node-only-and-grouped): New test.
2026-04-04 22:35:35 -07:00
Basil L. Contovounesios
d780007283 Add predicate for initial_terminal
This introduces the predicate frame-initial-p, which uses
struct frame.output_method or struct terminal.type to detect
initial_terminal without relying on its name (bug#80629).
For some prior discussion, see:
https://lists.gnu.org/r/emacs-devel/2019-12/msg00480.html
https://lists.gnu.org/r/emacs-devel/2020-01/msg00120.html

* doc/lispref/frames.texi (Frames): Document frame-initial-p.
(Finding All Frames): Fix grammar.
* etc/NEWS (Lisp Changes in Emacs 31.1): Announce frame-initial-p.
* lisp/desktop.el (desktop--check-dont-save):
* lisp/emacs-lisp/debug.el (debug):
* lisp/frameset.el (frameset-restore):
* lisp/menu-bar.el (menu-bar-update-buffers):
* lisp/xt-mouse.el (turn-on-xterm-mouse-tracking-on-terminal):
Use frame-initial-p instead of checking the "initial_terminal" name.
* lisp/emacs-lisp/byte-opt.el: Mark frame-initial-p as error-free.

* src/pgtkterm.c (pgtk_focus_changed): Use IS_DAEMON in place of
Fdaemonp, thus also accepting a named daemon session.
* src/terminal.c (decode_tty_terminal): Clarify commentary.
(Fframe_initial_p): New function.
(syms_of_terminal): Expose it.
(init_initial_terminal): Update commentary now that
menu-bar-update-buffers uses frame-initial-p (bug#53740).

* test/lisp/xt-mouse-tests.el (with-xterm-mouse-mode): Simulate the
lack of an initial terminal by overriding frame-initial-p now
that turn-on-xterm-mouse-tracking-on-terminal uses it.
* test/src/terminal-tests.el: New file.
2026-03-26 15:19:56 +01:00
Helmut Eller
e427d55284 * test/src/charset-tests.el (charset-tests-define-charset): New. 2026-03-21 18:42:01 +01:00
Stefan Monnier
e2004eb56f Merge remote-tracking branch 'origin/scratch/error-API' 2026-03-15 17:17:21 -04:00
Julian Scheid
f15ad18a14 Fix 'comp--func-unique-in-cu-p' to match docstring
* lisp/emacs-lisp/comp.el (comp--func-unique-in-cu-p): Check
only the callee name instead of requiring global uniqueness.
* test/src/comp-resources/comp-test-direct-call.el: New file.
* test/src/comp-resources/comp-test-direct-call-dup.el: New file.
* test/src/comp-tests.el (comp-tests-has-direct-call-p)
(comp-tests-direct-call-with-lambdas)
(comp-tests-direct-call-with-duplicate-names): New tests.
2026-03-12 09:08:08 +01:00
Andrea Corallo
40f4fc1d8c Fix negated equality assumptions (bug#80327)
* lisp/emacs-lisp/comp.el (comp--add-cond-cstrs): Skip
negated equality assumptions only for relational non-immediate
operands. Keep immediate false-branch constraints.
* test/src/comp-resources/comp-test-funcs.el
(comp-test-80327-hash, comp-test-80327-f): Add reproducer.
* test/src/comp-tests.el (comp-tests-bug-80327): Add regression
test.
2026-03-11 17:09:57 +01:00
Stefan Monnier
6d8b3d1077 test subdirectory: Use new error-API
* test/lisp/vc/vc-tests/vc-tests.el
(vc-test--run-maybe-unsupported-function): Remove dummy branch in
`condition-case`.
* test/lisp/arc-mode-tests.el (define-arc-mode-test-on-type):
Use `error-slot-value`.

* test/src/process-tests.el (process-tests--ignore-EMFILE):
* test/src/filelock-tests.el (filelock-tests-unlock-spoiled)
(filelock-tests-kill-buffer-spoiled):
* test/lisp/vc/vc-git-tests.el (vc-git-test--run):
* test/lisp/proced-tests.el (proced--assert-process-valid-cpu-refinement):
* test/lisp/emacs-lisp/pp-tests.el (pp-tests--sanity):
* test/lisp/emacs-lisp/edebug-tests.el (edebug-tests-with-normal-env)
(edebug-tests-post-command):
* test/lisp/autorevert-tests.el (auto-revert--deftest-remote):
* test/infra/android/test-controller.el (ats-connect):
2026-03-10 10:48:22 -04:00
Stefan Monnier
ea5f15d096 Fix signal calls where the data argument is not a list
* test/src/thread-tests.el (threads-join-error):
* test/src/emacs-module-resources/mod-test.c (Fmod_test_signal):
* src/print.c (print_bind_overrides):
* lisp/url/url-future.el (url-future-finish, url-future-errored)
(url-future-call, url-future-cancel): Make sure signal's data is a list.

* test/src/emacs-module-tests.el (mod-test-non-local-exit-signal-test):
Adjust accordingly.
2026-03-10 00:13:31 -04:00
Michael Albinus
fedf45ca63 Revert "Repair serious breakage in the batch tests."
This reverts commit feac531415.

This patch has deactivated 253 test cases without a sufficient reasoning.
Instead it speaks about a shotgun in its commite message.

The patch is reverted because

- It hasn't been discussed on emacs-devel. It should have, because it is
  a serious change in our infrastructure (new official tag :nobatch). Any
  documentation of this change, for example in test/README, is missing.

- The proper way to deactivate such tests would have been

  (skip-when noninteractive)

  Even better to skip for the respective reasons.

- There is no fault report. There is no information about how these tests
  have failed. Since it hasn't been a problem so far for us, nobody will
  work on a fix forever.
2026-03-04 19:24:52 +01:00
Eli Zaretskii
959da75342 ; * test/src/data-tests.el (data-tests-native-comp-unit): Fix test. 2026-02-27 15:29:16 +02:00
Eric S. Raymond
47735e0243 Repair another test bollixed by aggressive optimization. 2026-02-25 20:51:21 -05:00
Eric S. Raymond
ca42055b0c Repair ab ecal test by making a variable kexical, 2026-02-25 20:20:26 -05:00
Eric S. Raymond
1b0c8d6b95 Complete the test set for floatfns,c. 2026-02-25 20:18:31 -05:00
Eric S. Raymond
a339c6827c Tesrts for the portable primitives in fileio.c. 2026-02-25 19:54:11 -05:00
Eric S. Raymond
5749b2e4f4 Tests for primitives in coding.c and charset.c. 2026-02-25 19:41:05 -05:00
Eric S. Raymond
b09f8df206 Tests for primitives from the character.c module. 2026-02-25 19:41:05 -05:00
Eric S. Raymond
d7a3d442b4 Tests for the lreaf.c amd print.c primitives. 2026-02-25 19:03:02 -05:00
Eric S. Raymond
cd038e5617 Tests for remaining functions iun eval.c. 2026-02-25 18:54:50 -05:00
Eric S. Raymond
a6e19d6179 Completing test coverage for dataa.c orimitives. 2026-02-25 18:35:02 -05:00
Eric S. Raymond
40ff4512ad More correctness tesrs for orinitives from fns.c. 2026-02-25 18:25:58 -05:00
Eric S. Raymond
67e8f87562 More tests for edit functions, buffers, and markers. 2026-02-25 18:10:05 -05:00
Eric S. Raymond
3dda4b85e8 Added more buffer/marker/editing test coverage. 2026-02-25 17:52:42 -05:00
Eric S. Raymond
7a93a7b334 Category/charset/coding + char-table tests. 2026-02-25 17:23:46 -05:00
Eric S. Raymond
fc7339c46d More test coverage improvements. 2026-02-25 17:06:50 -05:00
Eric S. Raymond
feac531415 Repair serious breakage in the batch tests.
There were a bunch of tests that were breaking make check and should
never be run in batch mode, because they do things like assuming there
is a controlling tty or assuming we can access network services when
we can't (e/g. in a CI/CD environment). I have shotgunned this
problem by tagging all the failing tests with :nobatch and then
changing the default and expensive selectors so make check won't barf
all over its shoes.

As many of these :nobatch should be individually removed as possible, after
upgrading the test harness to mock the environmental stuff they need.
Investigate these failures with "make check-nobatch".
2026-02-25 16:36:50 -05:00
Eric S. Raymond
95329bf445 More test coverage improvements.
Bignum corner-case tests in data-tests.el.
More buffer-primitive tests in editfns-test.el
Some condition-case tesrs in eval-tests.el.
And another marker-primitive test in marker-tests.el.
2026-02-25 13:21:25 -05:00
Eric S. Raymond
e42c579a54 More test coverage improvements for ERT.
In marker-tests.el, editfbs-tests.el, and data-tests.el.
2026-02-25 13:21:25 -05:00
Eli Zaretskii
de44026297 ; Fix emacs-module-tests on MS-Windows
* test/src/emacs-module-resources/mod-test.c [WINDOWSNT]: Undef
fprintf to prevent link error.
2026-02-25 19:32:46 +02:00
Eric S. Raymond
90af3295c7 Crrections to tedt coverrage extensuion after bootstrap build.
Files: data-tests.el, editfns-tests.el.
2026-02-25 11:47:16 -05:00
Eric S. Raymond
6eb170b007 Improve test coverage of builtin predicates. 2026-02-25 11:47:16 -05:00
Eric S. Raymond
6d7f0acf9c Tests for 2 marker primitives previously not covered.
- insertion-type
      - last-position-after-kill
2026-02-25 10:24:38 -05:00
Eric S. Raymond
bb403e70ae Tests for 7 editor primitives previously not covered.
- byte-to-position
      - byte-to-string
      - insert-byte
      - insert-buffer-substring
      - insert-before-markers-and-inherit
      - field-string-and-delete
      - constrain-to-field
2026-02-25 10:24:38 -05:00
Mattias Engdegård
2505af27c6 Compare circular lists in 'equal' without error (bug#80456)
* src/lisp.h (FOR_EACH_TAIL_INTERNAL): Divvy up the code into...
(FOR_EACH_TAIL_BASIC, FOR_EACH_TAIL_STEP_CYCLEP): ...these macros,
so that they can be used in more flexible ways.
* src/fns.c (internal_equal_1): Detect circular lists and call...
(internal_equal_cycle): ...this function that keeps comparing
but now detecting cycles in the other argument.

* lisp/emacs-lisp/testcover.el (testcover-after):
Remove unnecessary error handling.
* test/src/fns-tests.el (test-cycle-equal): Adapt and extend.
* test/lisp/emacs-lisp/testcover-resources/testcases.el
(testcover-testcase-cyc1): Remove case that no longer applies.

* doc/lispref/objects.texi (Equality Predicates): Update.
* etc/NEWS: Announce.
2026-02-24 12:47:52 +01:00
Collin Funk
29440eedac Add SHA-3 support to secure-hash
* admin/merge-gnulib (GNULIB_MODULES): Add crypto/sha3-buffer.
* lib/sha3.c: New file, imported by running admin/merge-gnulib.
* lib/sha3.h: Likewise.
* m4/sha3.m4: Likewise.
* lib/gnulib.mk.in: Updated by admin/merge-gnulib.
* m4/gnulib-comp.m4: Likewise.
* src/fns.c: Include sha3.h
(Fsecure_hash_algorithms): Add Qsha3_224, Qsha3_256, Qsha3_384, and
Qsha3_512.
(secure_hash): Likewise.
(Fsecure_hash): List the SHA-3 algorithms in the docstring.
(syms_of_fns): Define Qsha3_224, Qsha3_256, Qsha3_384, and Qsha3_512.
* test/lisp/net/gnutls-tests.el (gnutls-tests-internal-macs-upcased):
Filter out the new SHA-3 algorithms since they are currently not
implemented in gnutls.
* test/src/fns-tests.el (test-secure-hash): Add test cases for the new
algorithms.
* doc/lispref/text.texi (Checksum/Hash): List the SHA-3 algorithms.
Mention that they are considered secure.
* etc/NEWS: Mention the new feature.
2026-02-23 00:22:17 -08:00