Patchwork Add googletest

login
register
mail settings
Submitter Lukas Gradl
Date June 2, 2016, 3:44 p.m.
Message ID <87h9dbegsl.fsf@openmailbox.org>
Download mbox | patch
Permalink /patch/12723/
State New
Headers show

Comments

Lukas Gradl - June 2, 2016, 3:44 p.m.
Hi Leo,

Leo Famulari <leo@famulari.name> writes:

> On Wed, Jun 01, 2016 at 09:57:53AM -0500, Lukas Gradl wrote:
>> Leo Famulari <leo@famulari.name> writes:
>> > I noticed in the README.md that upstream suggests use of GNU Make unless
>> > building from a Git checkout. Did you try that?
>> 
>> I have not tried that.  Their README.md left me under the impression
>> that tests are not supported useing GNU Make, but I just looked at their
>> Makefile and there are test targets, so I can try using the
>> gnu-build-system, if that is preferred?
>
> All else being equal, my personal preference is to use GNU tools. But
> otherwise, we should use the build system that upstream supports most
> fully. Especially, we should use the one that runs the tests.

Sounds good.  I switched to the gnu-build-system + autotools.  This also
made the "install" phase somewhat easier.

>> It seems they generate c++ header files using pump.py.  I will look into
>> that more.  Python is also needed for tests.
>
> Thanks for looking into that. If the header files are generated by other
> code, then we prefer to build them ourselves rather than use the
> "pre-compiled" headers.

The tool "pump.py" is distributed with the Googletest source.  It
appears to be a part of the source rather than a bundeled dependency and
the only reference to it that I found was in Googletest, so I would
assume it is a part of Googletest.  Therefore I did not create a
seperate package for that, but used the one provided in the Googletest
source tree.  With that, the pre-generated headers can be reproduced.
The attached patch does that.

Thank you!
Efraim Flashner - June 5, 2016, 1:12 p.m.
On Thu, Jun 02, 2016 at 10:44:58AM -0500, Lukas Gradl wrote:
> 
> Hi Leo,
> 
...
>
> The tool "pump.py" is distributed with the Googletest source.  It
> appears to be a part of the source rather than a bundeled dependency and
> the only reference to it that I found was in Googletest, so I would
> assume it is a part of Googletest.  Therefore I did not create a
> seperate package for that, but used the one provided in the Googletest
> source tree.  With that, the pre-generated headers can be reproduced.
> The attached patch does that.
> 
> Thank you!
> 

A couple last things I found, otherwise it looks great.

> From 7d4aaba39821130ba824c4b2f8bd236e0d1f1639 Mon Sep 17 00:00:00 2001
> From: Lukas Gradl <lgradl@openmailbox.org>
> Date: Thu, 2 Jun 2016 10:36:17 -0500
> Subject: [PATCH] gnu: Add googletest.
> 
> * gnu/packages/check.scm (googletest): New variable.
> ---
>  gnu/packages/check.scm | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 64 insertions(+)
> 
> diff --git a/gnu/packages/check.scm b/gnu/packages/check.scm
> index 9eef7a9..4971c71 100644
> --- a/gnu/packages/check.scm
> +++ b/gnu/packages/check.scm
> @@ -5,6 +5,7 @@
>  ;;; Copyright © 2015 Andreas Enge <andreas@enge.fr>
>  ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
>  ;;; Copyright © 2016 Roel Janssen <roel@gnu.org>
> +;;; Copyright © 2016 Lukas Gradl <lgradl@openmailbox.org>
>  ;;;
>  ;;; This file is part of GNU Guix.
>  ;;;
> @@ -24,6 +25,7 @@
>  (define-module (gnu packages check)
>    #:use-module (gnu packages)
>    #:use-module (gnu packages autotools)
> +  #:use-module (gnu packages python)
>    #:use-module (guix licenses)
>    #:use-module (guix packages)
>    #:use-module (guix download)
> @@ -193,3 +195,65 @@ in the code.  Cppcheck primarily detects the types of bugs that the compilers
>  normally do not detect.  The goal is to detect only real errors in the code
>  (i.e. have zero false positives).")
>      (license gpl3+)))
> +
> +(define-public googletest
> +  (package
> +    (name "googletest")
> +    (version "1.7.0")
> +    (source
> +     (origin
> +       (method url-fetch)
> +       (uri
> +        (string-append
> +         "https://github.com/google/googletest/archive/release-"
> +         version ".tar.gz"))

add:    (file-name (string-append name "-" version ".tar.gz"))

> +       (sha256
> +        (base32
> +         "1k0nf1l9cb3prdmsvaajl5i31bx86c1mw0d5jgzykz7rzm36afpp"))))
> +    (build-system gnu-build-system)
> +    (native-inputs
> +     `(("python-2" ,python-2)
> +       ("autoconf" ,autoconf)
> +       ("automake" ,automake)
> +       ("libtool" ,libtool)))
> +    (arguments
> +     `( #:phases
> +       (modify-phases %standard-phases
> +         (add-before 'configure 'autoconf
> +                      (lambda _
> +                        (zero? (system* "autoreconf" "-vfi"))))
> +         (add-before 'autoconf 'generate-headers
> +           (lambda _
> +             (begin
> +               (delete-file "include/gtest/gtest-param-test.h")
> +               (system* "python2" "scripts/pump.py"
> +                        "include/gtest/gtest-param-test.h.pump")
> +               (delete-file "include/gtest/internal/gtest-tuple.h")
> +               (system* "python2" "scripts/pump.py"
> +                        "include/gtest//internal/gtest-tuple.h.pump")
> +               (delete-file
> +                "include/gtest/internal/gtest-param-util-generated.h")
> +               (system*
> +                "python2" "scripts/pump.py"
> +                "include/gtest/internal/gtest-param-util-generated.h.pump")
> +               (delete-file "include/gtest/internal/gtest-type-util.h")
> +               (system* "python2" "scripts/pump.py"
> +                        "include/gtest/internal/gtest-type-util.h.pump"))))
> +         (replace 'install
> +           (lambda _
> +             (let ((out (assoc-ref %outputs "out"))
> +                   (version version))
                                      ^
you don't actually use this variable --

> +               (begin
> +                 (install-file "lib/.libs/libgtest_main.a"
> +                               (string-append out "/lib"))
> +                 (install-file "lib/.libs/libgtest.a"
> +                               (string-append out "/lib"))
> +                 (copy-recursively
> +                  (string-append "include")

don't need the string-append above

> +                  (string-append out "/include")))))))))
> +    (home-page "https://github.com/google/googletest/")
> +    (synopsis "Test discovery and XUnit test framework")
> +    (description "Google Test features an XUnit test framework, automated test
> +discovery, death tests, assertions, parameterized tests and XML test report
> +generation.")
> +    (license bsd-3)))
> -- 
> 2.7.4
>

Patch

From 7d4aaba39821130ba824c4b2f8bd236e0d1f1639 Mon Sep 17 00:00:00 2001
From: Lukas Gradl <lgradl@openmailbox.org>
Date: Thu, 2 Jun 2016 10:36:17 -0500
Subject: [PATCH] gnu: Add googletest.

* gnu/packages/check.scm (googletest): New variable.
---
 gnu/packages/check.scm | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)

