Subject: bug#29187: flymake ruby and perl tests fail on rhel7.4

From: Glenn Morris <[email-masked]>
Date: Tue, 07 Nov 2017 20:42:02 -0500

João Távora wrote:

> Wow, subtle stuff. My ruby (2.3) doesn't crash. Does yours also fail if
> you use a absolute path after -wc instead of a relative one?

Still fails.

> So I guess all that's missing is a fix to the ruby case. If the absolute
> path doesn't fix it, I think we can fake a dummy HOME

This works for me:

--- i/test/lisp/progmodes/flymake-tests.el
+++ w/test/lisp/progmodes/flymake-tests.el
@@ -120,11 +120,17 @@ flymake-tests--wait-for-backends
 (ert-deftest ruby-backend ()
   "Test the ruby backend"
   (skip-unless (executable-find "ruby"))
-  (flymake-tests--with-flymake ("test.rb")
-    (flymake-goto-next-error)
-    (should (eq 'flymake-warning (face-at-point)))
-    (flymake-goto-next-error)
-    (should (eq 'flymake-error (face-at-point)))))
+  ;; Some versions of ruby fail if HOME doesn't exist (bug#29187).
+  (let* ((tempdir (make-temp-file "flymake-tests-ruby" t))
+         (process-environment (cons (format "HOME=%s" tempdir)
+                                    process-environment)))
+    (unwind-protect
+        (flymake-tests--with-flymake ("test.rb")
+          (flymake-goto-next-error)
+          (should (eq 'flymake-warning (face-at-point)))
+          (flymake-goto-next-error)
+          (should (eq 'flymake-error (face-at-point))))
+      (delete-directory tempdir t))))
 
 (ert-deftest different-diagnostic-types ()
   "Test GCC warning via function predicate."