Commit graph

165 commits

Author SHA1 Message Date
Jim Porter
14d54212ea Improve robustness of server.el tests
* lisp/emacs-lisp/ert.el (ert--insert-infos): Allow 'message' to be a
function that is called when inserting the info.
(ert-info): Update docstring to describe using a function for
MESSAGE-FORM.

* lisp/server.el (server-start): Log when the server is starting.

* test/lisp/server-tests.el (server-tests/can-create-frames-p): New
constant.  Use it to skip tests that need to create frames.
(server-tests/start-emacsclient): Rename to...
(server-tests/start-client): ... this, and set the process's buffer.
(server-tests/with-server): Put the server file in a temporary
directory so we don't conflict with real Emacs servers.
(server-tests/with-client): New macro...
(server-tests/server-start/stop-prompt-with-client)
(server-tests/emacsclient/server-edit)
(server-tests/emacsclient/create-frame)
(server-tests/emacsclient/create-frame): ... use it.
(server-tests/server-start/stop-prompt-with-client): Simplify.
2022-11-26 13:40:33 -08:00
Stefan Kangas
f7ee6609ae ; Fix typos (prefer US spelling) 2022-11-18 13:06:55 +01:00
Mattias Engdegård
e99d7c4d62 Simplify code using take, ntake and butlast
* lisp/calc/calc-vec.el (calcFunc-rhead):
* lisp/calc/calc.el (calc-top-list, calc-pop):
* lisp/emacs-lisp/ert.el (ert-summarize-tests-batch-and-exit):
Simplify.
2022-08-14 15:43:12 +02:00
Paul Eggert
d634cb0954 Omit some (current-time) calls
* lisp/emacs-lisp/ert.el (ert-write-junit-test-summary-report):
* lisp/emacs-lisp/shortdoc.el (file):
* lisp/find-lisp.el (find-lisp-find-dired-insert-file):
* lisp/progmodes/hideif.el (hide-ifdefs):
* lisp/tar-mode.el (tar-subfile-save-buffer):
Prefer nil or omitted arg to (current-time) where this is better
or more-efficient.
2022-08-01 01:17:16 -07:00
Stefan Kangas
ecb2eccad5 Improve ert-test-erts-file documentation
* lisp/emacs-lisp/ert.el (ert-test-erts-file): Improve docstring.
* doc/misc/ert.texi (erts files): Fix typo.
2022-07-09 11:47:52 +02:00
Stefan Kangas
139eb1f845 * lisp/emacs-lisp/ert.el (Commentary): Refer to the Info manual. 2022-07-07 23:21:39 +02:00
Stefan Kangas
ef218ac936 ; * lisp/emacs-lisp/ert.el: Remove installation instructions. 2022-07-06 12:31:38 +02:00
Lars Ingebrigtsen
7c4cad3230 Fix ert-run-tests-batch-and-exit doc string typo
* lisp/emacs-lisp/ert.el (ert-run-tests-batch-and-exit): Fix doc
string typo.
2022-05-25 03:25:30 +02:00
Lars Ingebrigtsen
388e0c18f4 Make the nativecomp test eln directory more reliably be removed
* lisp/startup.el (startup-redirect-eln-cache, normal-top-level):
Don't create the nativecomp directory here, because this led to
brittle deletions of the directory -- there would be several
instances of the directory left over after a test run.

* lisp/emacs-lisp/ert.el (ert-run-tests-batch-and-exit): Create
the nativecomp directory.
2022-05-24 14:06:38 +02:00
Lars Ingebrigtsen
ead9547903 Allow jumping to ert failure definitions
* lisp/emacs-lisp/ert.el (ert-test):
(ert-deftest):  Store the file name.
(ert-test-location): New function.
(ert-run-tests-batch): Use it.

