[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: SETUPTOOLS_SCM_PRETEND_VERSION trick : how to use it in autopkgtest?



On Tue, 09 Jun 2020 at 11:50:02 +0200, Julien Puydt wrote:
> (1) during the autopkgtest run, we're not in the package source tree,
> are we? So there should be no access do d/changelog?

    The cwd of each test is guaranteed to be the root of the source
    package, which will have been unpacked but not built. However note
    that the tests must test the installed version of the package,
    as opposed to programs or any other file from the built tree.
    — https://salsa.debian.org/ci-team/autopkgtest/blob/master/doc/README.package-tests.rst

I've found that a lot of the time, what makes most sense is to gather
the information you need from the source tree, copy the files you
need from the source tree into a temporary directory, cd into the
temporary directory, and do the rest of your testing there. This avoids
things like Python's default "add the script's directory to sys.path"
behaviour accidentally picking up the version of the library that's in
the source package, which would result in not testing the installed copy
as required. For example, src:python-mpd does this.

Another way to get a similar result is to install the tests as part of the
binary packages, cd into an empty temporary directory, and run them from the
installed location. src:tap.py does this (the tests are small, so they're
just included in the main binary package) and so does src:dbus-python (the
tests are larger and have non-trivial dependencies, so they're a separate
binary package).

autopkgtest guarantees that $AUTOPKGTEST_TMP is an empty temporary
directory, or you can make your own with mktemp -d or similar, or you
can use a tool like ginsttest-runner (aka gnome-desktop-testing-runner,
in the gnome-desktop-testing package) that does it for you.

    smcv


Reply to: