diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0f73c83..39c4052 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,6 +25,22 @@ There is also a [stow-devel](https://lists.gnu.org/mailman/listinfo/stow-devel) 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 ~~~~~~~ @@ -43,6 +59,10 @@ this will do the job: (Not all tests require all of these, but it's safer to include all of 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: perl t/chkstow.t diff --git a/Makefile.am b/Makefile.am index ec1a2bd..d5218eb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -286,3 +286,28 @@ ChangeLog: doc/ChangeLog.OLD else \ echo "Not in a git repository; can't update ChangeLog."; \ 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 ' diff --git a/NEWS b/NEWS index c53efd6..40d433a 100644 --- a/NEWS +++ b/NEWS @@ -15,6 +15,11 @@ News file for Stow. ***** 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 This eliminates existing and future bit-rot.