Skip to content

Commit e6a3f04

Browse files
authored
Update smoke test to allow local restore source testing (#507)
1 parent fe4ae4b commit e6a3f04

File tree

2 files changed

+89
-32
lines changed

2 files changed

+89
-32
lines changed

smoke-test.sh

Lines changed: 80 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,31 @@ SCRIPT_ROOT="$(cd -P "$( dirname "$0" )" && pwd)"
55
TARBALL_PREFIX=dotnet-sdk-
66
VERSION_PREFIX=2.1
77
OUTPUT_DIR="$SCRIPT_ROOT/bin/x64/Release/"
8+
SOURCE_BUILT_PKGS_PATH="$SCRIPT_ROOT/bin/obj/x64/Release/blob-feed/packages/"
89
DOTNET_TARBALL_REL=$(ls ${OUTPUT_DIR}dotnet-sdk-${VERSION_PREFIX}*)
910
DOTNET_TARBALL=$(readlink -e ${DOTNET_TARBALL_REL})
1011

1112
projectOutput=false
1213
keepProjects=false
1314
dotnetDir=""
14-
includeWeb=false
15+
excludeWebTests=false
16+
excludeLocalTests=false
17+
excludeOnlineTests=false
1518
testingDir="$SCRIPT_ROOT/testing-smoke"
1619
cliDir="$testingDir/builtCli"
1720
logFile="$testingDir/smoke-test.log"
21+
restoredPackagesDir="$testingDir/packages"
1822

1923
function usage() {
2024
echo ""
2125
echo "usage:"
22-
echo " --dotnetDir the directory from which to run dotnet"
23-
echo " --projectOutput echo dotnet's output to console"
24-
echo " --keepProjects keep projects after tests are complete"
25-
echo " --includeWeb run tests for web projects"
26+
echo " --dotnetDir the directory from which to run dotnet"
27+
echo " --projectOutput echo dotnet's output to console"
28+
echo " --keepProjects keep projects after tests are complete"
29+
echo " --minimal run minimal set of tests - local sources only, no web"
30+
echo " --excludeWebTests don't run tests for web projects"
31+
echo " --excludeLocalTests exclude tests that use local sources for nuget packages"
32+
echo " --excludeOnlineTests exclude test that use online sources for nuget packages"
2633
echo ""
2734
}
2835

@@ -47,8 +54,18 @@ while :; do
4754
--keepprojects)
4855
keepProjects=true
4956
;;
50-
--includeweb)
51-
includeWeb=true
57+
--minimal)
58+
excludeWebTests=true
59+
excludeOnlineTests=true
60+
;;
61+
--excludewebtests)
62+
excludeWebTests=true
63+
;;
64+
--excludelocaltests)
65+
excludeLocalTests=true
66+
;;
67+
--excludeonlinetests)
68+
excludeOnlineTests=true
5269
;;
5370
*)
5471
usage
@@ -122,6 +139,35 @@ function doCommand() {
122139
echo "finished language $lang, type $proj" | tee -a smoke-test.log
123140
}
124141

142+
function runAllTests() {
143+
# Run tests for each language and template
144+
doCommand C# console new restore run
145+
doCommand C# classlib new restore build
146+
doCommand C# xunit new restore test
147+
doCommand C# mstest new restore test
148+
149+
doCommand VB console new restore run
150+
doCommand VB classlib new restore build
151+
doCommand VB xunit new restore test
152+
doCommand VB mstest new restore test
153+
154+
doCommand F# console new restore run
155+
doCommand F# classlib new restore build
156+
doCommand F# xunit new restore test
157+
doCommand F# mstest new restore test
158+
159+
if [ "$excludeWebTests" == "false" ]; then
160+
doCommand C# web new restore run
161+
doCommand C# mvc new restore run
162+
doCommand C# webapi new restore run
163+
doCommand C# razor new restore run
164+
165+
doCommand F# web new restore run
166+
doCommand F# mvc new restore run
167+
doCommand F# webapi new restore run
168+
fi
169+
}
170+
125171
# Clean up and create directory
126172
if [ -e "$testingDir" ]; then
127173
read -p "testing-smoke directory exists, remove it? [Y]es / [n]o" -n 1 -r
@@ -145,31 +191,33 @@ else
145191
fi
146192
fi
147193

148-
# Run tests for each language and template
149-
doCommand C# console new restore run
150-
doCommand C# classlib new restore build
151-
doCommand C# xunit new restore test
152-
doCommand C# mstest new restore test
153-
154-
doCommand VB console new restore run
155-
doCommand VB classlib new restore build
156-
doCommand VB xunit new restore test
157-
doCommand VB mstest new restore test
158-
159-
doCommand F# console new restore run
160-
doCommand F# classlib new restore build
161-
doCommand F# xunit new restore test
162-
doCommand F# mstest new restore test
163-
164-
if [ "$includeWeb" == "true" ]; then
165-
doCommand C# web new restore run
166-
doCommand C# mvc new restore run
167-
doCommand C# webapi new restore run
168-
doCommand C# razor new restore run
169-
170-
doCommand F# web new restore run
171-
doCommand F# mvc new restore run
172-
doCommand F# webapi new restore run
194+
# setup restore path
195+
export NUGET_PACKAGES="$restoredPackagesDir"
196+
197+
# Run all tests, local restore sources first, online restore sources second
198+
if [ "$excludeLocalTests" == "false" ]; then
199+
# Setup NuGet.Config with local restore source
200+
if [ -e "$SCRIPT_ROOT/smoke-testNuGet.Config" ]; then
201+
cp "$SCRIPT_ROOT/smoke-testNuGet.Config" "$testingDir/NuGet.Config"
202+
sed -i "s|SOURCE_BUILT_PACKAGES|$SOURCE_BUILT_PKGS_PATH|g" "$testingDir/NuGet.Config"
203+
fi
204+
echo "RUN ALL TESTS - LOCAL RESTORE SOURCE"
205+
runAllTests
206+
echo "LOCAL RESTORE SOURCE - ALL TESTS PASSED!"
207+
fi
208+
209+
# clean restore path
210+
rm -rf "$restoredPackagesDir"
211+
212+
if [ "$excludeOnlineTests" == "false" ]; then
213+
# Setup NuGet.Config to use online restore sources
214+
if [ -e "$SCRIPT_ROOT/smoke-testNuGet.Config" ]; then
215+
cp "$SCRIPT_ROOT/smoke-testNuGet.Config" "$testingDir/NuGet.Config"
216+
sed -i "/SOURCE_BUILT_PACKAGES/d" "$testingDir/NuGet.Config"
217+
fi
218+
echo "RUN ALL TESTS - ONLINE RESTORE SOURCE"
219+
runAllTests
220+
echo "ONLINE RESTORE SOURCE - ALL TESTS PASSED!"
173221
fi
174222

175223
rm -rf "$cliDir"

smoke-testNuGet.Config

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
5+
<clear />
6+
<add key="source-built-packages" value="SOURCE_BUILT_PACKAGES" />
7+
<add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" />
8+
</packageSources>
9+
</configuration>

0 commit comments

Comments
 (0)