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