Subject: Re: bug#79257: 31.0.50; flymake's ruby-backend test fails with ruby 3.4.5

From: john muhl <[email-masked]>
Date: Sun, 24 Aug 2025 11:35:05 -0500

The cause is a change in the check output of new Ruby versions
which include the location of the executable; e.g.

  # Ruby 3.3.8
  -:3: warning: statement not reached
  -:6: syntax error, unexpected end-of-input, expecting `end' or dummy end

  # Ruby 3.4.5
  -:3: warning: statement not reached
  /usr/bin/ruby: -:5: syntax errors found (SyntaxError)

Here’s a patch that updates the regex to account for it. Tests
pass with both Ruby 3.3 and 3.4.

>From 85b63d01fa2f080cfa360105b913ba5532c8e1e9 Mon Sep 17 00:00:00 2001
From: john muhl <[email-masked]>
Date: Sun, 24 Aug 2025 11:29:43 -0500
Subject: [PATCH] Fix 'ruby-flymake-simple' for Ruby 3.4 (Bug#79257)

* lisp/progmodes/ruby-mode.el (ruby-flymake-simple): Update
regular expression to handle new versions of Ruby including the
location of the executable in the output.
---
 lisp/progmodes/ruby-mode.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index 1079aad1a55..5c8a4025419 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -2516,7 +2516,7 @@ ruby-flymake-simple
      (goto-char (point-min))
      (cl-loop
       while (search-forward-regexp
-             "^\\(?:.*\\.rb\\|-\\):\\([0-9]+\\): \\(.*\\)$"
+             "^\\(?:.*ruby: \\)?\\(?:.*\\.rb\\|-\\):\\([0-9]+\\): \\(.*\\)$"
              nil t)
       for msg = (match-string 2)
       for (beg . end) = (flymake-diag-region
-- 
2.50.1

john muhl <[email-masked]> writes:

> The test passes with Ruby 3.3.8:
>
> $ ruby --version
> ruby 3.3.8 (2025-04-09 revision b200bad6cd) [x86_64-linux-gnu]
>
> $ make -C test lisp/progmodes/flymake-tests.log
> make: Entering directory '/root/emacs/test'
>   GEN      lisp/progmodes/flymake-tests.log
> make: Leaving directory '/root/emacs/test'
>
> $ cat test/lisp/progmodes/flymake-tests.log
> Running 10 tests (2025-08-16 20:14:31+0000, selector `(not (or (tag :unstable) (tag :nativecomp)))')
>    passed   1/10  different-diagnostic-types (1.064348 sec)
>    passed   2/10  dummy-backends (1.001868 sec)
>    passed   3/10  eob-region-and-trailing-newline (0.000263 sec)
>    passed   4/10  foreign-diagnostics (2.039984 sec)
>    passed   5/10  included-c-header-files (2.038547 sec)
>    passed   6/10  perl-backend (1.013309 sec)
>    passed   7/10  recurrent-backend (1.002002 sec)
>    passed   8/10  ruby-backend (1.015112 sec)
>    passed   9/10  warning-predicate-function-gcc (1.017387 sec)
>    passed  10/10  warning-predicate-rx-gcc (1.019503 sec)
>
> Ran 10 tests, 10 results as expected, 0 unexpected (2025-08-16 20:14:42+0000, 11.213646 sec)
>
> Then fails with 3.4.5:
>
> $ ruby --version
> ruby 3.4.5 (2025-07-16 revision 20cda200d3) +PRISM [x86_64-linux]
>
> $ make -C test lisp/progmodes/flymake-tests.log
> make[1]: Entering directory '/root/emacs/test'
>   GEN      lisp/progmodes/flymake-tests.log
> Running 10 tests (2025-08-16 20:09:51+0000, selector `(not (or (tag :unstable) (tag :nativecomp)))')
>    passed   1/10  different-diagnostic-types (1.066408 sec)
>    passed   2/10  dummy-backends (1.001843 sec)
>    passed   3/10  eob-region-and-trailing-newline (0.000216 sec)
>    passed   4/10  foreign-diagnostics (2.041202 sec)
>    passed   5/10  included-c-header-files (2.038718 sec)
>    passed   6/10  perl-backend (1.014080 sec)
>    passed   7/10  recurrent-backend (1.002050 sec)
> Test ruby-backend backtrace:
>   signal(ert-test-failed (((should (eq 'flymake-error (face-at-point))
>   ert-fail(((should (eq 'flymake-error (face-at-point))) :form (eq fly
>   (if (unwind-protect (setq value-41 (apply fn-39 args-40)) (setq form
>   (let (form-description-43) (if (unwind-protect (setq value-41 (apply
>   (let ((value-41 'ert-form-evaluation-aborted-42)) (let (form-descrip
>   (let* ((fn-39 #'eq) (args-40 (condition-case err (list 'flymake-erro
>   #f(lambda () [t] (flymake-goto-next-error) (let* ((fn-34 #'eq) (args
>   funcall(#f(lambda () [t] (flymake-goto-next-error) (let* ((fn-34 #'e
>   (save-excursion (if sev-pred-supplied-p (progn (setq flymake-proc-di
>   (save-current-buffer (set-buffer buffer) (save-excursion (if sev-pre
>   (unwind-protect (save-current-buffer (set-buffer buffer) (save-excur
>   (let* ((file (expand-file-name file flymake-tests-data-directory)) (
>   (progn (let ((--cl-keys-- --cl-rest--)) (while --cl-keys-- (cond ((m
>   (let* ((sev-pred-supplied-p (plist-member --cl-rest-- ':severity-pre
>   flymake-tests--call-with-fixture(#f(lambda () [t] (flymake-goto-next
>   (let* ((process-environment (cons (format "HOME=%s" tempdir) process
>   (progn (let* ((process-environment (cons (format "HOME=%s" tempdir) 
>   (unwind-protect (progn (let* ((process-environment (cons (format "HO
>   (let* ((coding-system-for-write nil) (temp-file (file-name-as-direct
>   #f(lambda () [ruby-mode-hook t] (let* ((fn-29 #'executable-find) (ar
>   #f(compiled-function () #<bytecode 0xf2de8ace0c80c71>)()
>   handler-bind-1(#f(compiled-function () #<bytecode 0xf2de8ace0c80c71>
>   ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
>   ert-run-test(#s(ert-test :name ruby-backend :documentation "Test the
>   ert-run-or-rerun-test(#s(ert--stats :selector ... :tests ... :test-m
>   ert-run-tests((not (or (tag :unstable) (tag :nativecomp))) #f(compil
>   ert-run-tests-batch((not (or (tag :unstable) (tag :nativecomp))))
>   ert-run-tests-batch-and-exit((not (or (tag :unstable) (tag :nativeco
>   eval((ert-run-tests-batch-and-exit '(not (or (tag :unstable) (tag :n
>   command-line-1(("-L" ":." "-l" "ert" "--eval" "(setq treesit-extra-l
>   command-line()
>   normal-top-level()
> Test ruby-backend condition:
>     (ert-test-failed
>      ((should (eq 'flymake-error (face-at-point))) :form
>       (eq flymake-error flymake-warning) :value nil))
>    FAILED   8/10  ruby-backend (1.013506 sec) at lisp/progmodes/flymake-tests.el:123
>    passed   9/10  warning-predicate-function-gcc (1.017136 sec)
>    passed  10/10  warning-predicate-rx-gcc (1.019550 sec)
>
> Ran 10 tests, 9 results as expected, 1 unexpected (2025-08-16 20:10:02+0000, 11.275721 sec)
>
> 1 unexpected results:
>    FAILED  ruby-backend