* tests/unit_test/build_unit_test.sh: new.
---
scribo/ChangeLog | 15 +++++++
scribo/tests/unit_test/build_unit_test.sh | 59 +++++++++++++++++++++++++++++
2 files changed, 74 insertions(+), 0 deletions(-)
create mode 100644 scribo/ChangeLog
create mode 100755 scribo/tests/unit_test/build_unit_test.sh
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
new file mode 100644
index 0000000..a6a798b
--- /dev/null
+++ b/scribo/ChangeLog
@@ -0,0 +1,15 @@
+2009-05-25 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ Add a script to generate unit tests for scribo.
+
+ * tests/unit_test/build_unit_test.sh: new.
+
+
+$Rev$
+$Id$
+$Date$
+
+Local Variables:
+ispell-local-dictionary: "american"
+coding: iso-latin-1
+End:
diff --git a/scribo/tests/unit_test/build_unit_test.sh
b/scribo/tests/unit_test/build_unit_test.sh
new file mode 100755
index 0000000..7c80671
--- /dev/null
+++ b/scribo/tests/unit_test/build_unit_test.sh
@@ -0,0 +1,59 @@
+#! /bin/sh
+
+## FIXME: Don't use `echo -n', as echo's options are not portable.
+##
+##
http://www.gnu.org/software/autoconf/manual/html_node/Limitations-of-Builtiā¦
+##
+## As an ugly workaround, use `printf' instead. The right approach
+## would be to only emit lines ended with newlines.
+ECHO_N=printf
+
+
+test $# -eq 1 || { echo "Usage: $0 <scribo path>" && exit 1; }
+
+## FIXME: Ouch! Using `find' properly can probably save us some pipes,
+## forks and characters here.
+HEADERS=`find $1 -name "*.hh" | grep -vE "*.spe.hh" | sort | sed -e
's/.*\/scribo\/\(.*\)/scribo\/\1/g' | sed 's/\.\.\/\.\.\///g'`
+
+output=unit-tests.mk
+
+rm -f "$output"
+rm -f scribo_*.cc
+
+# Build unit-tests.mk.
+echo "## Generated by $0, do not modify." >"$output"
+echo >>"$output"
+$ECHO_N "check_PROGRAMS = " >>"$output"
+
+for i in $HEADERS; do
+ FILE_CC=`echo $i | sed 's/[/.]/_/g' | sed 's/_hh/\.cc/g'`
+
+ # Build .cc.
+ cat > $FILE_CC << EOF
+// Unit test for $i.
+// Generated by $0, do not modify.
+
+// Include the file twice, so we detect missing inclusion guards.
+#include <$i>
+#include <$i>
+
+int main()
+{
+ // Nothing.
+}
+EOF
+
+ # Build unit-tests.mk.
+ TARGET=`echo "${FILE_CC}" | sed 's/\.cc//'`
+ echo " \\" >>"$output"
+ $ECHO_N "${TARGET}" >>"$output"
+done
+
+# Build "$output".
+echo "" >>"$output"
+echo "" >>"$output"
+for i in $HEADERS; do
+ FILE_CC=`echo $i | sed 's/[/.]/_/g' | sed 's/_hh/\.cc/g'`
+ NAME=`echo $FILE_CC | sed 's/\.cc//g'`
+ echo "${NAME}_SOURCES = $FILE_CC" >>"$output"
+done
--
1.5.6.5