]> git.eshelyaron.com Git - emacs.git/commitdiff
Factor out function to check for clang in tests
authorStefan Kangas <stefan@marxist.se>
Mon, 31 Jan 2022 06:42:50 +0000 (07:42 +0100)
committerStefan Kangas <stefan@marxist.se>
Mon, 31 Jan 2022 06:42:50 +0000 (07:42 +0100)
This also stops a flymake test from failing on my machine.

* lisp/emacs-lisp/ert-x.el (ert-gcc-is-clang-p): New function
factored out from ...
* test/lisp/progmodes/flymake-tests.el (flymake-tests--gcc-is-clang):
* test/lisp/cedet/semantic/bovine/gcc-tests.el
(semantic-gcc-test-output-parser-this-machine): ... here.

* test/lisp/progmodes/flymake-tests.el (different-diagnostic-types)
(included-c-header-files):
* test/lisp/cedet/semantic/bovine/gcc-tests.el
(semantic-gcc-test-output-parser-this-machine): Use above new function.

lisp/emacs-lisp/ert-x.el
test/lisp/cedet/semantic/bovine/gcc-tests.el
test/lisp/progmodes/flymake-tests.el

index 2818d4b6cc725e3c01a51882b6c4d2a996f4a055..0e412a8d34e7f70fa63b33e1a40a5a36c2f914ab 100644 (file)
@@ -475,6 +475,14 @@ The same keyword arguments are supported as in
      :directory t
      ,@body))
 
+(defun ert-gcc-is-clang-p ()
+  "Return non-nil if the `gcc' command actually runs the Clang compiler."
+  ;; Some macOS machines run llvm when you type gcc.  (!)
+  ;; We can't even check if it's a symlink; it's a binary placed in
+  ;; "/usr/bin/gcc".  So we need to check the output.
+  (string-match "Apple \\(LLVM\\|[Cc]lang\\)\\|Xcode\\.app"
+                (shell-command-to-string "gcc --version")))
+
 (provide 'ert-x)
 
 ;;; ert-x.el ends here
index 2e61f91e58ca054bf74cbf596f7748df2a522c98..525843d9960a0dfee9cad9709fdd17ca36dd1789 100644 (file)
@@ -122,14 +122,9 @@ gcc version 2.95.2 19991024 (release)"
 
 (ert-deftest semantic-gcc-test-output-parser-this-machine ()
   "Test the output parser against the machine currently running Emacs."
-  (skip-unless (executable-find "gcc"))
+  (skip-unless (and (executable-find "gcc")
+                    (not (ert-gcc-is-clang-p))))
   (let ((semantic-gcc-test-strings (list (semantic-gcc-query "gcc" "-v"))))
-    ;; Some macOS machines run llvm when you type gcc.  (!)
-    ;; We can't even check if it's a symlink; it's a binary placed in
-    ;; "/usr/bin/gcc".  So check the output and just skip this test if
-    ;; it looks like that's the case.
-    (unless (string-match "Apple \\(LLVM\\|clang\\)\\|Xcode\\.app"
-                          (car semantic-gcc-test-strings))
-        (semantic-gcc-test-output-parser))))
+    (semantic-gcc-test-output-parser)))
 
 ;;; gcc-tests.el ends here
index ced7b5aacedb4e6603553525932ca9043e9ee7cb..71b03b21e5c3b4e497ae506bc7de1328e8870e00 100644 (file)
@@ -140,15 +140,10 @@ SEVERITY-PREDICATE is used to setup
         (flymake-goto-next-error)
         (should (eq 'flymake-error (face-at-point)))))))
 
-(defun flymake-tests--gcc-is-clang ()
-  "Whether the `gcc' command actually runs the Clang compiler."
-  (string-match "[Cc]lang version "
-                (shell-command-to-string "gcc --version")))
-
 (ert-deftest different-diagnostic-types ()
   "Test GCC warning via function predicate."
   (skip-unless (and (executable-find "gcc")
-                    (not (flymake-tests--gcc-is-clang))
+                    (not (ert-gcc-is-clang-p))
                     (version<=
                      "5" (string-trim
                           (shell-command-to-string "gcc -dumpversion")))
@@ -173,7 +168,7 @@ SEVERITY-PREDICATE is used to setup
 (ert-deftest included-c-header-files ()
   "Test inclusion of .h header files."
   (skip-unless (and (executable-find "gcc")
-                    (not (flymake-tests--gcc-is-clang))
+                    (not (ert-gcc-is-clang-p))
                     (executable-find "make")))
   (let ((flymake-wrap-around nil))
     (flymake-tests--with-flymake