Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test all functionality #69

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ transform.tex
Dockerfile.tex
intro.tex
Makefile.tex
tests.tex
tests.mk
21 changes: 10 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -26,6 +19,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
Expand All @@ -46,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
Expand All @@ -64,6 +58,7 @@ clean:
${RM} ${MKFILES:.mk=.tex}
${RM} gitattributes Dockerfile
${RM} makefiles.tar.gz
${RM} tests.mk

distclean:
docker image rm makefiles
Expand All @@ -73,3 +68,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
17 changes: 17 additions & 0 deletions Makefile.nw
Original file line number Diff line number Diff line change
Expand Up @@ -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.
<<clean recipe>>=
${RM} makefiles.pdf
Expand Down Expand Up @@ -175,3 +176,19 @@ all: makefiles.tar.gz
${RM} makefiles.tar.gz
@

\section{Testing all functionality}

Finally, we provide tests in [[tests.mk]].
This file is tangled from all parts of the framework.
To use it, we must include it in the [[Makefile]].
<<include files>>=
tests.mk: tests.nw $(addsuffix .nw,${MKFILES})
${NOTANGLE}

include tests.mk
@ This also requires
<<clean recipe>>=
${RM} tests.mk
@

\input{tests.tex}
35 changes: 35 additions & 0 deletions tests.nw
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
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.

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.
<<tests.mk>>=
.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 [[<<tests.mk>>]] code
block that will be appended to [[<<tests.mk>>]] here (thanks to the recipe for
[[tests.mk]] in [[Makefile]]).