gdal icon indicating copy to clipboard operation
gdal copied to clipboard

autotest: run Python tests directly from source tree [WIP]

Open dbaston opened this issue 1 year ago • 2 comments

What does this PR do?

Modifies CMake configuration so that Python tests are run directly from the source tree, rather than from a symlink or copy in the build directory. This is an experiment in removing the following "gotcha":

(be careful on Windows, the content of $build_dir/autotest is copied from $source_dir/autotest each time "cmake" is run, so if you edit your test .py file directly in the build directory, be super careful of not accidentally losing your work, and make sure to copy its content to the source directory first. That's admittedly an annoying point of the current test setup on Windows, compared to Unix where we use symbolic links)

described in https://lists.osgeo.org/pipermail/gdal-dev/2024-February/058425.html

A downside of this change is that, because pytest.ini lives only in the build directory, we must always explicitly provide the config file via pytest -c pytest.ini. Is it an overall reduction in complexity? I don't know, am interested in feedback.

What are related issues/pull requests?

Tasklist

  • [ ] Review
  • [ ] Adjust for comments
  • [ ] All CI builds and checks have passed

dbaston avatar Feb 09 '24 22:02 dbaston

Coverage Status

coverage: 69.002% (+0.005%) from 68.997% when pulling fc5fbf3542bdd3ed52cbf08e17c8f95b4f2fc92b on dbaston:autotest-no-symlink into 88b0dd89776ed254a8fce3108f146b7a97da991e on OSGeo:master.

coveralls avatar Feb 09 '24 22:02 coveralls

ah, this was mostly me not being aware of the -c option of pytest then. But perhaps we could keep the current symlink approach on non-Windows so that only Windows users have to pay the price of using an inferior operating system ;-) ?

rouault avatar Feb 09 '24 23:02 rouault

@dbaston do we need to keep that one opened ? I'm trying to reduce the number of staled PRs to keep the list as small as possible.

rouault avatar Apr 17 '24 17:04 rouault

I updated this so that the tests are still symlinked on Linux/Mac, so I wasn't planning more work here. It can be merged or closed if we would prefer to continue copying the tests on Windows.

dbaston avatar Apr 17 '24 17:04 dbaston

I updated this so that the tests are still symlinked on Linux/Mac, so I wasn't planning more work here. It can be merged or closed if we would prefer to continue copying the tests on Windows.

ok, sometimes I'm getting lost in what is ready for final review/merge or staled ;-) Don't hesitate to ping me if you see a PR that should be merged

Perhaps https://gdal.org/development/testing.html#running-a-subset-of-tests-using-pytest could get some updates to explain the subtelty on Windows of doing "python -m pytest -c autotest/pytest.ini ../autotest/gcore/vrt_read.py"

rouault avatar Apr 17 '24 17:04 rouault

Perhaps https://gdal.org/development/testing.html#running-a-subset-of-tests-using-pytest could get some updates to explain the subtelty on Windows of doing "python -m pytest -c autotest/pytest.ini ../autotest/gcore/vrt_read.py"

Good idea, I've done this at https://github.com/OSGeo/gdal/pull/9224/files#diff-1c899043c9c79440030b3ee7fcf72b357d3333d5070807d933f03ce80b4861edR51

dbaston avatar Apr 17 '24 19:04 dbaston