Add watch target to Makefile for easier hacking

This commit is contained in:
Adam Spiers 2021-04-04 19:08:15 +01:00
parent 28a4e82741
commit 478c7b921d
3 changed files with 50 additions and 0 deletions

View file

@ -25,6 +25,22 @@ There is also a
[stow-devel](https://lists.gnu.org/mailman/listinfo/stow-devel) [stow-devel](https://lists.gnu.org/mailman/listinfo/stow-devel)
mailing list (see [Mailing lists](README.md#mailing-lists)). mailing list (see [Mailing lists](README.md#mailing-lists)).
Please be aware that all program source files (excluding the test
suite) end in `.in`, and are pre-processed by `Makefile` into
corresponding files with that prefix stripped before execution. So if
you want to test any modifications to the source, make sure that you
change the `.in` files and then run `make` to regenerate the
pre-processed versions before doing any testing. To avoid forgetting
(which can potentially waste a lot of time debugging the wrong code),
you can automatically run `make` in an infinite loop every second via:
make watch
(You could even use fancier approaches like
[`inotifywait(1)`](https://www.man7.org/linux/man-pages/man1/inotifywait.1.html)
or [Guard](https://guardgem.org/). But those are probably overkill in
this case where the simple `while` loop is plenty good enough.)
Testing Testing
~~~~~~~ ~~~~~~~
@ -43,6 +59,10 @@ this will do the job:
(Not all tests require all of these, but it's safer to include all of (Not all tests require all of these, but it's safer to include all of
them.) them.)
Secondly, be aware that if you want to test modifications to the
source files, you will need to run `make watch`, or `make` before each
test run as explained above.
Now running an individual test is as simple as: Now running an individual test is as simple as:
perl t/chkstow.t perl t/chkstow.t

View file

@ -286,3 +286,28 @@ ChangeLog: doc/ChangeLog.OLD
else \ else \
echo "Not in a git repository; can't update ChangeLog."; \ echo "Not in a git repository; can't update ChangeLog."; \
fi fi
# Watch for changes, and if any rebuilds are required, also do a
# make install.
#
# If we solved https://github.com/aspiers/stow/issues/84, we could
# probably ditch this:
watch:
@echo "Watching for changes to program source files ..."
@while true; do \
if $(MAKE) 2>&1 | \
grep -vE 'make\[[1-9]\]: (Entering|Leaving) directory ' | \
grep -v 'Nothing to be done'; \
then \
echo; \
echo "-----------------------------------------------------"; \
echo "make found things to rebuild; doing $(MAKE) install ..."; \
echo; \
$(MAKE) install; \
echo; \
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"; \
echo; \
fi; \
sleep 1; \
done 2>&1 | \
grep -vE 'make\[[1-9]\]: (Entering|Leaving) directory '

5
NEWS
View file

@ -15,6 +15,11 @@ News file for Stow.
***** Added a CONTRIBUTING.md file ***** Added a CONTRIBUTING.md file
***** Add a =watch= target to =Makefile=
=make watch= provides easy continual pre-processing during
development, which reduces the risk of debugging the wrong code.
***** Removed texinfo.tex from the distribution ***** Removed texinfo.tex from the distribution
This eliminates existing and future bit-rot. This eliminates existing and future bit-rot.