@@ -4,30 +4,40 @@ set -euo pipefail
4
4
SCRIPT_ROOT=" $( cd -P " $( dirname " $0 " ) " && pwd) "
5
5
TARBALL_PREFIX=dotnet-sdk-
6
6
VERSION_PREFIX=2.1
7
+ DEV_CERTS_VERSION_DEFAULT=2.1.0
7
8
8
9
projectOutput=false
9
10
keepProjects=false
10
11
dotnetDir=" "
11
12
configuration=" Release"
13
+ excludeNonWebTests=false
12
14
excludeWebTests=false
15
+ excludeWebNoHttpsTests=false
16
+ excludeWebHttpsTests=false
13
17
excludeLocalTests=false
14
18
excludeOnlineTests=false
19
+ devCertsVersion=" $DEV_CERTS_VERSION_DEFAULT "
15
20
testingDir=" $SCRIPT_ROOT /testing-smoke"
16
21
cliDir=" $testingDir /builtCli"
17
22
logFile=" $testingDir /smoke-test.log"
18
23
restoredPackagesDir=" $testingDir /packages"
24
+ testingHome=" $testingDir /home"
19
25
20
26
function usage() {
21
27
echo " "
22
28
echo " usage:"
23
- echo " --dotnetDir the directory from which to run dotnet"
24
- echo " --configuration the configuration being tested (default=Release)"
25
- echo " --projectOutput echo dotnet's output to console"
26
- echo " --keepProjects keep projects after tests are complete"
27
- echo " --minimal run minimal set of tests - local sources only, no web"
28
- echo " --excludeWebTests don't run tests for web projects"
29
- echo " --excludeLocalTests exclude tests that use local sources for nuget packages"
30
- echo " --excludeOnlineTests exclude test that use online sources for nuget packages"
29
+ echo " --dotnetDir the directory from which to run dotnet"
30
+ echo " --configuration the configuration being tested (default=Release)"
31
+ echo " --projectOutput echo dotnet's output to console"
32
+ echo " --keepProjects keep projects after tests are complete"
33
+ echo " --minimal run minimal set of tests - local sources only, no web"
34
+ echo " --excludeNonWebTests don't run tests for non-web projects"
35
+ echo " --excludeWebTests don't run tests for web projects"
36
+ echo " --excludeWebNoHttpsTests don't run web project tests with --no-https"
37
+ echo " --excludeWebHttpsTests don't run web project tests with https using dotnet-dev-certs"
38
+ echo " --excludeLocalTests exclude tests that use local sources for nuget packages"
39
+ echo " --excludeOnlineTests exclude test that use online sources for nuget packages"
40
+ echo " --devCertsVersion <version> use dotnet-dev-certs <version> instead of default $DEV_CERTS_VERSION_DEFAULT "
31
41
echo " "
32
42
}
33
43
@@ -57,18 +67,30 @@ while :; do
57
67
keepProjects=true
58
68
;;
59
69
--minimal)
60
- excludeWebTests=true
61
70
excludeOnlineTests=true
62
71
;;
72
+ --excludenonwebtests)
73
+ excludeNonWebTests=true
74
+ ;;
63
75
--excludewebtests)
64
76
excludeWebTests=true
65
77
;;
78
+ --excludewebnohttpstests)
79
+ excludeWebNoHttpsTests=true
80
+ ;;
81
+ --excludewebhttpstests)
82
+ excludeWebHttpsTests=true
83
+ ;;
66
84
--excludelocaltests)
67
85
excludeLocalTests=true
68
86
;;
69
87
--excludeonlinetests)
70
88
excludeOnlineTests=true
71
89
;;
90
+ --devcertsversion)
91
+ shift
92
+ devCertsVersion=" $1 "
93
+ ;;
72
94
* )
73
95
usage
74
96
exit 1
@@ -90,6 +112,24 @@ function doCommand() {
90
112
mkdir " ${lang} _${proj} "
91
113
cd " ${lang} _${proj} "
92
114
115
+ newArgs=" new $proj -lang $lang "
116
+
117
+ while : ; do
118
+ if [ $# -le 0 ]; then
119
+ break
120
+ fi
121
+ case " $1 " in
122
+ --new-arg)
123
+ shift
124
+ newArgs=" $newArgs $1 "
125
+ ;;
126
+ * )
127
+ break
128
+ ;;
129
+ esac
130
+ shift
131
+ done
132
+
93
133
while : ; do
94
134
if [ $# -le 0 ]; then
95
135
break
@@ -99,9 +139,9 @@ function doCommand() {
99
139
100
140
if [ " $1 " == " new" ]; then
101
141
if [ " $projectOutput " == " true" ]; then
102
- " ${dotnetCmd} " new $proj -lang $lang | tee -a " $logFile "
142
+ " ${dotnetCmd} " $newArgs | tee -a " $logFile "
103
143
else
104
- " ${dotnetCmd} " new $proj -lang $lang >> " $logFile " 2>&1
144
+ " ${dotnetCmd} " $newArgs >> " $logFile " 2>&1
105
145
fi
106
146
elif [[ " $1 " == " run" && " $proj " =~ ^(web| mvc| webapi| razor)$ ]]; then
107
147
if [ " $projectOutput " == " true" ]; then
@@ -110,12 +150,20 @@ function doCommand() {
110
150
" ${dotnetCmd} " $1 >> " $logFile " 2>&1 &
111
151
fi
112
152
webPid=$!
113
- echo " waiting 20 seconds for web project with pid $webPid "
114
- sleep 20
115
- echo " sending SIGINT to $webPid "
116
- pkill -SIGINT -P $webPid
153
+ killCommand=" pkill -SIGTERM -P $webPid "
154
+ echo " waiting up to 20 seconds for web project with pid $webPid ..."
155
+ echo " to clean up manually after an interactive cancellation, run: $killCommand "
156
+ for seconds in $( seq 20) ; do
157
+ if [ " $( tail -n 1 " $logFile " ) " = ' Application started. Press Ctrl+C to shut down.' ]; then
158
+ echo " app ready for shutdown after $seconds seconds"
159
+ break
160
+ fi
161
+ sleep 1
162
+ done
163
+ echo " stopping $webPid " | tee -a " $logFile "
164
+ $killCommand
117
165
wait $!
118
- echo " terminated with exit code $? "
166
+ echo " terminated with exit code $? " | tee -a " $logFile "
119
167
else
120
168
if [ " $projectOutput " == " true" ]; then
121
169
" ${dotnetCmd} " $1 | tee -a " $logFile "
@@ -141,35 +189,68 @@ function doCommand() {
141
189
echo " finished language $lang , type $proj " | tee -a smoke-test.log
142
190
}
143
191
192
+ function setupDevCerts() {
193
+ echo " Setting up dotnet-dev-certs $devCertsVersion to generate dev certificate" | tee -a " $logFile "
194
+ (
195
+ set -x
196
+ " $dotnetDir /dotnet" tool install -g dotnet-dev-certs --version " $devCertsVersion " --add-source https://dotnet.myget.org/F/dotnet-core/api/v3/index.json
197
+ export DOTNET_ROOT=" $dotnetDir "
198
+ " $testingHome /.dotnet/tools/dotnet-dev-certs" https
199
+ ) >> " $logFile " 2>&1
200
+ }
201
+
144
202
function runAllTests() {
145
203
# Run tests for each language and template
146
- doCommand C# console new restore run
147
- doCommand C# classlib new restore build
148
- doCommand C# xunit new restore test
149
- doCommand C# mstest new restore test
150
-
151
- doCommand VB console new restore run
152
- doCommand VB classlib new restore build
153
- doCommand VB xunit new restore test
154
- doCommand VB mstest new restore test
155
-
156
- doCommand F# console new restore run
157
- doCommand F# classlib new restore build
158
- doCommand F# xunit new restore test
159
- doCommand F# mstest new restore test
160
-
204
+ if [ " $excludeNonWebTests " == " false" ]; then
205
+ doCommand C# console new restore run
206
+ doCommand C# classlib new restore build
207
+ doCommand C# xunit new restore test
208
+ doCommand C# mstest new restore test
209
+
210
+ doCommand VB console new restore run
211
+ doCommand VB classlib new restore build
212
+ doCommand VB xunit new restore test
213
+ doCommand VB mstest new restore test
214
+
215
+ doCommand F# console new restore run
216
+ doCommand F# classlib new restore build
217
+ doCommand F# xunit new restore test
218
+ doCommand F# mstest new restore test
219
+ fi
220
+
161
221
if [ " $excludeWebTests " == " false" ]; then
162
- doCommand C# web new restore run
163
- doCommand C# mvc new restore run
164
- doCommand C# webapi new restore run
165
- doCommand C# razor new restore run
166
-
167
- doCommand F# web new restore run
168
- doCommand F# mvc new restore run
169
- doCommand F# webapi new restore run
222
+ if [ " $excludeWebNoHttpsTests " == " false " ] ; then
223
+ runWebTests --new-arg --no-https
224
+ fi
225
+
226
+ if [ " $excludeWebHttpsTests " == " false " ] ; then
227
+ setupDevCerts
228
+ runWebTests
229
+ fi
170
230
fi
171
231
}
172
232
233
+ function runWebTests() {
234
+ doCommand C# web " $@ " new restore run
235
+ doCommand C# mvc " $@ " new restore run
236
+ doCommand C# webapi " $@ " new restore run
237
+ doCommand C# razor " $@ " new restore run
238
+
239
+ doCommand F# web " $@ " new restore run
240
+ doCommand F# mvc " $@ " new restore run
241
+ doCommand F# webapi " $@ " new restore run
242
+ }
243
+
244
+ function resetCaches() {
245
+ rm -rf " $testingHome "
246
+ mkdir " $testingHome "
247
+
248
+ HOME=" $testingHome "
249
+
250
+ # clean restore path
251
+ rm -rf " $restoredPackagesDir "
252
+ }
253
+
173
254
function setupProdConFeed() {
174
255
sed -i.bakProdCon " s|PRODUCT_CONTRUCTION_PACKAGES|$prodConFeedUrl |g" " $testingDir /NuGet.Config"
175
256
}
@@ -207,6 +288,7 @@ prodConFeedUrl="$(cat "$SCRIPT_ROOT/ProdConFeed.txt")"
207
288
208
289
# Run all tests, local restore sources first, online restore sources second
209
290
if [ " $excludeLocalTests " == " false" ]; then
291
+ resetCaches
210
292
# Setup NuGet.Config with local restore source
211
293
if [ -e " $SCRIPT_ROOT /smoke-testNuGet.Config" ]; then
212
294
cp " $SCRIPT_ROOT /smoke-testNuGet.Config" " $testingDir /NuGet.Config"
@@ -220,10 +302,8 @@ if [ "$excludeLocalTests" == "false" ]; then
220
302
echo " LOCAL RESTORE SOURCE - ALL TESTS PASSED!"
221
303
fi
222
304
223
- # clean restore path
224
- rm -rf " $restoredPackagesDir "
225
-
226
305
if [ " $excludeOnlineTests " == " false" ]; then
306
+ resetCaches
227
307
# Setup NuGet.Config to use online restore sources
228
308
if [ -e " $SCRIPT_ROOT /smoke-testNuGet.Config" ]; then
229
309
cp " $SCRIPT_ROOT /smoke-testNuGet.Config" " $testingDir /NuGet.Config"
0 commit comments