Subject: [bug#28151] [PATCH] gnu: Add honcho.

From: Stefan Reichör <[email-masked]>
Date: Tue, 22 Aug 2017 21:42:36 +0200

Marius Bakke <[email-masked]> writes:

> Stefan Reichör <[email-masked]> writes:
>
>> * gnu/packages/python.scm (python-honcho): New variable.
>
> Thanks!  I noticed this runs no tests, can you try to add a phase that
> invokes "pytest" instead of relying on the default "setup.py test"?
>
> It looks like it might require some extra (native) inputs, but they
> should already be in Guix:
>
> https://github.com/nickstenning/honcho/blob/master/tox.ini#L17

I tried to add a py.test check phase. But I failed.

By reading python.scm I found two ways to do such tests

a) before installation
    (arguments
     '(#:phases
       (modify-phases %standard-phases
         (replace 'check
           (lambda _
             (zero? (system* "py.test" "-vv" )))))))

b) after installation
    (arguments
	 `(#:phases
	   (modify-phases %standard-phases
		 (delete 'check)
		 (add-after 'install 'check
		   (lambda* (#:key outputs inputs #:allow-other-keys)
			 ;; It's easier to run tests after install.
			 ;; Make installed package available for running the tests
			 (add-installed-pythonpath inputs outputs)
			 (zero? (system* "py.test" "-vv")))))))

I added the following to get pytest dependencies in:
    (native-inputs
     `(("python-pytest" ,python-pytest)
       ("python-mock" ,python-mock)
       ("python-tox" ,python-tox))) ;for tests

Both ways have the same effect: They don't collect any tests:
,----
| platform linux -- Python 3.5.3 -- py-1.4.32 -- pytest-2.7.3 -- /gnu/store/bf54hnwd8mb63zmssc23fwslf5zvxpxs-python-wrapper-3.5.3/bin/python
| rootdir: /tmp/guix-build-python-honcho-1.0.1.drv-0/honcho-1.0.1, inifile: 
| collecting ... collected 0 items
`----

When I run py.test on my Ubuntu machine, the tox.ini file is picked up
and I can run the tests:
,----
| platform linux2 -- Python 2.7.12, pytest-2.8.7, py-1.4.31, pluggy-0.3.1
| rootdir: /home/stefan/work/git/honcho, inifile: tox.ini
| plugins: mock-0.8.1
| collected 123 items 
| 
| tests/test_colour.py ..
| tests/test_environ.py ..........................................
| tests/test_export_base.py .............
| tests/test_export_runit.py ..
| tests/test_export_supervisord.py ..
| tests/test_export_upstart.py .....
| tests/test_manager.py ...............
| tests/test_printer.py ..............
| tests/test_process.py ..............
| tests/integration/test_check.py .
| tests/integration/test_export.py ...
| tests/integration/test_run.py ....
| tests/integration/test_start.py ......
| 
| ============================= 123 passed in 19.25 seconds ================
`----

Of course, the python versions are different. But the test for the guix
package seems to be run either in a wrong directory or some files
(tox.ini) are missing...

Sorry - I have no idea how to proceed.

> Also, since this seems to be some kind of process manager, perhaps it
> would be better suited in 'admin.scm' (without the 'python-' prefix)?

This was also my first intention.

However, after reading https://honcho.readthedocs.io/en/latest/,
I thought that honcho could also be used as python library.
No idea how many users will do that...

> Just a question, anyway.  The patch looks good to me (but make sure it
> passes `guix lint`).
>
> TIA!

Stefan.