diff options
author | Mike Buland <eichlan@xagasoft.com> | 2010-05-15 07:44:10 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2010-05-15 07:44:10 +0000 |
commit | 306b80c1cf9ab490a83b36d3e7cf07e09f9e5d68 (patch) | |
tree | 32c35f8507edb4ea403f4ebc4b625c1096f6f384 /mkunit.sh | |
parent | 11413d228bae2919fe69c83b74c7ff49209dd65a (diff) | |
download | libbu++-306b80c1cf9ab490a83b36d3e7cf07e09f9e5d68.tar.gz libbu++-306b80c1cf9ab490a83b36d3e7cf07e09f9e5d68.tar.bz2 libbu++-306b80c1cf9ab490a83b36d3e7cf07e09f9e5d68.tar.xz libbu++-306b80c1cf9ab490a83b36d3e7cf07e09f9e5d68.zip |
mkunit.sh was a little dumb, it didn't handle a number of things correctly.
I've written a new program that basically does the same thing, only it's much
more clever, and does many more of the translations and conversions better,
including the #line directives. Also, I dropped nids, we don't need it anymore.
But now I'm ready to write some serious tests for myriad.
Diffstat (limited to '')
-rwxr-xr-x | mkunit.sh | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/mkunit.sh b/mkunit.sh deleted file mode 100755 index b99b6d3..0000000 --- a/mkunit.sh +++ /dev/null | |||
@@ -1,38 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | inputfile="$1" | ||
4 | |||
5 | function mkfunc() | ||
6 | { | ||
7 | line=$(grep -nh "{%$1" "$inputfile") | ||
8 | echo "#line ${line%%:*} \"$inputfile\" \\" | ||
9 | echo "void $1() /**< expect ${2:-pass} */" | ||
10 | } | ||
11 | |||
12 | function mkadd() | ||
13 | { | ||
14 | ex="expectPass" | ||
15 | if [ "$2" == "fail" ]; then | ||
16 | ex="expectFail" | ||
17 | fi | ||
18 | echo "\\\\tadd( static_cast<Bu::UnitSuite::Test>(\\&Unit::$1), \"$1\", Bu::UnitSuite::${ex} );\\\\n" | ||
19 | } | ||
20 | |||
21 | sedbits="" | ||
22 | init="#include \"bu/unitsuite.h\"\\\\n\\\\nclass Unit : public Bu::UnitSuite\\\\n{\\\\npublic:\\\\n\\\\nUnit()\\\\n{\\\\n\\\\tsetName(\"${1%.*}\");\\\\n" | ||
23 | for i in $(grep {% "$1"); do | ||
24 | sedbits="${sedbits}s@${i}@$(mkfunc $(echo $i | sed -e 's/.*{%\(.*\)}/\1/' -e 's/:/ /g'))@\n" | ||
25 | init="${init}$(mkadd $(echo $i | sed -e 's/.*{%\(.*\)}/\1/' -e 's/:/ /g'))" | ||
26 | done | ||
27 | |||
28 | init="${init}\\\\n}\\\\n\\\\nvirtual ~Unit() { }\\\\n\\\\n" | ||
29 | |||
30 | sedbits="${sedbits}s@.*{=Init}@${init}@\n" | ||
31 | |||
32 | temp=$(mktemp) | ||
33 | echo -e "$sedbits" > $temp | ||
34 | sed -f $temp $1 > $2 | ||
35 | echo -e "\n};\n\nint main( int argc, char *argv[] )\n{\n\treturn Unit().run( argc, argv );\n}\n" >> $2 | ||
36 | |||
37 | rm $temp | ||
38 | |||