depot/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-check-hook.sh
Luke Granger-Brown 57725ef3ec Squashed 'third_party/nixpkgs/' content from commit 76612b17c0ce
git-subtree-dir: third_party/nixpkgs
git-subtree-split: 76612b17c0ce71689921ca12d9ffdc9c23ce40b2
2024-11-10 23:59:47 +00:00

81 lines
3 KiB
Bash

dotnetCheckHook() {
echo "Executing dotnetCheckHook"
runHook preCheck
local -r dotnetBuildType="${dotnetBuildType-Release}"
if [[ -n $__structuredAttrs ]]; then
local dotnetProjectFilesArray=( "${dotnetProjectFiles[@]}" )
local dotnetTestProjectFilesArray=( "${dotnetTestProjectFiles[@]}" )
local dotnetTestFlagsArray=( "${dotnetTestFlags[@]}" )
local dotnetTestFiltersArray=( "${dotnetTestFilters[@]}" )
local dotnetDisabledTestsArray=( "${dotnetDisabledTests[@]}" )
local dotnetRuntimeDepsArray=( "${dotnetRuntimeDeps[@]}" )
local dotnetRuntimeIdsArray=( "${dotnetRuntimeIds[@]}" )
else
local dotnetProjectFilesArray=($dotnetProjectFiles)
local dotnetTestProjectFilesArray=($dotnetTestProjectFiles)
local dotnetTestFlagsArray=($dotnetTestFlags)
local dotnetTestFiltersArray=($dotnetTestFilters)
local dotnetDisabledTestsArray=($dotnetDisabledTests)
local dotnetRuntimeDepsArray=($dotnetRuntimeDeps)
local dotnetRuntimeIdsArray=($dotnetRuntimeIds)
fi
if (( ${#dotnetDisabledTestsArray[@]} > 0 )); then
local disabledTestsFilters=("${dotnetDisabledTestsArray[@]/#/FullyQualifiedName!=}")
dotnetTestFiltersArray=( "${dotnetTestFiltersArray[@]}" "${disabledTestsFilters[@]//,/%2C}" )
fi
if (( ${#dotnetTestFiltersArray[@]} > 0 )); then
local OLDIFS="$IFS" IFS='&'
dotnetTestFlagsArray+=("--filter:${dotnetTestFiltersArray[*]}")
IFS="$OLDIFS"
fi
local libraryPath="${LD_LIBRARY_PATH-}"
if (( ${#dotnetRuntimeDepsArray[@]} > 0 )); then
local libraryPathArray=("${dotnetRuntimeDepsArray[@]/%//lib}")
local OLDIFS="$IFS" IFS=':'
libraryPath="${libraryPathArray[*]}${libraryPath:+':'}$libraryPath"
IFS="$OLDIFS"
fi
if [[ -n ${enableParallelBuilding-} ]]; then
local -r maxCpuFlag="$NIX_BUILD_CORES"
else
local -r maxCpuFlag="1"
fi
local projectFile runtimeId
for projectFile in "${dotnetTestProjectFilesArray[@]-${dotnetProjectFilesArray[@]}}"; do
for runtimeId in "${dotnetRuntimeIdsArray[@]}"; do
local runtimeIdFlagsArray=()
if [[ $projectFile == *.csproj ]]; then
runtimeIdFlagsArray=("--runtime" "$runtimeId")
fi
LD_LIBRARY_PATH=$libraryPath \
dotnet test "$projectFile" \
-maxcpucount:"$maxCpuFlag" \
-p:ContinuousIntegrationBuild=true \
-p:Deterministic=true \
--configuration "$dotnetBuildType" \
--no-restore \
--no-build \
--logger "console;verbosity=normal" \
"${runtimeIdFlagsArray[@]}" \
"${dotnetTestFlagsArray[@]}" \
"${dotnetFlagsArray[@]}"
done
done
runHook postCheck
echo "Finished dotnetCheckHook"
}
if [[ -z "${dontDotnetCheck-}" && -z "${checkPhase-}" ]]; then
checkPhase=dotnetCheckHook
fi