Repository navigation
Expand file tree
/
Copy pathdcoverage.sh
More file actions
executable file
·128 lines (114 loc) · 3.39 KB
/
Copy pathdcoverage.sh
File metadata and controls
executable file
·128 lines (114 loc) · 3.39 KB
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/bash
buildImage () {
cd ./dockerhub/coverage
docker build -t evmone-coverage-script .
exit 0
}
rebuildImage () {
cd ./dockerhub/coverage
docker build --no-cache -t evmone-coverage-script .
exit 0
}
printHelp() {
echo "Usage:"
echo "./dcoverage.sh --tests=./testsA --mode=cover --outputname=BASE [--driver=retesteth|native]"
echo "./dcoverage.sh --tests=./testsB --mode=cover --outputname=PATCH [--driver=retesteth|native]"
echo "./dcoverage.sh --mode=diff --basefile=coverage_BASE.lcov --patchfile=coverage_PATCH.lcov"
# echo ""
# echo "With --driver=retesteth (default) only:"
# echo "./dcoverage.sh --testrepo --test_type=GeneralStateTests/stExample"
exit 0
}
cleanDocker () {
# Ask user a confirmation
read -p "This will clean all docker containers and docker system, do you want to proceed? (y|n) " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
docker rmi evmone-coverage-script:latest
docker image rm evmone-coverage-script
docker image prune -a -f
docker container prune -f
docker volume prune -f
docker image rm evmone-coverage-script
docker rmi evmone-coverage-script:latest
docker system prune -f
docker system prune -a --volumes
fi
exit 0
}
case $1 in
"build")
buildImage
;;
"rebuild")
rebuildImage
;;
"clean")
cleanDocker
;;
esac
testpath=$(pwd)/coverage
MOUNT="-v $testpath:/tests"
user=$(whoami)
sudo chown -R $user:$user $testpath
driver="retesteth"
while [ "$#" -gt 0 ]; do
case "$1" in
--driver=*) # retesteth | native
driver="${1#*=}"
shift 1
;;
--mode=*) # cover | covertests | diff
mode="${1#*=}"
shift 1
;;
--tests=*) # path to the folder with tests
tests="${1#*=}"
shift 1
;;
--basefile=*)
basefile="${1#*=}"
shift 1
;;
--patchfile=*)
patchfile="${1#*=}"
shift 1
;;
--outputname=*) # filename to save to coverage results
outputname="${1#*=}"
shift 1
;;
*)
echo "Unknown option: $1"
printHelp
exit 1
;;
esac
done
if [[ -z "$outputname" || -z "$mode" || -z "$tests" ]]; then
if [[ -z "$basefile" || -z "$patchfile" ]]; then
echo "Missing options, read help:"
printHelp
exit 1
fi
fi
if [ -d "${testpath}/${outputname}_TESTS" -a ! -z "$outputname" ]; then
rm -r "${testpath}/${outputname}"
rm -r "${testpath}/${outputname}_TESTS"
rm "${testpath}/coverage_${outputname}.lcov"
fi
if [ -n "$outputname" ]; then
mkdir "${testpath}/${outputname}_TESTS"
fi
if [[ "$mode" == "cover" ]]; then
cp -r $tests/* "${testpath}/${outputname}_TESTS"
docker run $MOUNT evmone-coverage-script --mode=$mode --driver=$driver --testpath=/tests/${outputname}_TESTS --outputname=${outputname}
fi
if [[ "$mode" == "diff" ]]; then
rm -r "${testpath}/DIFF"
rm "${testpath}/difflog.txt"
docker run $MOUNT evmone-coverage-script --mode=$mode --basefile=$basefile --patchfile=$patchfile
docker run $MOUNT -it --entrypoint=./check.sh evmone-coverage-script
fi
sudo chown -R $user:$user $testpath