forked from root-project/roottest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
addtest
executable file
·103 lines (78 loc) · 2.31 KB
/
addtest
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
# Name: addtest
# Desc: Updates the Makefile
# Args: $1 -> test directory
# $2 -> test Name
#
scriptdir=`dirname $0`
printUSAGE() {
echo "" ;
echo "Usage: addtest test_path test_name" ;
echo " where test name is the name of the test to be added"
echo " where test path is the directory path for the test to be added";
echo "";
echo "addtest is a script to add test to the directories, update
Makefile, create .ref, runTESTNAME.C and update cvs repository";
echo "" ;
exit 1;
}
if [ $# -lt 2 ] ; then
printUSAGE ;
fi
dir=$1
testname=$2
printALREADY_EXIST() {
echo "" ;
echo "A target '$1' already exists in $2/Makefile " ;
exit 1 ;
}
printERROR() { echo "ERROR: $@." >&2 ; }
printWarning() { echo "Warning: $@." >&2 ; }
# check whether sufficient args are given
check_target=`grep -F " $testname " $dir/Makefile 2>/dev/null`
if [ "$check_target" != "" ]; then
printALREADY_EXIST $testname $dir;
fi
check_target2=`grep "^[[:space:]]*$testname[[:space:]]*:" $dir/Makefile 2>/dev/null`
if [ "$check_target2" != "" ]; then
printALREADY_EXIST $testname $dir;
fi
if [ ! -d "$dir" ] ; then
printWarning "The source $dir is not a directory, or does not exist"
echo "use 'mktest $dir' to add test directory by selecting 1."
#mktest $dir
selection=
until [ "$selection" = "0" ]; do
echo "1 - Create $dir and add test '$testname'"
echo "0 - exit"
echo ""
echo -n "Enter selection: "
read selection
echo ""
case $selection in
1 ) $scriptdir/mktest $dir ; $scriptdir/addtest $dir $testname; exit 1;;
0 ) exit ;;
* ) echo "Please enter 1 or 0"
esac
done
fi
cd $dir
sed -e "s/TEST_TARGETS += /TEST_TARGETS += $testname /g" Makefile > Makefile1
rm Makefile
mv Makefile1 Makefile
echo "" >> Makefile
echo "$testname: $testname.log" >> Makefile
echo " \$(TestDiff)" >> Makefile
git add Makefile
if [ ! -s $testname.ref ]; then
echo "" > $testname.ref
echo "Processing run$testname.C..." >> $testname.ref
git add $testname.ref
fi
if [ ! -s run$testname.C ]; then
echo "{" > run$testname.C
echo "// Fill out the code of the actual test" >> run$testname.C
echo "}" >> run$testname.C
git add run$testname.C
fi
echo "Message: Test successfully added"