diff --git a/gnu/packages/check.scm b/gnu/packages/check.scm
index 9eef7a9..4971c71 100644
--- a/gnu/packages/check.scm
+++ b/gnu/packages/check.scm
@@ -5,6 +5,7 @@ 
 ;;; Copyright © 2015 Andreas Enge <andreas@enge.fr>
 ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
 ;;; Copyright © 2016 Roel Janssen <roel@gnu.org>
+;;; Copyright © 2016 Lukas Gradl <lgradl@openmailbox.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -24,6 +25,7 @@ 
 (define-module (gnu packages check)
   #:use-module (gnu packages)
   #:use-module (gnu packages autotools)
+  #:use-module (gnu packages python)
   #:use-module (guix licenses)
   #:use-module (guix packages)
   #:use-module (guix download)
@@ -193,3 +195,65 @@  in the code.  Cppcheck primarily detects the types of bugs that the compilers
 normally do not detect.  The goal is to detect only real errors in the code
 (i.e. have zero false positives).")
     (license gpl3+)))
+
+(define-public googletest
+  (package
+    (name "googletest")
+    (version "1.7.0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri
+        (string-append
+         "https://github.com/google/googletest/archive/release-"
+         version ".tar.gz"))
+       (sha256
+        (base32
+         "1k0nf1l9cb3prdmsvaajl5i31bx86c1mw0d5jgzykz7rzm36afpp"))))
+    (build-system gnu-build-system)
+    (native-inputs
+     `(("python-2" ,python-2)
+       ("autoconf" ,autoconf)
+       ("automake" ,automake)
+       ("libtool" ,libtool)))
+    (arguments
+     `( #:phases
+       (modify-phases %standard-phases
+         (add-before 'configure 'autoconf
+                      (lambda _
+                        (zero? (system* "autoreconf" "-vfi"))))
+         (add-before 'autoconf 'generate-headers
+           (lambda _
+             (begin
+               (delete-file "include/gtest/gtest-param-test.h")
+               (system* "python2" "scripts/pump.py"
+                        "include/gtest/gtest-param-test.h.pump")
+               (delete-file "include/gtest/internal/gtest-tuple.h")
+               (system* "python2" "scripts/pump.py"
+                        "include/gtest//internal/gtest-tuple.h.pump")
+               (delete-file
+                "include/gtest/internal/gtest-param-util-generated.h")
+               (system*
+                "python2" "scripts/pump.py"
+                "include/gtest/internal/gtest-param-util-generated.h.pump")
+               (delete-file "include/gtest/internal/gtest-type-util.h")
+               (system* "python2" "scripts/pump.py"
+                        "include/gtest/internal/gtest-type-util.h.pump"))))
+         (replace 'install
+           (lambda _
+             (let ((out (assoc-ref %outputs "out"))
+                   (version version))
+               (begin
+                 (install-file "lib/.libs/libgtest_main.a"
+                               (string-append out "/lib"))
+                 (install-file "lib/.libs/libgtest.a"
+                               (string-append out "/lib"))
+                 (copy-recursively
+                  (string-append "include")
+                  (string-append out "/include")))))))))
+    (home-page "https://github.com/google/googletest/")
+    (synopsis "Test discovery and XUnit test framework")
+    (description "Google Test features an XUnit test framework, automated test
+discovery, death tests, assertions, parameterized tests and XML test report
+generation.")
+    (license bsd-3)))
-- 
2.7.4