getting-things-gnome / gtg

Getting Things GNOME! trunk
https://wiki.gnome.org/Apps/GTG
GNU General Public License v3.0
559 stars 164 forks source link

Rename info.py.in to info.py #1141

Open ArimaBatista opened 2 months ago

ArimaBatista commented 2 months ago

File naming error resulting in test failures

ArimaBatista commented 2 months ago

This causes the error 'GTG/core/meson.build:25:10: ERROR: File info.py.in does not exist'. To fix this, change 'info.py.in' to 'info.py' on line 26 of that file. After this change, 'bash launch.sh' will work with automated tests and 'precommit'.

Neui commented 2 months ago

.in files are to be post-processed (usually by the build system). In this case, it is for the version (replacing @VCS_TAG@ with the version).

I don't like this solution because it removes the indication that it is a file to be post-processed. If anything, tests should just work with the build-installed version since we don't support running the project in-place anyway (which sound what you are trying to do), unless we (or someone else) make the project runnable in-place.

PR #1142 depends on this commit, so you should just combine both into one PR (you could add the commit to this repo, but it seems you are editing from the Github Web UI (because of the branch name) and I am not sure if it can do that.)

SqAtx commented 2 months ago

Yes, that's not actually a file naming error. The problem is that meson needs to be run before running the tests. That will create process the .py.in file in the output folder, and you can then run the tests there. But that's not documented except in the comments of #1036:

The file info.py.in is a template that gets filled (also called configured) by the meson setup step. The resulting file is placed into the build directory. This is the file we actually want Python to find and use.

It's kind of annoying to have to do that. It gets in the way of quick iteration when writing code and tests in parallel. So on my local machine, after running meson once, I copied the resulting info.py into GTG/core. Now I can run the tests normally:

~/src/gtg$ pytest
==================================================================== test session starts =====================================================================
platform linux -- Python 3.12.3, pytest-8.2.2, pluggy-1.5.0
rootdir: /home/kevin/src/gtg
configfile: pyproject.toml
testpaths: tests
collected 160 items                                                                                                                                          

tests/backend/backend_caldav_test.py sssssss                                                                                                           [  4%]
tests/core/test_config.py ...................                                                                                                          [ 16%]
[...]

=============================================================== 153 passed, 7 skipped in 1.20s ===============================================================

This is probably worth a subsection under "Setting up a development environment" in the README. I'll look into that.