* lisp/emacs-lisp/find-func.el (find-ert-deftest-regexp): New
variable.
(find-function-regexp-alist): Add ert-deftest (bug#22471).

Based on code by Phillip Lord <phillip.lord@russet.org.uk>.
2022-01-24 14:01:06 +01:00
Lars Ingebrigtsen
4d866fc0f5 Interpret a "" value of EMACS_TEST_VERBOSE as "off"
* doc/misc/ert.texi (Running Tests in Batch Mode): Adjust doc.
* lisp/emacs-lisp/ert.el (ert-run-tests-batch): Allow overriding
the EMACS_TEST_VERBOSE variable by setting it to "" (bug#53313).
2022-01-21 12:32:10 +01:00
Lars Ingebrigtsen
9c31be6dc3 Make ert explainers work on function aliases
* lisp/emacs-lisp/ert.el: New function.
(ert--expand-should-1): Use it (bug#53178).
2022-01-13 09:49:19 +01:00
Eli Zaretskii
dcd76bd48d Merge from origin/emacs-28
836be7a112 ; * etc/refcards/ru-refcard.tex: Update Copyright year.
86cbc6ee4a * lisp/net/tramp-sh.el: Adapt copyright year
ebe8772f65 ; Minor fixes related to copyright years
23c1ee6989 ; * test/manual/etags/ETAGS.good_N: Adjust to copyright ye...
8d3fc7ec89 * src/xfaces.c (face_for_font): Make 'hash' be uintptr_t.
19dcb237b5 ; Add 2022 to copyright years.

# Conflicts:
#	etc/NEWS
#	etc/refcards/ru-refcard.tex
#	lib/cdefs.h
#	lisp/erc/erc-dcc.el
#	lisp/erc/erc-imenu.el
#	lisp/erc/erc-replace.el
#	lisp/image-dired.el
#	lisp/progmodes/xref.el
#	m4/alloca.m4
#	m4/byteswap.m4
#	m4/errno_h.m4
#	m4/getopt.m4
#	m4/gnulib-common.m4
#	m4/inttypes.m4
#	m4/stddef_h.m4
#	m4/stdint.m4
#	m4/sys_socket_h.m4
2022-01-01 07:03:03 -05:00
Eli Zaretskii
19dcb237b5 ; Add 2022 to copyright years. 2022-01-01 02:45:51 -05:00
Philipp Stephani
d0974e294d * lisp/emacs-lisp/ert.el (ert-select-tests): Document new error. 2021-12-30 17:59:07 +01:00
Philipp Stephani
097452efbc * lisp/emacs-lisp/ert.el (ert-select-tests): Simplify nested switch 2021-12-30 17:19:31 +01:00
Philipp Stephani
f6da1eed74 Properly report errors about unbound ERT test symbols.
Assertions should only be used to check internal consistency within a
package, not to check arguments passed by callers.  Instead, define
and use a new error symbol.

* lisp/emacs-lisp/ert.el (ert-test-unbound): New error symbol.
(ert-select-tests): Use it.

* test/lisp/emacs-lisp/ert-tests.el (ert-test-select-undefined): New
unit test.

* etc/NEWS: Document new behavior.
2021-12-30 17:06:09 +01:00
Philipp Stephani
94891dd225 ; * lisp/emacs-lisp/ert.el: Update reference to 'cl-assert' 2021-12-30 16:23:48 +01:00
Michael Albinus
55f652c856 Make generation of JUnit test reports more robust.
* lisp/emacs-lisp/ert.el (ert-load-file-name): New defvar.
(ert-write-junit-test-report): Use it.  Make detection of selector
more robust.  Protect calls of `xml-escape-string' with 'noerror.

* test/infra/Makefile.in (subdir_template): Use "make -k ...".

* test/infra/gitlab-ci.yml (test-filenotify-gio):
Adapt make_params in order to get a JUnit test report.
(test-native-comp-speed0): Use "make -k ...".

* test/infra/test-jobs.yml: Regenerate.

* test/lisp/progmodes/perl-mode-tests.el (top):
Set `ert-load-file-name'.
2021-12-18 18:43:18 +01:00
Michael Albinus
041fff3d3d Handle missing JUnit test reports
* lisp/emacs-lisp/ert.el (ert-write-junit-test-report)
(ert-write-junit-test-summary-report): Handle missing JUnit test reports.
2021-12-17 20:02:21 +01:00
Michael Albinus
030a1a8bd5 Add errors in ert JUnit test reports
* lisp/emacs-lisp/ert.el (ert-write-junit-test-report)
(ert-write-junit-test-summary-report): Handle errors.
2021-12-15 18:54:31 +01:00
Michael Albinus
b30b33ed9b ERT can generate JUnit test reports
* .gitignore: Add test/**/*.xml.

* admin/notes/emba: Mention JUnit test report.

* etc/NEWS: ERT can generate JUnit test reports.

* lisp/emacs-lisp/ert.el (xml-escape-string): Autoload.
(ert-write-junit-test-report)
(ert-write-junit-test-summary-report): New defuns.
(ert-run-tests-batch, ert-summarize-tests-batch-and-exit): Call them.

* test/Makefile.in (clean): Remove *.xml.

* test/README: Mention $EMACS_TEST_JUNIT_REPORT environment variable.

* test/infra/Makefile.in ($(FILE)): Generate header commentary.
(clean): Remove.

* test/infra/gitlab-ci.yml (variables): Set EMACS_TEST_JUNIT_REPORT.
(.job-template): Use it in script and after_script.
(.build-template, .gnustep-template, .filenotify-gio-template)
(.native-comp-template): Adapt rules.
(.test-template): Trigger JUnit test report.

* test/infra/test-jobs.yml: Regenerate.
2021-12-13 16:09:56 +01:00
Filipp Gunbin
f8478dc133 Fixup for bug#51037
* lisp/emacs-lisp/ert.el (ert-batch-backtrace-line-length): Fix
docstring.
(ert-run-tests-batch): Remove redundand let-binding.
(ert-run-tests-interactively): Fix interactive spec.
2021-11-18 17:03:43 +03:00
Mattias Engdegård
67ffcc5c7f Signal an error for duplicated ERT tests (bug#51941)
Make `ert-deftest` fail with an error (in batch mode only) if an
existing test is redefined, because that is an easy mistake to make
and which leads to a test being discarded silently.

lisp/emacs-lisp/ert.el (ert-set-test, ert-deftest): Add check.
etc/NEWS: Announce.
2021-11-18 12:25:34 +01:00
Michael Herstine
977f102a49 Make results details in ert-run-tests-batch configurable
* lisp/emacs-lisp/ert.el (ert-batch-print-length)
(ert-batch-print-level,.ert-batch-backtrace-line-length)
(ert-batch-test, ert-run-tests-interactively): Added the three
variables, bound them to these settings when formatting batch
test results including backtraces. Removed the optional
parameters output-buffer & message-fn from
ert-run-tests-interactively.
* test/lisp/emacs-lisp/ert-tests.el
(ert-test-run-tests-interactively, ert-test-run-tests-batch): use
cl-letf to capture output, new tests resp.
* test/lisp/ert-x-tests.el (ert-test-run-tests-interactively-2):
Changed to use cl-letf to capture output instead of using
message-fn.
* lisp/emacs-lisp/backtrace.el (backtrace--line-length-or-nil)
(backtrace--print-func-and-args): Fixed a bug when setting
backtrace-line-length to nil by adding a new function to check
for that case & having backtrace--print-func-and-args use it.
* doc/misc/ert.texi: document the new variables & their usage
(bug#51037).
2021-11-16 08:48:24 +01:00
Lars Ingebrigtsen
67276f3403 Make debugging ert--erts-specifications easier
* lisp/emacs-lisp/ert.el (ert--erts-specifications): Strip text
properties from specs to make debugging easier.
2021-11-07 23:45:14 +01:00
Stefan Kangas
54b8ec4e6f Remove workaround for fixed Bug#6581 from ert
* lisp/emacs-lisp/ert.el (ert-equal-including-properties): Make
into obsolete function alias for 'equal-including-properties'.
* test/src/editfns-tests.el (format-properties):
* test/lisp/emacs-lisp/ert-x-tests.el (ert-propertized-string)
(ert-test-run-tests-interactively-2): Don't use above obsolete
name.

(ert--explain-equal-including-properties-rec): New function.
(ert--explain-equal-including-properties): Use as an explainer for
'equal-including-properties' now that Bug#6581 is fixed.

* test/lisp/emacs-lisp/ert-tests.el
(ert-test-explain-equal-string-properties): Expand test.
(ert-test-equal-including-properties): Merge test into above
expanded test.
2021-10-31 03:02:32 +01:00
Stefan Kangas
8227d1273e Fix bug with string values in equal-including-properties
* src/intervals.c (intervals_equal_1): Factor out from
intervals_equal.  Optionally use Fequal for comparison of string
values in property lists.
(intervals_equal): Update for the above.
(compare_string_intervals): Use the above optional Fequal comparison
to fix a bug where 'equal-including-properties' compared strings with
eq, instead of equal.  (Bug#6581)
* test/src/fns-tests.el (fns-tests-equal-including-properties)
(fns-tests-equal-including-properties/string-prop-vals): New tests.

* test/lisp/emacs-lisp/ert-tests.el
(ert-test-equal-including-properties): Remove parts testing
'equal-including-properties'.
* lisp/emacs-lisp/ert.el (ert-equal-including-properties): Add
FIXME that this should be removed.
2021-10-31 03:02:32 +01:00
Lars Ingebrigtsen
713e19a60a Fix parsing of erts files
* lisp/emacs-lisp/ert.el (ert-test-erts-file): Fix progress
through a test file (bug#51409).
2021-10-27 16:13:30 +02:00
Glenn Morris
8aceb37b47 Merge from origin/emacs-28
1a1b206a8b Adapt the recent 'num_processors' change to MS-Windows
7cb4637923 Minor fix to clarify a sentence in emacs-lisp-intro
ab60144ea3 ; Pacify recent shorthand unused lexarg warnings.
e9df86004f Make tty-run-terminal-initialization load the .elc file (i...
07edc28bdb Fix ert errors when there's a test that binds `debug-on-er...
96278de8ac New function num-processors
575e626105 Add symbol property 'save-some-buffers-function' (bug#46374)
a3e10af95c Keep reading when typed RET in read-char-from-minibuffer a...
013e3be832 * lisp/userlock.el (ask-user-about-supersession-threat): A...
ae61d7a57d Fix point positioning on mouse clicks with non-zero line-h...
4c7e74c386 Complete shorthands to longhands for symbol-completing tables
c2513c5d0d Add new failing test for bug#51089
1d1e96377c ; * lisp/emacs-lisp/shortdoc.el: Fix typo.
6bf29072e9 Avoid mapping file names through 'substring'
bcce93f04c Update to Org 9.5-46-gb71474
5d408f1a24 Expanded testing of MH-E with multiple MH variants
b497add971 Fix Seccomp filter for newer GNU/Linux systems (Bug#51073).
75d9fbec88 Tramp code cleanup

# Conflicts:
#	etc/NEWS
#	test/lisp/progmodes/elisp-mode-tests.el
2021-10-11 08:04:57 -07:00
Lars Ingebrigtsen
07edc28bdb Fix ert errors when there's a test that binds `debug-on-error'
* lisp/emacs-lisp/ert.el (ert--run-test-internal): Don't infloop
on errors when signalling errors (bug#51131).
2021-10-11 11:14:26 +02:00
Glenn Morris
2dc88a27a4 Merge from origin/emacs-28
63abe976ce (origin/emacs-28) Document minibuffer-default-prompt-forma...
b5afbedc90 Backward compatibility option for 'nobreak-char-display'
ea1b728a06 ; * lisp/dired.el: Fix typo.
984eafeb98 Unbreak the build after Gnulib update
5946370cd1 Check, whether an FUSE mount has been broken in Tramp
90575a6c0c Disable 'nobreak-char-display' in Eldoc buffers
570e2c9a17 Fix small error in comint-send-input
fd7bb31412 Update documentation of search-whitespace-regexp
1f4ced47a1 Fix cc-compat.el syntax error
b431f54c1b Mention `seq-uniq' in `delete-dups' documentation
0a7bab689c ; Minor stylistic fixes found by checkdoc
e2861e2d08 ; * etc/NEWS: Fix typo.
1a65d49931 Port recent Gnulib changes to MS-Windows
68a256c892 Update from Gnulib
63cb65dcce * Fix mh tests for native comp builds (bug#50975)
e606cc6f40 * Fix `batch-native-compile' not to spawn a subprocess
894dfe70da Fix native-compilation build from tarball on Cygwin
2ce5e08058 Remove U+FE0F from script-representative-chars

# Conflicts:
#	etc/NEWS
2021-10-05 07:50:22 -07:00
Stefan Kangas
0a7bab689c ; Minor stylistic fixes found by checkdoc 2021-10-05 02:06:57 +02:00
Mattias Engdegård
0f2df36559 Run ERT tests with lexical-binding bound to t
* lisp/emacs-lisp/ert.el (ert-deftest, ert--run-test-internal):
Use t rather than the ambient file value for `lexical-binding` to
avoid bad lexbind coverage by mistake.
2021-10-04 18:11:40 +02:00
Lars Ingebrigtsen
4b90aacf79 Refactor out ert-test--erts-test
* lisp/emacs-lisp/ert.el (ert-test--erts-test): Refactor out the
bulk of the function for easier reuse.
2021-10-01 15:23:32 +02:00
Lars Ingebrigtsen
295d552e4e Allow skipping erts tests
* doc/misc/ert.texi (erts files): Document it.

* lisp/emacs-lisp/ert.el (ert-test-erts-file): Allow skipping tests.
2021-10-01 13:20:20 +02:00
Lars Ingebrigtsen
1a65320903 Add new functionality to write buffer-based tests
* doc/misc/ert.texi (erts files): New node.

* lisp/files.el (auto-mode-alist): Map .erts to erts-mode.

* lisp/emacs-lisp/ert.el (ert-test-erts-file): New function.

* lisp/emacs-lisp/ert.el (ert--erts-specifications)
(ert--erts-unquote): Helper functions.

* lisp/progmodes/erts-mode.el: New mode and file.
2021-10-01 12:17:47 +02:00
Stefan Kangas
b8b1d8dee7 Add fast-path to ert--explain-string-equal
* lisp/emacs-lisp/ert.el (ert--explain-string-equal): Add fast-path to
avoid doing extra work.
Problem reported by Mattias Engdegård <mattiase@acm.org>.
2021-09-26 15:30:40 +02:00
Stefan Kangas
f4ea15907a ert: Add basic explainer for string-equal
* lisp/emacs-lisp/ert.el (ert--explain-string-equal): Add basic
explainer for 'string-equal' based on 'ert--explain-equal'.
2021-09-26 13:21:53 +02:00
Mattias Engdegård
0b099e34dc Use ambient lexical-binding value in ert-deftest body (bug#50738)
* lisp/emacs-lisp/ert.el (ert-deftest):
Evaluate the body of `ert-deftest` with the `lexical-binding` value of
the source file (or more precisely the value in force when the
definition is evaluated), which is what everyone expected, instead of
always using dynamic binding which is what they got until now.
* test/lisp/emacs-lisp/ert-tests.el
(ert-test-deftest-lexical-binding-t): New test.
2021-09-25 20:25:01 +02:00
Stefan Kangas
dd1220b969 ; More stylistic docfixes in emacs-lisp/*.el found by checkdoc 2021-09-18 13:14:50 +02:00
Michael Albinus
527bab054f Handle test environment variables
* lisp/emacs-lisp/ert.el (ert-summarize-tests-batch-and-exit):
Check also for EMACS_EMBA_CI.

* test/README (SELECTOR): Mention EMACS_TEST_VERBOSE.

* test/infra/gitlab-ci.yml (variables): Set EMACS_TEST_VERBOSE.
2021-07-01 13:43:44 +02:00
Mattias Engdegård
52528d6a16 Print newlines as \n instead of \12 in ERT results
This makes test errors unquestionably more readable.  The change also
makes FF print as \f; other controls still use octal escapes.

* lisp/emacs-lisp/ert.el (ert--pp-with-indentation-and-newline):
Run `pp` with `pp-escape-newlines` set to `t`.
2021-06-25 19:55:27 +02:00
Mattias Engdegård
1283e1db9b Don't call ERT explainer on error
* lisp/emacs-lisp/ert.el (ert--expand-should-1): If the predicate form
signals an error, don't call an explainer because the arguments passed
(the error and error argument, respectively) do not make any sense to
the explainer at all.
2021-06-24 20:48:41 +02:00
Julian Scheid
8be9d4a156 Allow ERT tests to output the failure reasons, too
* lisp/emacs-lisp/ert.el (ert-reason-for-test-result): New function.
(ert-run-tests-batch): Output failure or skip reason  (bug#47071).
2021-06-15 17:01:57 +02:00
Stefan Kangas
4cb52200cb Fix duplicate ":" in ert-find-test-other-window prompt
* lisp/emacs-lisp/ert.el (ert-find-test-other-window): Don't insert
duplicate ":" in prompt.
2021-03-10 04:34:53 +01:00
Stefan Kangas
dc2688acb3 Do mode tagging in ert.el 2021-03-10 04:34:32 +01:00
Philipp Stephani
f4452bb814 Fix structure of condition object in nested 'ert-fail'.
See the test 'ert-test-fail' for the expected structure.

* lisp/emacs-lisp/ert.el (ert--should-signal-hook): Condition list
should be (SYMBOL . DATA), not (SYMBOL DATA).
* test/lisp/emacs-lisp/ert-tests.el (ert-test-fail-inside-should): Fix
unit test.
2021-03-08 14:30:24 +01:00
Stefan Monnier
a0f60293d9 Fix misuses of byte-compile-macro-environment
These seem to be left overs from Emacs<24 when `macroexpand-all` was
implemented in the CL library and hence the macros's evaluation
environment could come from different places depending on the
circumstance (either `byte-compile-macro-environment`, or
`cl-macro-environment`, or ...).

`byte-compile-macro-environment` contains definitions which expand to
code that is only understood by the rest of the byte-compiler,
so using it for code which isn't being byte-compiled leads to errors
such as references to non-existing function
`internal--with-suppressed-warnings`.

* lisp/emacs-lisp/cl-extra.el (cl-prettyexpand): Remove left-over
binding from when `macroexpand-all` was implemented in the CL library.

* lisp/emacs-lisp/ert.el (ert--expand-should-1):
* lisp/emacs-lisp/cl-macs.el (cl--compile-time-too): Properly preserve the
macroexpand-all-environment.
(cl--macroexp-fboundp): Pay attention to `cl-macrolet` macros as well.
2021-03-01 12:18:49 -05:00
Stefan Kangas
54af0d4298 Remove redundant requires of easymenu
* lisp/allout.el:
* lisp/emacs-lisp/edebug.el:
* lisp/emacs-lisp/ert.el:
* lisp/erc/erc-menu.el:
* lisp/help-mode.el:
* lisp/net/dictionary.el:
* lisp/nxml/rng-nxml.el:
* lisp/progmodes/ebrowse.el:
* lisp/progmodes/meta-mode.el:
* lisp/progmodes/prolog.el:
* lisp/progmodes/ps-mode.el:
* lisp/progmodes/vera-mode.el:
* lisp/wid-browse.el: Remove redundant require of easymenu.  We only
use the autoloaded macro 'easy-menu-define' here.
2021-02-26 15:52:26 +01:00