Merge branch 'publish-tests1' of https://github.com/sridhar-ms/cli

This commit is contained in:
Sridhar Periyasamy 2015-12-14 17:42:22 -08:00
commit f910bc9eff
42 changed files with 1825 additions and 128 deletions

View file

@ -129,20 +129,13 @@ Download it from https://www.cmake.org
if (!$?) {
Write-Host "Command failed: " cmd /c "$PSScriptRoot\build\build_appdeps.cmd" "$Stage2Dir"
Exit 1
}
}
# Smoke test stage2
$env:DOTNET_HOME = "$Stage2Dir"
& "$PSScriptRoot\test\smoke-test.ps1"
# Run tests on stage2 dotnet tools
& "$PSScriptRoot\test\runtests.ps1"
if (!$?) {
Write-Host "Command failed: $PSScriptRoot\test\smoke-test.ps1"
Exit 1
}
# E2E Test of stage2
& "$PSScriptRoot\test\e2e-test.ps1"
if (!$?) {
Write-Host "Command failed: $PSScriptRoot\test\e2e-test.ps1"
Write-Host "Command failed: $PSScriptRoot\test\runtests.ps1"
Exit 1
}

View file

@ -111,10 +111,6 @@ DOTNET_HOME=$STAGE2_DIR DOTNET_TOOLS=$STAGE2_DIR $REPOROOT/scripts/build/build_a
COMMIT_ID=$(git rev-parse HEAD)
echo $COMMIT_ID > $STAGE2_DIR/.commit
# Smoke-test the output
header "Testing stage2 ..."
DOTNET_HOME=$STAGE2_DIR DOTNET_TOOLS=$STAGE2_DIR $DIR/test/smoke-test.sh
# E2E test on the output
header "Testing stage2 End to End ..."
DOTNET_HOME=$STAGE2_DIR DOTNET_TOOLS=$STAGE2_DIR $DIR/test/e2e-test.sh
header "Testing stage2..."
DOTNET_HOME=$STAGE2_DIR DOTNET_TOOLS=$STAGE2_DIR $DIR/test/runtests.sh

View file

@ -1,44 +0,0 @@
#
# Copyright (c) .NET Foundation and contributors. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
#
. "$PSScriptRoot\..\_common.ps1"
# Restore and compile the test app
dotnet restore "$RepoRoot\test\E2E" --runtime "osx.10.10-x64" --runtime "ubuntu.14.04-x64" --runtime "win7-x64"
if (!$?) {
Write-Host "Command failed: dotnet restore"
Exit 1
}
dotnet publish --framework dnxcore50 --runtime "$Rid" --output "$RepoRoot\artifacts\$Rid\e2etest" "$RepoRoot\test\E2E"
if (!$?) {
Write-Host "Command failed: dotnet publish"
Exit 1
}
## Temporary Workaround for Native Compilation
## Need x64 Native Tools Dev Prompt Env Vars
## Tracked Here: https://github.com/dotnet/cli/issues/301
pushd "$env:VS140COMNTOOLS\..\..\VC"
cmd /c "vcvarsall.bat x64&set" |
foreach {
if ($_ -match "=") {
$v = $_.split("=", 2); set-item -force -literalpath "ENV:\$($v[0])" -value "$($v[1])"
}
}
popd
# Run the app and check the exit code
pushd "$RepoRoot\artifacts\$Rid\e2etest"
mv E2E.exe corehost.exe -Force
& "corehost.exe" "xunit.console.netcore.exe" "E2E.dll" -xml ..\..\e2etest.xml
if (!$?) {
Write-Host "E2E Test Failure"
popd
Exit 1
}
else {
popd
}

68
scripts/test/runtests.ps1 Normal file
View file

