blob: 867d6dfa8cb2c98654e43206349e42139ee82b36 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#!/bin/bash
function mkfunc()
{
echo "void $1() /**< expect ${2:-pass} */"
}
function mkadd()
{
ex="expectPass"
if [ "$2" == "fail" ]; then
ex="expectFail"
fi
echo "\\\\tadd( static_cast<Bu::UnitSuite::Test>(\\&Unit::$1), \"$1\", Bu::UnitSuite::${ex} );\\\\n"
}
sedbits=""
init="#include \"bu/unitsuite.h\"\\\\n\\\\nclass Unit : public Bu::UnitSuite\\\\n{\\\\npublic:\\\\n\\\\nUnit()\\\\n{\\\\n\\\\tsetName(\"${1%.*}\");\\\\n"
for i in $(grep {% "$1"); do
sedbits="${sedbits}s@${i}@$(mkfunc $(echo $i | sed -e 's/.*{%\(.*\)}/\1/' -e 's/:/ /g'))@\n"
init="${init}$(mkadd $(echo $i | sed -e 's/.*{%\(.*\)}/\1/' -e 's/:/ /g'))"
done
init="${init}\\\\n}\\\\n\\\\nvirtual ~Unit() { }\\\\n\\\\n"
sedbits="${sedbits}s@.*{=Init}@${init}@\n"
temp=$(mktemp)
echo -e "$sedbits" > $temp
sed -f $temp $1 > $2
echo -e "\n};\n\nint main( int argc, char *argv[] )\n{\n\treturn Unit().run( argc, argv );\n}\n" >> $2
rm $temp
|