Trac: Status: assigned to needs_review Summary: Improve practracker unit tests, and run them in "make check" to Improve practracker unit tests, and run them in "make check" and pre-commit Reviewer: N/Ato nickm
This isn't quite the fix I wanted, so I'd like your advice.
The commits themselves look okay to me. Is the issue the one that you mention here?
Is there a way we can restrict includes to ".h" and ".inc"?
Perhaps with some custom code in practracker includes.py?
We could add a .may_include to all directories, starting with ".h" and ".inc". Then practracker would start looking at them. Does that do what you want?
Right now it looks like there are some places where we include .c files intentionally. And arguably we should rename ".i" to ".inc"
This isn't quite the fix I wanted, so I'd like your advice.
The commits themselves look okay to me. Is the issue the one that you mention here?
Yes, the #include "feature/dircache/dirserv.c" in test_controller.c.
Is there a way we can restrict includes to ".h" and ".inc"?
Perhaps with some custom code in practracker includes.py?
We could add a .may_include to all directories, starting with ".h" and ".inc". Then practracker would start looking at them. Does that do what you want?
No, because practracker just logs a warning, which most people ignore. (And CI doesn't fail.) We really do need to fail on weird include patterns like this.
Right now it looks like there are some places where we include .c files intentionally. And arguably we should rename ".i" to ".inc"
This isn't quite the fix I wanted, so I'd like your advice.
The commits themselves look okay to me. Is the issue the one that you mention here?
Yes, the #include "feature/dircache/dirserv.c" in test_controller.c.
Is there a way we can restrict includes to ".h" and ".inc"?
Perhaps with some custom code in practracker includes.py?
We could add a .may_include to all directories, starting with ".h" and ".inc". Then practracker would start looking at them. Does that do what you want?
No, because practracker just logs a warning, which most people ignore. (And CI doesn't fail.) We really do need to fail on weird include patterns like this.
The .may_includes checker in practracker has two entry points: the one in practracker.py, and the one in includes.py directly that replaces our old checkIncludes.py. The latter does fail on violations, if the .may_includes file is not marked as advisory.
For example, add a .may_include file to src/test containing only '*.h', and run "make check". When I try this, "make check" fails.
Right now it looks like there are some places where we include .c files intentionally. And arguably we should rename ".i" to ".inc"
I went with the simple change, and added the missing .may_include files. There are 4 !advisory files right now, in core/{crypto,mainloop,or,proto}. They won't catch "*.c" includes, but the others will. That's probably ok for now.
We can get more specific about the dependencies in future work.
I documented !advisory in practracker/includes.py, because it wasn't documented.
I also fixed an issue in the pre-commit hook, and added checkSpaceTest.sh from #32613 (moved) to that hook. (Otherwise, there would have been a merge conflict.)
Here's the script I used to create the new .may_include files:
$ cd tor$ echo '*.h' > .may_include$ for cf in `find src -name *.c`; do d=`dirname $cf` if [ ! -e $d/.may_include ]; then echo $d/.may_include fi done | sort -u | grep -v ext | xargs -n1 cp .may_include$ echo '*.inc' >> src/app/config/.may_include$ echo '*.inc' >> src/test/.may_include$ rm .may_include