@ -0,0 +1,68 @@
#
# Copyright (c) .NET Foundation and contributors. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
#
. "$PSScriptRoot\..\_common.ps1"
$TestBinRoot = "$RepoRoot\artifacts\tests"
$TestProjects = @(
"E2E",
"Microsoft.DotNet.Tools.Publish.Tests"
)
# Publish each test project
$TestProjects | ForEach-Object {
dotnet publish --framework "dnxcore50" --runtime "$Rid" --output "$TestBinRoot" --configuration "$Configuration" "$RepoRoot\test\$_"
if (!$?) {
Write-Host Command failed: dotnet publish --framework "dnxcore50" --runtime "$Rid" --output "$TestBinRoot" --configuration "$Configuration" "$RepoRoot\test\$_"
exit 1
}
}
## Temporary Workaround for Native Compilation
## Need x64 Native Tools Dev Prompt Env Vars
## Tracked Here: https://github.com/dotnet/cli/issues/301
pushd "$env:VS140COMNTOOLS\..\..\VC"
cmd /c "vcvarsall.bat x64&set" |
foreach {
if ($_ -match "=") {
$v = $_.split("=", 2); set-item -force -literalpath "ENV:\$($v[0])" -value "$($v[1])"
}
}
popd
# copy TestProjects folder which is used by the test cases
mkdir -Force "$TestBinRoot\TestProjects"
cp -rec -Force "$RepoRoot\test\TestProjects\*" "$TestBinRoot\TestProjects"
$failCount = 0
$failingTests = @()
pushd "$TestBinRoot"
# Run each test project
$TestProjects | ForEach-Object {
& "corerun.exe" "xunit.console.netcore.exe" "$_.dll" -xml "$_.xml" -notrait category=failing
$exitCode = $LastExitCode
if ($exitCode -ne 0) {
$failingTests += "$_"
}
$failCount += $exitCode
}
popd
if ($failCount -ne 0) {
Write-Host -ForegroundColor Red "The following tests failed."
$failingTests | ForEach-Object {
Write-Host -ForegroundColor Red "$_.dll failed. Logs in '$TestBinRoot\$_.xml'"
}
}
else {
Write-Host -ForegroundColor Green "All the tests passed!"
}
Exit $failCount

View file

@ -16,12 +16,30 @@ DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
source "$DIR/../_common.sh"
rm "$REPOROOT/test/E2E/project.lock.json"
dotnet restore --quiet "$REPOROOT/test/E2E" --runtime "osx.10.10-x64" --runtime "ubuntu.14.04-x64" --runtime "win7-x64"
dotnet publish --framework dnxcore50 --runtime "$RID" --output "$REPOROOT/artifacts/$RID/e2etest" "$REPOROOT/test/E2E"
TestBinRoot="$REPOROOT/artifacts/tests"
TestProjects=( \
E2E \
Microsoft.DotNet.Tools.Publish.Tests \
)
for project in ${TestProjects[@]}
do
dotnet publish --framework "dnxcore50" --runtime "$RID" --output "$TestBinRoot" --configuration "$CONFIGURATION" "$REPOROOT/test/$project"
done
# copy TestProjects folder which is used by the test cases
mkdir -p "$TestBinRoot/TestProjects"
cp -R $REPOROOT/test/TestProjects/* $TestBinRoot/TestProjects
# set -e will abort if the exit code of this is non-zero
pushd "$REPOROOT/artifacts/$RID/e2etest"
mv ./E2E ./corehost
./corehost xunit.console.netcore.exe E2E.dll
pushd "$TestBinRoot"
for project in ${TestProjects[@]}
do
./corerun "xunit.console.netcore.exe" "$project.dll" -xml "project.xml"
done
popd

View file

@ -1,25 +0,0 @@
#
# Copyright (c) .NET Foundation and contributors. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
#
. "$PSScriptRoot\..\_common.ps1"
# Restore and compile the test app
dotnet restore "$RepoRoot\test\TestApp" --runtime "osx.10.10-x64" --runtime "ubuntu.14.04-x64" --runtime "win7-x64"
dotnet compile "$RepoRoot\test\TestApp" --output "$RepoRoot\artifacts\$Rid\smoketest"
# Run the app and check the exit code
& "$RepoRoot\artifacts\$Rid\smoketest\TestApp.exe"
if ($LASTEXITCODE -ne 0) {
throw "Test App failed to run"
}
# Check that a compiler error is reported
$oldErrorAction = $ErrorActionPreference
$ErrorActionPreference="SilentlyContinue"
dotnet compile "$RepoRoot\test\compile\failing\SimpleCompilerError" --framework "$Tfm" 2>$null >$null
if ($LASTEXITCODE -eq 0) {
throw "Compiler error didn't cause non-zero exit code!"
}
$ErrorActionPreference = $oldErrorAction

View file

@ -1,35 +0,0 @@
#!/usr/bin/env bash
#
# Copyright (c) .NET Foundation and contributors. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
#
set -e
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
REPOROOT="$( cd -P "$DIR/../.." && pwd )"
source "$DIR/../_common.sh"
rm "$REPOROOT/test/TestApp/project.lock.json"
dotnet restore "$REPOROOT/test/TestApp" --runtime "osx.10.10-x64" --runtime "ubuntu.14.04-x64" --runtime "win7-x64"
dotnet compile "$REPOROOT/test/TestApp" --output "$REPOROOT/artifacts/$RID/smoketest"
# set -e will abort if the exit code of this is non-zero
$REPOROOT/artifacts/$RID/smoketest/TestApp
# Check that a compiler error is reported
set +e
dotnet compile "$REPOROOT/test/compile/failing/SimpleCompilerError" --framework "$TFM" 2>/dev/null >/dev/null
rc=$?
if [ $rc == 0 ]; then
error "Compiler failure test failed! The compiler did not fail to compile!"
exit 1
fi
set -e