Subject: [bug#29030] [PATCH] perl-sys-cpu: Mark cpu_type and cpu_clock tests as TODO.

From: Eric Bavier <[email-masked]>
Date: Fri, 27 Oct 2017 20:40:12 +0000

Hello Guix,

On my system, perl-sys-cpu's tests fail because of differences in the information available in /proc/cpuinfo.

Debian's patch for this perl module seemed nice: rather than trying to fix the related functions, just concede that the module is mostly used just to read the number of available processors and mark the other tests as "TODO".

This patch replaces the test file with debian's using an origin snippet.

Eric Bavier, Scientific Libraries, Cray Inc.
diff --git a/gnu/packages/perl.scm b/gnu/packages/perl.scm
index 815a212..7d1fda7 100644
--- a/gnu/packages/perl.scm
+++ b/gnu/packages/perl.scm
@@ -2,7 +2,7 @@
 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <[email-masked]>
 ;;; Copyright © 2013 Andreas Enge <[email-masked]>
 ;;; Copyright © 2015, 2016, 2017 Ricardo Wurmus <[email-masked]>
-;;; Copyright © 2015, 2016 Eric Bavier <[email-masked]>
+;;; Copyright © 2015, 2016, 2017 Eric Bavier <[email-masked]>
 ;;; Copyright © 2015 Eric Dvorsak <[email-masked]>
 ;;; Copyright © 2016 Mark H Weaver <[email-masked]>
 ;;; Copyright © 2016 Jochem Raat <[email-masked]>
@@ -6665,7 +6665,34 @@ statements: @code{switch} and @code{case}.")
                                   "Sys-CPU-" version ".tar.gz"))
               (sha256
                (base32
-                "1r6976bs86j7zp51m5vh42xlyah951jgdlkimv202413kjvqc2i5"))))
+                "1r6976bs86j7zp51m5vh42xlyah951jgdlkimv202413kjvqc2i5"))
+              (modules '((guix build utils)))
+              (snippet
+               '(begin
+                  ;; Replace test with one that marks cpu_clock and cpu_type
+                  ;; as TODO.  Borrowed from Debian.
+                  (call-with-output-file "t/Sys-CPU.t"
+                    (lambda (port)
+                      (format port "#!/usr/bin/perl
+
+use Test::More tests => 4;
+
+BEGIN { use_ok('Sys::CPU'); }
+
+$number = &Sys::CPU::cpu_count();
+ok( defined($number), \"CPU Count: $number\" );
+
+TODO: {
+    local $TODO = \"/proc/cpuinfo doesn't always report 'cpu MHz' or 'clock' or 'bogomips' ...\";
+    $speed = &Sys::CPU::cpu_clock();
+    ok( defined($speed), \"CPU Speed: $speed\" );
+}
+
+TODO: {
+    local $TODO = \"/proc/cpuinfo doesn't always report 'model name' or 'machine' ...\";
+    $type = &Sys::CPU::cpu_type();
+    ok( defined($type), \"CPU Type:  $type\" );
+}~%")))))))
     (build-system perl-build-system)
     (synopsis "Perl extension for getting CPU information")
     (description