Subject: [PATCH v4 2/3] gnu: gnulib: Enable tests.

From: Vivien Kraus <[email-masked]>
Date: Fri, 30 Dec 2022 12:30:54 +0100

* gnu/packages/build-tools.scm (gnulib-checkout) [fix-tests]: New
phase. Create a git repository so that every file is committed.
* gnu/packages/build-tools.scm (gnulib-checkout): [disable-failing-tests]: New
phase.
* gnu/packages/build-tools.scm (gnulib-checkout): [install]: Delete the fake
git repository.
* gnu/packages/build-tools.scm (gnulib-checkout): [native-inputs]: Add more
tools for the tests.
---
 gnu/packages/build-tools.scm | 54 +++++++++++++++++++++++++++++++++---
 1 file changed, 50 insertions(+), 4 deletions(-)

diff --git a/gnu/packages/build-tools.scm b/gnu/packages/build-tools.scm
index bde4ee0973..5fa2b7234c 100644
--- a/gnu/packages/build-tools.scm
+++ b/gnu/packages/build-tools.scm
@@ -43,11 +43,14 @@ (define-module (gnu packages build-tools)
   #:use-module (guix build-system cmake)
   #:use-module (gnu packages)
   #:use-module (gnu packages adns)
+  #:use-module (gnu packages autotools)
   #:use-module (gnu packages base)
   #:use-module (gnu packages bash)
   #:use-module (gnu packages check)
+  #:use-module (gnu packages code)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages cpp)
+  #:use-module (gnu packages cppi)
   #:use-module (gnu packages elf)
   #:use-module (gnu packages linux)
   #:use-module (gnu packages lisp)
@@ -830,16 +833,59 @@ (define*-public (gnulib-checkout #:key
      (list
       #:phases
       #~(modify-phases %standard-phases
+          (add-after 'unpack 'fix-tests
+            (lambda _
+              (substitute* "Makefile"
+                (("-f maint.mk syntax-check")
+                 "_gl-Makefile=yes -f maint.mk syntax-check"))
+              (invoke "git" "init")
+              (invoke "git" "config" "user.name" "Guix")
+              (invoke "git" "config" "user.email" "guix@localhost")
+              (invoke "git" "add" ".")
+              (invoke "git" "commit" "-m"
+                      "Syntax checks are only run against committed files, so commit everything.")))
+          (add-after 'fix-tests 'disable-failing-tests
+            (lambda _
+              (substitute* "cfg.mk"
+                (("local-checks-to-skip =")
+                 "local-checks-to-skip = \\
+  sc_Wundef_boolean \\
+  sc_file_system \\
+  sc_indent \\
+  sc_keep_gnulib_texi_files_mostly_ascii \\
+  sc_prohibit_assert_without_use \\
+  sc_prohibit_close_stream_without_use \\
+  sc_prohibit_defined_have_decl_tests \\
+  sc_prohibit_doubled_word \\
+  sc_prohibit_empty_lines_at_EOF \\
+  sc_prohibit_intprops_without_use \\
+  sc_prohibit_openat_without_use \\
+  sc_prohibit_test_minus_ao \\
+  sc_unportable_grep_q"))
+              (substitute* "Makefile"
+                (("sc_check_sym_list")
+                 "disabled_check_sym_list")
+                (("sc_cpp_indent_check")
+                 "disabled_cpp_indent_check")
+                (("sc_check_copyright")
+                 "disabled_check_copyright")
+                (("sc_prohibit_AC_LIBOBJ_in_m4")
+                 "disabled_prohibit_AC_LIBOBJ_in_m4")
+                (("sc_prefer_ac_check_funcs_once")
+                 "disabled_prefer_ac_check_funcs_once")
+                (("sc_prohibit_leading_TABs")
+                 "disabled_prohibit_leading_TABs"))))
           (delete 'configure)
           (replace 'install
             (lambda _
               (install-file "gnulib-tool"
                             (string-append #$output "/bin"))
-              (copy-recursively "." (string-append #$output "/src/gnulib/")))))
-      #:tests? #f)) ;; Tests are syntax and indentation checks for the
-    ;; maintainer. And they are failing.
+              (delete-file-recursively ".git")
+              (copy-recursively "." (string-append #$output "/src/gnulib/")))))))
     (inputs ;; Shebangs for some auxiliary build files.
-     (list python perl clisp))
+     (list python perl clisp
+           ;; Programs for the tests:
+           cppi indent git autoconf))
     (home-page "https://www.gnu.org/software/gnulib/")
     (synopsis "Source files to share among distributions")
     (description
-- 
2.38.1