aboutsummaryrefslogtreecommitdiff
path: root/mkunit.sh
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2009-01-07 15:59:57 +0000
committerMike Buland <eichlan@xagasoft.com>2009-01-07 15:59:57 +0000
commit45e065bc4fc93731ea9a0543462bc7cf9e6084d7 (patch)
treea9e8279fe00b9b01dc2393f59dc7f41b5e416b2a /mkunit.sh
parentd96fe229e79f9b1947cbd24ff52d6bf7bb9bf80d (diff)
downloadlibbu++-45e065bc4fc93731ea9a0543462bc7cf9e6084d7.tar.gz
libbu++-45e065bc4fc93731ea9a0543462bc7cf9e6084d7.tar.bz2
libbu++-45e065bc4fc93731ea9a0543462bc7cf9e6084d7.tar.xz
libbu++-45e065bc4fc93731ea9a0543462bc7cf9e6084d7.zip
Only two real changes. First, Bu::FString and Bu::FBasicString are in different
files. This won't affect any programs at all anywhere. This will just make it easier to maintain and extend later. You still want to include "bu/fstring.h" and use Bu::FString in code. The other is kinda fun. I created a special format for unit tests, they use the extension .unit now and use the mkunit.sh script to convert them to c++ code. There are some nice features here too, maintaining unit tests is much, much easier, and we can have more features without making the code any harder to use. Also, it will be easier to have the unit tests generate reports and be run from a master program and the like.
Diffstat (limited to 'mkunit.sh')
-rwxr-xr-xmkunit.sh34
1 files changed, 34 insertions, 0 deletions
diff --git a/mkunit.sh b/mkunit.sh
new file mode 100755
index 0000000..867d6df
--- /dev/null
+++ b/mkunit.sh
@@ -0,0 +1,34 @@
1#!/bin/bash
2
3function mkfunc()
4{
5 echo "void $1() /**< expect ${2:-pass} */"
6}
7
8function mkadd()
9{
10 ex="expectPass"
11 if [ "$2" == "fail" ]; then
12 ex="expectFail"
13 fi
14 echo "\\\\tadd( static_cast<Bu::UnitSuite::Test>(\\&Unit::$1), \"$1\", Bu::UnitSuite::${ex} );\\\\n"
15}
16
17sedbits=""
18init="#include \"bu/unitsuite.h\"\\\\n\\\\nclass Unit : public Bu::UnitSuite\\\\n{\\\\npublic:\\\\n\\\\nUnit()\\\\n{\\\\n\\\\tsetName(\"${1%.*}\");\\\\n"
19for i in $(grep {% "$1"); do
20 sedbits="${sedbits}s@${i}@$(mkfunc $(echo $i | sed -e 's/.*{%\(.*\)}/\1/' -e 's/:/ /g'))@\n"
21 init="${init}$(mkadd $(echo $i | sed -e 's/.*{%\(.*\)}/\1/' -e 's/:/ /g'))"
22done
23
24init="${init}\\\\n}\\\\n\\\\nvirtual ~Unit() { }\\\\n\\\\n"
25
26sedbits="${sedbits}s@.*{=Init}@${init}@\n"
27
28temp=$(mktemp)
29echo -e "$sedbits" > $temp
30sed -f $temp $1 > $2
31echo -e "\n};\n\nint main( int argc, char *argv[] )\n{\n\treturn Unit().run( argc, argv );\n}\n" >> $2
32
33rm $temp
34