Subject: bug#78552: [PATCH] Add baseline pass/fail tests for `ert-test-erts-file'

From: Roi Martin <[email-masked]>
Date: Thu, 22 May 2025 17:13:54 +0200

Tags: patch

This patch adds tests to verify that the `ert-test-erts-file' function
can detect both passing a failing test cases.  This provides a baseline
to test other erts features like test specifications (e.g. `Skip' or
`Code').  It complements the tests introduced in Bug#76839, which tested
a bug fix for `Skip'.

>From 1549198120051afaa1016627a1833d6497d4bc65 Mon Sep 17 00:00:00 2001
From: Roi Martin <[email-masked]>
Date: Sun, 20 Apr 2025 08:05:56 +0200
Subject: [PATCH] Add baseline pass/fail tests for `ert-test-erts-file'

* test/lisp/emacs-lisp/ert-tests.el (ert-test-erts-pass)
(ert-test-erts-fail): Add tests to verify that the `ert-test-erts-file'
function can detect both passing a failing test cases.
* test/lisp/emacs-lisp/ert-resources/erts-fail.erts:
* test/lisp/emacs-lisp/ert-resources/erts-pass.erts:
Add test data.
---
 test/lisp/emacs-lisp/ert-resources/erts-fail.erts |  7 +++++++
 test/lisp/emacs-lisp/ert-resources/erts-pass.erts |  7 +++++++
 test/lisp/emacs-lisp/ert-tests.el                 | 11 +++++++++++
 3 files changed, 25 insertions(+)
 create mode 100644 test/lisp/emacs-lisp/ert-resources/erts-fail.erts
 create mode 100644 test/lisp/emacs-lisp/ert-resources/erts-pass.erts

diff --git a/test/lisp/emacs-lisp/ert-resources/erts-fail.erts b/test/lisp/emacs-lisp/ert-resources/erts-fail.erts
new file mode 100644
index 000000000000..12d73454f7b0
--- /dev/null
+++ b/test/lisp/emacs-lisp/ert-resources/erts-fail.erts
@@ -0,0 +1,7 @@
+Name: fail
+
+=-=
+FOO
+=-=
+BAR
+=-=-=
diff --git a/test/lisp/emacs-lisp/ert-resources/erts-pass.erts b/test/lisp/emacs-lisp/ert-resources/erts-pass.erts
new file mode 100644
index 000000000000..6f98150d4d9f
--- /dev/null
+++ b/test/lisp/emacs-lisp/ert-resources/erts-pass.erts
@@ -0,0 +1,7 @@
+Name: pass
+
+=-=
+FOO
+=-=
+FOO
+=-=-=
diff --git a/test/lisp/emacs-lisp/ert-tests.el b/test/lisp/emacs-lisp/ert-tests.el
index 467d01fed9d2..048ab931f501 100644
--- a/test/lisp/emacs-lisp/ert-tests.el
+++ b/test/lisp/emacs-lisp/ert-tests.el
@@ -1030,6 +1030,17 @@ ert-test-with-test-buffer-selected/buffer-name
                  (ert-with-test-buffer (:name "foo" :selected t)
                    (buffer-name)))))
 
+(ert-deftest ert-test-erts-pass ()
+  "Test that `ert-test-erts-file' reports test case passed."
+  (ert-test-erts-file (ert-resource-file "erts-pass.erts")
+                      (lambda () ())))
+
+(ert-deftest ert-test-erts-fail ()
+  "Test that `ert-test-erts-file' reports test case failed."
+  (should-error (ert-test-erts-file (ert-resource-file "erts-fail.erts")
+                                    (lambda () ()))
+                :type 'ert-test-failed))
+
 (ert-deftest ert-test-erts-skip-one ()
   "Test that Skip does not affect subsequent test cases (Bug#76839)."
   (should-error (ert-test-erts-file (ert-resource-file "erts-skip-one.erts")
-- 
2.49.0