Today I discovered how to customize the test command modifying debian/rules.
First of all I discovered what are the sub command launched by debheler:

andrea@debian:~/trash-cli$ dh build --no-act
   dh_testdir
   dh_update_autotools_config
   dh_autoreconf
   dh_auto_configure
   dh_auto_build
   dh_auto_test
   create-stamp debian/debhelper-build-stamp

Then I discovered these lines in dh_auto_test(1) manual page:

       This is intended to work for about 90% of packages with a test
suite. If it doesn't work, you're encouraged to skip using dh_auto_test at
all, and
       just run the test suite manually.

Reading the dh(1) man page I found the way to override dh_auto_test.

andrea@debian:~/trash-cli$ git diff debian/rules
diff --git a/debian/rules b/debian/rules
index 641186e..1cebeeb 100755
--- a/debian/rules
+++ b/debian/rules
@@ -2,3 +2,6 @@

 %:
        dh $@ --with python3 --buildsystem=pybuild
+
+override_dh_auto_test:
+       python3 -m pytest

Now I have other problems: the tests what to use "python" instead of
"python3", I'll try to fix that upstream.

Regards

Il giorno dom 17 ott 2021 alle ore 14:35 Andrea Francia <
and...@andreafrancia.it> ha scritto:

> Hi Jonathan,
>    thank you for your interest.
> I've written the automatic tests using the assumption that they will be
> launched from the project root.
> They search for ./script/bump.py and for these commands: ./trash
> ./trash-empty ./trash-list ./trash-put ./trash-restore ./trash-rm
> Can we launch test before the build like I do in the upstream source code?
>
> Regards
>
> Il giorno ven 15 ott 2021 alle ore 17:24 Jonathan Dowland <j...@debian.org>
> ha scritto:
>
>> On Wed, Oct 13, 2021 at 10:16:24AM +0100, Jonathan Dowland wrote:
>> >Eyeballing the failures again quickly now, I think the majority of the
>> >failures will be due to not finding the actual test utilities in an
>> >expected place in the chroot, variations on:
>> >
>> >    python3: can't open file
>> >    '/<<PKGBUILDDIR>>/.pybuild/cpython3_3.9/build/trash-put': [Errno 2]
>> >    No such file or directory
>>
>> Expanding on this a bit, the build phase runs
>>
>>      /usr/bin/python3 setup.py build
>>
>> Which outputs the following (elided)
>>
>> > running build_py
>> > creating /<<PKGBUILDDIR>>/.pybuild/cpython3_3.9/build/trashcli
>> > copying trashcli/fstab.py ->
>> /<<PKGBUILDDIR>>/.pybuild/cpython3_3.9/build/trashcli
>> ...
>> > running build_scripts
>> > creating build
>> > creating build/scripts-3.9
>> > copying and adjusting trash -> build/scripts-3.9
>> ...
>>
>> Note: the initial 'copying' lines are to a path
>> /<<PKGBUILDDIR>>/.pybuild/cpython3_3.9/build/trashcli, but the latter
>> ones are to just "build/scripts-3.9". And indeed, if I run
>>
>>      sbuild --build-failed-commands '%SBUILD_SHELL'
>>
>> I'm dropped into a shell in the build environment after the test
>> failure. Right now that's /build/trash-cli-Nkmibk, which has the
>> unpacked source at trash-cli-0.21.7.24, which corresponds to the
>> <<PKGBUILDDIR>> substitution in the output above.
>>
>> I see the path
>> /build/trash-cli-Nkmibk/trash-cli-0.21.7.24/.pybuild/cpython3_3.9/build,
>> corresponding to the first set of "copying" lines above, and containing
>> "tests" and "trashcli". And I see
>> /build/trash-cli-Nkmibk/trash-cli-0.21.7.24/build/scripts-3.9,
>> containing the command-line tools, corresponding to the second set of
>> 'copying' lines above.
>>
>> When the tests are executed, the following is run
>>
>>      cd /<<PKGBUILDDIR>>/.pybuild/cpython3_3.9/build; python3.9 -m pytest
>> tests
>>
>> And so at the time the tests run the command line tools are not in $PWD
>> and tests/run_command.py::run_command constructs a path that is not
>> valid.
>>
>> So... the question is, why does the "build_py" phase of
>> distutils/setuptools have the correct path, where is that being
>> specified? Why doesn't the "build_scripts" phase also have the correct
>> path, and where can we specify that?
>>
>> --
>> 👱🏻    Jonathan Dowland
>> ✎        j...@debian.org
>> 🔗      https://jmtd.net
>>
>
>
> --
> Andrea Francia http://andreafrancia.it
>


-- 
Andrea Francia http://andreafrancia.it

Reply via email to