-
Notifications
You must be signed in to change notification settings - Fork 1
/
replace.sh
66 lines (54 loc) · 1.7 KB
/
replace.sh
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
#!/bin/sh
tdir=${1:-$TDIR}
echo $tdir
# It is just used to remove HyperShiftGUEST label and add NonHyperShiftHOST on the test cases without HyperShiftGUEST
# It is better to run in the openshift-test-private, otherwise use a abs dir below
# sh replace.sh ./test/extended/apiserverauth/apiserver.go true
# sh replace.sh ./test/extended/networking true
# sh replace.sh ./test/extended/workloads/ true
# sh replace.sh ./test/extended/workloads/ true
# only print sed result without real change by default
execute=$2
result_file="result-$RANDOM.txt"
function print_sed() {
local file=$1
sed '/HyperShiftGUEST/!s/g.It("/g.It("NonHyperShiftHOST-/g' $file | sed 's/HyperShiftGUEST-//g' $file
}
function sed_linux() {
local file=$1
sed -i '/HyperShiftGUEST/!s/g.It("/g.It("NonHyperShiftHOST-/g' $file
sed -i 's/HyperShiftGUEST-//g' $file
}
function sed_mac() {
local file=$1
sed -i "" '/HyperShiftGUEST/!s/g.It("/g.It("NonHyperShiftHOST-/g' $file
sed -i "" 's/HyperShiftGUEST-//g' $file
}
for file in `find $tdir -type f -name "*.go" `; do
echo $file
if [[ $tdir == *"networking"* ]]; then
echo "It's for networking sdn by default!"
# There are not only SDN testcases in networking dir, find them by [sig-networking] SDN
res=$(grep "\"\[sig-networking\] SDN\"" $file)
if [ -z "$res" ] ; then
continue
fi
fi
echo "$file" >> $result_file
if [ -z $execute ] ; then
print_sed $file
continue
fi
os="$(uname -s)"
case "${os}" in
Linux*)
sed_linux $file
;;
Darwin*)
sed_mac $file
;;
*)
echo "unknown system exit!"
exit 1
esac
done