From 009c3e4d830eebac715ff668af83a11e256584c9 Mon Sep 17 00:00:00 2001 From: Daniel Bosk Date: Sat, 11 Jan 2020 09:09:57 +0100 Subject: [PATCH 1/3] Adds start of testing for entire framework --- .gitignore | 1 + Makefile.nw | 8 ++++++++ intro.tex | 1 + tests.nw | 6 ++++++ 4 files changed, 16 insertions(+) create mode 100644 tests.nw diff --git a/.gitignore b/.gitignore index 191cadc..c25b730 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ transform.tex Dockerfile.tex intro.tex Makefile.tex +tests.tex diff --git a/Makefile.nw b/Makefile.nw index e44c573..fc04fce 100644 --- a/Makefile.nw +++ b/Makefile.nw @@ -175,3 +175,11 @@ all: makefiles.tar.gz ${RM} makefiles.tar.gz @ +\subsection{Testing} + +Finally, we provide tests in [[tests.mk]]. +This is documented in the following sections. +To use it, we must include it in the [[Makefile]]. +<>= +include tests.mk +@ diff --git a/intro.tex b/intro.tex index 00f0d98..f8945a7 100644 --- a/intro.tex +++ b/intro.tex @@ -6,4 +6,5 @@ In subsequent sections we will cover the remaining parts. \input{Makefile.tex} +\input{tests.tex} diff --git a/tests.nw b/tests.nw new file mode 100644 index 0000000..7f55667 --- /dev/null +++ b/tests.nw @@ -0,0 +1,6 @@ +\section{Compressed files and archives} + +[[portability.mk]] defines variable names for programs on various systems, \eg +[[GREP]] will be [[grep]] on GNU/Linux but [[ggrep]] on BSD. +Otherwise, the most useful functionality provided here is working with +compressed files and file archives. From e8250f33629b07d9b0e0b5dd41bdab8dd7650ea4 Mon Sep 17 00:00:00 2001 From: Daniel Bosk Date: Sat, 11 Jan 2020 22:03:56 +0100 Subject: [PATCH 2/3] Updates structure for tests.mk (#25) We now introduce `tests.mk` in the intro chapter. However, the tests will be covered in each chapter (i.e. in the NOWEB file of each include). There is a `tests.nw` file which sets up the structure. This file is covered in the introduction. However, each file, e.g. `tex.mk.nw`, will also have a code block `<>` containing all test code. Then `tests.mk` can be constructed from `tests.nw tex.mk.nw` and so on. The rationale is that the tests should be with the code. Otherwise they risk getting out of sync. --- .gitignore | 1 + Makefile | 6 ++++++ Makefile.nw | 13 +++++++++++-- intro.tex | 1 - tests.nw | 39 ++++++++++++++++++++++++++++++++++----- 5 files changed, 52 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index c25b730..26f7d66 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ Dockerfile.tex intro.tex Makefile.tex tests.tex +tests.mk diff --git a/Makefile b/Makefile index 0ce459c..fafdcea 100644 --- a/Makefile +++ b/Makefile @@ -26,6 +26,7 @@ makefiles.pdf: exam.bib makefiles.pdf: transform.bib makefiles.pdf: tex.bib makefiles.pdf: Dockerfile.tex +makefiles.pdf: tests.tex define makefiles_depends makefiles.pdf: $(1:.mk=.tex) $(1) $(1:.mk=.tex): $(1).nw @@ -64,6 +65,7 @@ clean: ${RM} ${MKFILES:.mk=.tex} ${RM} gitattributes Dockerfile ${RM} makefiles.tar.gz + ${RM} tests.mk distclean: docker image rm makefiles @@ -73,3 +75,7 @@ MAKEFILES_INCLUDE=${INCLUDE_MAKEFILES} include ${MAKEFILES_INCLUDE}/tex.mk include ${MAKEFILES_INCLUDE}/noweb.mk include ${MAKEFILES_INCLUDE}/pkg.mk +tests.mk: tests.nw $(addsuffix .nw,${MKFILES}) + ${NOTANGLE} + +include tests.mk diff --git a/Makefile.nw b/Makefile.nw index fc04fce..9653f34 100644 --- a/Makefile.nw +++ b/Makefile.nw @@ -71,6 +71,7 @@ makefiles.pdf: exam.bib makefiles.pdf: transform.bib makefiles.pdf: tex.bib makefiles.pdf: Dockerfile.tex +makefiles.pdf: tests.tex @ We must add the generated files to the clean recipe. <>= ${RM} makefiles.pdf @@ -175,11 +176,19 @@ all: makefiles.tar.gz ${RM} makefiles.tar.gz @ -\subsection{Testing} +\section{Testing all functionality} Finally, we provide tests in [[tests.mk]]. -This is documented in the following sections. +This file is tangled from all parts of the framework. To use it, we must include it in the [[Makefile]]. <>= +tests.mk: tests.nw $(addsuffix .nw,${MKFILES}) + ${NOTANGLE} + include tests.mk +@ This also requires +<>= +${RM} tests.mk @ + +\input{tests.tex} diff --git a/intro.tex b/intro.tex index f8945a7..00f0d98 100644 --- a/intro.tex +++ b/intro.tex @@ -6,5 +6,4 @@ In subsequent sections we will cover the remaining parts. \input{Makefile.tex} -\input{tests.tex} diff --git a/tests.nw b/tests.nw index 7f55667..da82352 100644 --- a/tests.nw +++ b/tests.nw @@ -1,6 +1,35 @@ -\section{Compressed files and archives} +We now provide the details of [[tests.mk]], which will test all functionality +of this framework and will thus be interesting for illustrating a variety of +the framework's use. -[[portability.mk]] defines variable names for programs on various systems, \eg -[[GREP]] will be [[grep]] on GNU/Linux but [[ggrep]] on BSD. -Otherwise, the most useful functionality provided here is working with -compressed files and file archives. +We provide a [[test]] target that will run all tests, each test will be a +dependency for [[test]]. +The target [[test-clean]] will clean up. +(The [[clean]] target will depend on [[test-clean]] so that it will +automatically be run when [[clean]] is run.) +Finally, [[run-tests]] will depend on any tests defined throughout the +framework. + +All tests will be run in a subdirectory [[tests]]. +The [[test]] target will set this up and start executing [[run-tests]] in that +directory. +<>= +.PHONY: test +test: + ${MKDIR} tests + ${MAKE} -C tests -f ../tests.mk run-tests + +.PHONY: clean test-clean +test-clean: + ${RM} tests + +clean: test-clean + +.PHONY: run-tests +run-tests: + true +@ + +Now, each NOWEB source file of the framework can define a [[<>]] code +block that will be appended to [[<>]] here (thanks to the recipe for +[[tests.mk]] in [[Makefile]]). From 5e1367ca92a70d207b2b638d69df9bb6699f495d Mon Sep 17 00:00:00 2001 From: Daniel Bosk Date: Mon, 13 Jan 2020 10:21:06 +0100 Subject: [PATCH 3/3] Updates Makefile from Makefile.nw --- Makefile | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index fafdcea..91f2f01 100644 --- a/Makefile +++ b/Makefile @@ -3,12 +3,6 @@ MKFILES+= pkg.mk pub.mk transform.mk MKFILES+= tex.mk doc.mk MKFILES+= noweb.mk haskell.mk MKFILES+= exam.mk results.mk -#MKFILES+= miun.port.mk - -MIUNFILES+= miun.docs.mk miun.tex.mk miun.subdir.mk -MIUNFILES+= miun.package.mk miun.pub.mk miun.course.mk -MIUNFILES+= miun.export.mk miun.results.mk latexmkrc -MIUNFILES+= miun.depend.mk OTHERS+= latexmkrc OTHERS+= gitattributes @@ -17,7 +11,6 @@ OTHERS+= Dockerfile .PHONY: all all: makefiles.pdf all: ${MKFILES} -#all: ${MIUNFILES} all: ${OTHERS} makefiles.pdf: makefiles.tex preamble.tex makefiles.bib @@ -47,11 +40,11 @@ docker-makefiles: Dockerfile push: docker-makefiles docker push ${DOCKER_ID_USER}/makefiles -PKG_PACKAGES?= main -PKG_NAME-main= makefiles +PKG_PACKAGES?= main +PKG_NAME-main= makefiles -PKG_PREFIX= /usr/local -PKG_INSTALL_DIR= /include +PKG_PREFIX= /usr/local +PKG_INSTALL_DIR= /include PKG_INSTALL_FILES-main= ${MKFILES} PKG_TARBALL_FILES-main= ${PKG_INSTALL_FILES-main} ${OTHERS} Makefile README.md