This repository has been archived by the owner on Feb 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ut.sh
171 lines (152 loc) · 3.89 KB
/
ut.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
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/bin/bash
function upload_codecov_report {
# upload_codecov_report <dir> <flag>
cd "$1" || return 126
wget --no-check-certificate https://codecov.io/bash -O codecov.sh
pwd
bash codecov.sh -cF "$2"
return $?
}
function run_cpp {
cd cpp/ || return 126
sudo add-apt-repository ppa:mhier/libboost-latest -y || return 126
sudo apt-get update || return 126
aptitude search boost || return 126
sudo apt-get install libboost-all-dev || return 126
sudo apt-get install lcov libcpprest-dev libcurl4-openssl-dev libssl-dev uuid-dev libjson-c-dev libjsoncpp-dev || return 126
sh scripts/run_ut.sh || return 126
cd ../
upload_codecov_report cpp cpp
}
function run_php {
cd php/ || return 126
composer --version
composer install -vvv
composer test || return 126
cd ../
upload_codecov_report php php
}
function run_swift {
cd swift/ || rerturn 126
swift package generate-xcodeproj --enable-code-coverage
xcodebuild clean build -project AlibabaCloudRoaUtils.xcodeproj -scheme "AlibabaCloudRoaUtils-Package" -sdk "macosx" -destination "platform=OS X,arch=x86_64" -configuration Debug ONLY_ACTIVE_ARCH=NO test
xcodebuild test -project AlibabaCloudRoaUtils.xcodeproj -scheme "AlibabaCloudRoaUtils-Package" -sdk "macosx" -destination "platform=OS X,arch=x86_64" -configuration Debug ONLY_ACTIVE_ARCH=NO test || return 126
cd ../
upload_codecov_report swift swift
}
function run_go {
cd golang/ || return 126
export GO111MODULE=on
go mod tidy
go test -race -coverprofile=coverage.txt -covermode=atomic ./service/... || return 126
cd ../
upload_codecov_report golang go
}
function run_csharp {
# before_install
wget https://download.visualstudio.microsoft.com/download/pr/42f39f2f-3f24-4340-8c57-0a3133620c21/0a353696275b00cbddc9f60069867cfc/dotnet-sdk-2.2.110-linux-x64.tar.gz
mkdir -p ~/dotnet/ && tar zxf dotnet-sdk-2.2.110-linux-x64.tar.gz -C ~/dotnet/
sudo ln -sf ~/dotnet/dotnet /usr/bin/dotnet
dotnet --info
# install
cd csharp/tests/ || return 126
dotnet tool install --global altcover.visualizer
dotnet restore
dotnet build
cd ../
# run tests
dotnet test tests/ /p:AltCover=true || return 126
cd ../
# upload code coverage report
upload_codecov_report csharp csharp
}
function run_java {
cd java/ || return 126
mvn test -B || return 126
cd ../
upload_codecov_report java java
}
function run_ts {
cd ts/ || return 126
npm install
npm run test-cov || return 126
cd ../
upload_codecov_report ts node_js
}
function run_python {
#env
export PYTHONPATH=$PYTHONPATH:`pwd`/python
echo $PYTHONPATH
# install
cd python || return 126
pip install coverage
pip install alibabacloud-tea
pip install alibabacloud-tea-util
coverage run --source="./alibabacloud_roa_util" -m pytest tests/test_* || return 126
cd ../
upload_codecov_report python python
}
function run_python2 {
#env
export PYTHONPATH=$PYTHONPATH:`pwd`/python2
echo $PYTHONPATH
# install
cd python2 || return 126
pip install coverage
pip install alibabacloud-tea-py2
pip install alibabacloud-tea-util-py2
coverage run --source="./alibabacloud_roa_util" -m pytest tests/ || return 126
cd ../
upload_codecov_report python python
}
function contains {
local value=$2
for i in $1
do
if [ "$i" == "$value" ]; then
echo "y"
return 0
fi
done
echo "n"
return 1
}
lang=$1
if [ "$lang" == "swift" ]
then
echo "run swift"
run_swift
elif [ "$lang" == "php" ]
then
echo "run php"
run_php
elif [ "$lang" == "csharp" ]
then
echo "run csharp"
run_csharp
elif [ "$lang" == "java" ]
then
echo "run java"
run_java
elif [ "$lang" == "ts" ]
then
echo "run ts"
run_ts
elif [ "$lang" == "go" ]
then
echo "run golang"
run_go
elif [ "$lang" == "python" ]
then
echo "run python"
run_python
elif [ "$lang" == "python2" ]
then
echo "run python2"
run_python2
elif [ "$lang" == "cpp" ]
then
echo "run cpp"
run_cpp
fi
exit $?