Subject: Re: bug#25177: Test failures don't cause some Python packages to fail [was Re: [PATCH 05/11] gnu: Add python-pygit2.]

From: Marius Bakke <[email-masked]>
Date: Mon, 12 Dec 2016 08:54:40 +0100

Marius Bakke <[email-masked]> writes:

> Leo Famulari <[email-masked]> writes:
>
>> I noticed while building the package added by ng0's patch (below) that
>> the test suite fails, but the check phase succeeds:
>>
>> [...]
>> ======================================================================
>> ERROR: test_clone_with_credentials (test.test_repository.CloneRepositoryTest)
>> ----------------------------------------------------------------------
>> Traceback (most recent call last):
>>   File "/tmp/guix-build-python-pygit2-0.24.2.drv-0/pygit2-0.24.2/test/test_repository.py", line 544, in test_clone_with_credentials
>>     self._temp_dir, callbacks=pygit2.RemoteCallbacks(credentials=pygit2.UserPass("libgit2", "libgit2")))
>>   File "/tmp/guix-build-python-pygit2-0.24.2.drv-0/pygit2-0.24.2/pygit2/__init__.py", line 255, in clone_repository
>>     check_error(err)
>>   File "/tmp/guix-build-python-pygit2-0.24.2.drv-0/pygit2-0.24.2/pygit2/errors.py", line 64, in check_error
>>     raise GitError(message)
>> _pygit2.GitError: curl error: Couldn't resolve host 'bitbucket.org'
>>
>>
>> ----------------------------------------------------------------------
>> Ran 262 tests in 5.771s
>>
>> FAILED (errors=3)
>> phase `check' succeeded after 8.9 seconds
>> [...]
>>
>> Any ideas?
>
> It looks like the 'check' phase ends with 'delete-file-recursively',
> which has an unspecified return value, and that eventual failures from
> 'call-setuppy' are lost.

The good news: the attached patch makes 'check' work as expected. The
bad news is that we have some breakages.

'python-py' fails with:

TypeError: py.test.__dict__ is not a dictionary

Which seems similar to

https://github.com/NixOS/nixpkgs/issues/12565#issuecomment-174165144

I tried adding a newer setuptools as input, to no avail. Needs more
investigation.

>From 12c4a14b415f26155f85f8ea172ddf696e274855 Mon Sep 17 00:00:00 2001
From: Marius Bakke <[email-masked]>
Date: Mon, 12 Dec 2016 00:25:27 +0100
Subject: [PATCH] build-system/python: Make sure 'check' returns failures.

* guix/build/python-build-system.scm (check): Wrap 'call-setuppy' in 'if' so
that it actually fails when the tests fail. Print informational message when
skipped.
---
 guix/build/python-build-system.scm | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/guix/build/python-build-system.scm b/guix/build/python-build-system.scm
index 3f280b0ac..dd07986b9 100644
--- a/guix/build/python-build-system.scm
+++ b/guix/build/python-build-system.scm
@@ -137,11 +137,15 @@
       ;; (given with `package_dir`). This will by copied to the output, too,
       ;; so we need to remove.
       (let ((before (find-files "build" "\\.egg-info$" #:directories? #t)))
-        (call-setuppy test-target '() use-setuptools?)
-        (let* ((after (find-files "build" "\\.egg-info$" #:directories? #t))
-               (inter (lset-difference eqv? after before)))
-          (for-each delete-file-recursively inter)))
-    #t))
+        (if (call-setuppy test-target '() use-setuptools?)
+            (let* ((after (find-files "build" "\\.egg-info$" #:directories? #t))
+                   (inter (lset-difference eqv? after before)))
+              (for-each delete-file-recursively inter)
+              #t)
+            #f))
+      (begin
+        (format #t "test suite not run~%")
+        #t)))
 
 (define (get-python-version python)
   (let* ((version     (last (string-split python #\-)))
-- 
2.11.0