Add all-problem testing.
authorW. Trevor King <wking@drexel.edu>
Fri, 27 May 2011 19:47:37 +0000 (15:47 -0400)
committerW. Trevor King <wking@drexel.edu>
Fri, 27 May 2011 20:52:52 +0000 (16:52 -0400)
latex/test/Makefile [new file with mode: 0644]
latex/test/all_problems.tex [new file with mode: 0644]
latex/test/probs.tex [new file with mode: 0644]
latex/test/sols.tex [new file with mode: 0644]
latex/test/write_problemlist.py [new file with mode: 0755]

diff --git a/latex/test/Makefile b/latex/test/Makefile
new file mode 100644 (file)
index 0000000..7ed6b11
--- /dev/null
@@ -0,0 +1,45 @@
+THIS_DIR = $(shell basename $(PWD))
+SOURCE_FILES = all_problems.tex probs.tex sols.tex
+OTHER_FILES = Makefile write_problemlist.py
+DIST_FILES = $(SOURCE_FILES) $(OTHER_FILES)
+DIST_FILE = $(THIS_DIR)_source.tar.gz
+DIST_DIR = note
+
+all : sols.pdf probs.pdf
+
+view : all
+       xpdf probs.pdf &
+       xpdf sols.pdf &
+
+%.pdf : %.tex $(SOURCE_FILES) problemlist.tex
+       pdflatex $(patsubst %.tex,%,$<)
+       find . -name '*.asy' -execdir asy -noprc -render=0 {} \;
+       pdflatex $(patsubst %.tex,%,$<)
+       pdflatex $(patsubst %.tex,%,$<)
+
+problemlist.tex : write_problemlist.py
+       ./$<
+
+semi-clean :
+       rm -f *.log *.aux *.out *.thm *.toc *.pre *-*[0-9].tex *.js *.prc *.asy
+
+clean : semi-clean
+       rm -f *.pdf $(DIST_FILE) $(DIST_DIR) install*
+       rm -f problemlist.tex $(shell find . -type l)
+
+$(DIST_FILE) : $(DIST_FILES)
+       mkdir $(DIST_DIR)
+       cp -Lrp $^ $(DIST_DIR)
+       tar -chozf $@ $(DIST_DIR)
+       rm -rf $(DIST_DIR)
+
+install : install-probs install-solns
+
+install-probs : probs.pdf
+       scp -p $< $(INSTALL_USER)@$(INSTALL_HOST):$(INSTALL_DIR)/rec$(RECITATION_NUMBER)_problems.pdf
+       @date > $@
+
+install-solns : sols.pdf $(DIST_FILE)
+       scp -p $< $(INSTALL_USER)@$(INSTALL_HOST):$(INSTALL_DIR)/rec$(RECITATION_NUMBER)_solutions.pdf
+       scp -p $(DIST_FILE) $(INSTALL_USER)@$(INSTALL_HOST):$(SOURCE_DIR)
+       @date > $@
diff --git a/latex/test/all_problems.tex b/latex/test/all_problems.tex
new file mode 100644 (file)
index 0000000..df38e5c
--- /dev/null
@@ -0,0 +1,21 @@
+\usepackage[author={W. Trevor King},
+            coursetitle={Physics},
+            classtitle={Testing},
+            subheading={All problems}]{problempack}
+\usepackage[inline]{asymptote}
+\usepackage{cleveref}
+\usepackage{wtk_cmmds}
+\usepackage{wtk_format}
+
+\begin{document}
+
+\begin{asydef}
+// make wtk_cmmds macros available in Asymptote-rendered environments
+usepackage("wtk_cmmds");
+\end{asydef}
+
+\maketitle
+
+\input{problemlist}
+
+\end{document}
diff --git a/latex/test/probs.tex b/latex/test/probs.tex
new file mode 100644 (file)
index 0000000..fa21ac1
--- /dev/null
@@ -0,0 +1,5 @@
+\documentclass[letterpaper, 10pt]{article}
+
+\PassOptionsToPackage{nosolutions}{problempack}
+
+\input{all_problems}
diff --git a/latex/test/sols.tex b/latex/test/sols.tex
new file mode 100644 (file)
index 0000000..1596819
--- /dev/null
@@ -0,0 +1,5 @@
+\documentclass[letterpaper, 10pt]{article}
+
+\PassOptionsToPackage{solutions,loose}{problempack}
+
+\input{all_problems}
diff --git a/latex/test/write_problemlist.py b/latex/test/write_problemlist.py
new file mode 100755 (executable)
index 0000000..c6a34b0
--- /dev/null
@@ -0,0 +1,54 @@
+#!/usr/bin/env python
+
+import os
+import os.path
+
+
+_this_dir = os.path.dirname(__file__)
+
+
+def write_problemlist(problem_dir=None, blacklist=()):
+    # remove evidence from previous runs
+    for name in os.listdir(_this_dir):
+        if os.path.islink(name):
+            os.unlink(name)
+
+    # generate new symlinks and problemlist.tex
+    f = open(os.path.join(_this_dir, 'problemlist.tex'), 'w')
+    i = 1
+    for source in sorted(os.listdir(problem_dir)):
+        if source in blacklist:
+            continue
+        source_dir = os.path.join(problem_dir, source)
+        if not os.path.isdir(source_dir):
+            continue
+        f.write('\section{%s}' % source.replace('_', ' '))
+        for problem in sorted(os.listdir(source_dir)):
+            path = os.path.join(source_dir, problem)
+            if os.path.isfile(path):
+                relpath = os.path.relpath(path, _this_dir)
+                if path.endswith('.tex'):
+                    pname = 'problem%d.tex' % i
+                    i += 1
+                    f.write('\\input{%s}\n' % pname)
+                else:  # utility file (e.g. image)
+                    pname = problem
+                os.symlink(relpath, pname)
+    f.close()
+
+
+if __name__ == '__main__':
+    write_problemlist(
+        problem_dir=os.path.join(_this_dir, '..', 'problems'),
+        blacklist=[
+            'Giancoli_6',
+            'Serway_and_Jewett_4',
+            'Serway_and_Jewett_4_venkat',
+            'Serway_and_Jewett_4_wking',
+#            'Serway_and_Jewett_8',
+            'Thornton_and_Rex_3',
+            'Thornton_and_Rex_3_wking',
+            'Young_and_Freedman_12',
+            'wking',
+            ]
+        )