提交 a005d688 编写于 作者: A Ashley Hauck 提交者: GitHub

Merge pull request #22145 from khyperia/twiddle_tests_sh

Refactor tests.sh to be a bit cleaner
......@@ -7,13 +7,7 @@ set -u
get_repo_dir()
{
local d=$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)
pushd $d > /dev/null
cd ..
cd ..
local repoDir=$(pwd)
popd > /dev/null
echo $repoDir
cd -P "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd
}
# This function will give you the current version number for the specified string in the
......
......@@ -5,58 +5,53 @@
set -e
set -u
BUILD_CONFIGURATION=${1:-Debug}
build_configuration=${1:-Debug}
THIS_DIR=$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)
source ${THIS_DIR}/build-utils.sh
this_dir=$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)
source ${this_dir}/build-utils.sh
BINARIES_PATH=${THIS_DIR}/../../Binaries
SRC_PATH=${THIS_DIR}/../..
UNITTEST_DIR=${BINARIES_PATH}/${BUILD_CONFIGURATION}/UnitTests
LOG_DIR=${BINARIES_PATH}/${BUILD_CONFIGURATION}/xUnitResults
NUGET_DIR=${HOME}/.nuget/packages
RUNTIME_ID=$(dotnet --info | awk '/RID:/{print $2;}')
TARGET_FRAMEWORK=netcoreapp2.0
XUNIT_CONSOLE_VERSION=$(get_package_version dotnet-xunit)
XUNIT_CONSOLE=${NUGET_DIR}/dotnet-xunit/${XUNIT_CONSOLE_VERSION}/tools/${TARGET_FRAMEWORK}/xunit.console.dll
root_path=$(get_repo_dir)
binaries_path=${root_path}/Binaries
unittest_dir=${binaries_path}/${build_configuration}/UnitTests
log_dir=${binaries_path}/${build_configuration}/xUnitResults
nuget_dir=${HOME}/.nuget/packages
runtime_id=$(dotnet --info | awk '/RID:/{print $2;}')
target_framework=netcoreapp2.0
xunit_console_version=$(get_package_version dotnet-xunit)
xunit_console=${nuget_dir}/dotnet-xunit/${xunit_console_version}/tools/${target_framework}/xunit.console.dll
echo Using $XUNIT_CONSOLE
echo "Using ${xunit_console}"
# Need to publish projects that have runtime assets before running tests
NEED_PUBLISH=(
'src\Compilers\CSharp\Test\Symbol\CSharpCompilerSymbolTest.csproj'
need_publish=(
'src/Compilers/CSharp/Test/Symbol/CSharpCompilerSymbolTest.csproj'
)
for p in $NEED_PUBLISH
for project in $need_publish
do
echo Publishing ${p}
dotnet publish --no-restore ${SRC_PATH}/${p} -p:RuntimeIdentifier=${RUNTIME_ID} -p:TargetFramework=${TARGET_FRAMEWORK} -p:SelfContained=true
echo "Publishing ${project}"
dotnet publish --no-restore ${root_path}/${project} -r ${runtime_id} -f ${target_framework} -p:SelfContained=true
done
# Discover and run the tests
mkdir -p ${LOG_DIR}
pushd ${UNITTEST_DIR}
mkdir -p "${log_dir}"
for d in *
for test_path in ${unittest_dir}/*/${target_framework}
do
TEST_PATH=${UNITTEST_DIR}/${d}/${TARGET_FRAMEWORK}
PUBLISH_TEST_PATH=${TEST_PATH}/${RUNTIME_ID}/publish
if [ -d ${PUBLISH_TEST_PATH} ]
publish_test_path=${test_path}/${runtime_id}/publish
if [ -d ${publish_test_path} ]
then
TEST_PATH=${PUBLISH_TEST_PATH}
test_path=${publish_test_path}
fi
pushd $TEST_PATH
FILE_NAME=$(ls *.UnitTests.dll)
LOG_NAME="${FILE_NAME%.*}.xml"
echo Running ${TEST_PATH}/${FILE_NAME}
dotnet exec --depsfile "${FILE_NAME%.*}.deps.json" --runtimeconfig "${FILE_NAME%.*}.runtimeconfig.json" ${XUNIT_CONSOLE} $FILE_NAME -xml ${LOG_DIR}/${LOG_NAME}
if [ $? -ne 0 ]; then
file_name=( ${test_path}/*.UnitTests.dll )
log_file="${log_dir}/$(basename "${file_name%.*}.xml")"
deps_json="${file_name%.*}.deps.json"
runtimeconfig_json="${file_name%.*}.runtimeconfig.json"
echo "Running ${file_name}"
dotnet exec --depsfile "${deps_json}" --runtimeconfig "${runtimeconfig_json}" ${xunit_console} "$file_name" -xml "${log_file}"
if [[ $? -ne 0 ]]; then
echo Unit test failed
exit 1
fi
popd
done
popd
......@@ -19,9 +19,11 @@ usage()
}
THIS_DIR=$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)
BINARIES_PATH=${THIS_DIR}/Binaries
source ${THIS_DIR}/build/scripts/build-utils.sh
ROOT_PATH=$(get_repo_dir)
BINARIES_PATH=${ROOT_PATH}/Binaries
BOOTSTRAP_PATH=${BINARIES_PATH}/Bootstrap
SRC_PATH=${THIS_DIR}/src
SRC_PATH=${ROOT_PATH}/src
BUILD_LOG_PATH=${BINARIES_PATH}/Build.log
TARGET_FRAMEWORK=netcoreapp2.0
......@@ -95,18 +97,18 @@ fi
# obtain_dotnet.sh puts the right dotnet on the PATH
FORCE_DOWNLOAD=true
source ${THIS_DIR}/build/scripts/obtain_dotnet.sh
source ${ROOT_PATH}/build/scripts/obtain_dotnet.sh
RUNTIME_ID=$(dotnet --info | awk '/RID:/{print $2;}')
echo "Using Runtime Identifier: ${RUNTIME_ID}"
RESTORE_ARGS="-r ${RUNTIME_ID} -v Minimal --disable-parallel"
echo "Restoring BaseToolset.csproj"
dotnet restore ${RESTORE_ARGS} ${THIS_DIR}/build/ToolsetPackages/BaseToolset.csproj
dotnet restore ${RESTORE_ARGS} ${ROOT_PATH}/build/ToolsetPackages/BaseToolset.csproj
echo "Restoring CoreToolset.csproj"
dotnet restore ${RESTORE_ARGS} ${THIS_DIR}/build/ToolsetPackages/CoreToolset.csproj
dotnet restore ${RESTORE_ARGS} ${ROOT_PATH}/build/ToolsetPackages/CoreToolset.csproj
echo "Restoring CrossPlatform.sln"
dotnet restore ${RESTORE_ARGS} ${THIS_DIR}/CrossPlatform.sln
dotnet restore ${RESTORE_ARGS} ${ROOT_PATH}/CrossPlatform.sln
BUILD_ARGS="--no-restore -c ${BUILD_CONFIGURATION} /nologo /consoleloggerparameters:Verbosity=minimal;summary /filelogger /fileloggerparameters:Verbosity=normal;logFile=${BUILD_LOG_PATH} /maxcpucount:1"
PUBLISH_ARGS="-f ${TARGET_FRAMEWORK} -r ${RUNTIME_ID} ${BUILD_ARGS}"
......@@ -119,10 +121,10 @@ rm -rf ${BINARIES_PATH}/${BUILD_CONFIGURATION}
BUILD_ARGS+=" /p:CscToolPath=${BOOTSTRAP_PATH}/csc /p:CscToolExe=csc /p:VbcToolPath=${BOOTSTRAP_PATH}/vbc /p:VbcToolExe=vbc"
echo "Building CrossPlatform.sln"
dotnet build ${THIS_DIR}/CrossPlatform.sln ${BUILD_ARGS}
dotnet build ${ROOT_PATH}/CrossPlatform.sln ${BUILD_ARGS}
if [[ "${SKIP_TESTS}" == false ]]
then
echo "Running tests"
${THIS_DIR}/build/scripts/tests.sh ${BUILD_CONFIGURATION}
${ROOT_PATH}/build/scripts/tests.sh ${BUILD_CONFIGURATION}
fi
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册