diff options
Diffstat (limited to 'mkunit.sh')
-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 | |||