about summary refs log tree commit diff
path: root/nixpkgs/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-check-hook.sh
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2024-06-23 00:32:22 +0200
committerAlyssa Ross <hi@alyssa.is>2024-06-23 00:32:22 +0200
commit6402b188ddd100b3cd6afe7b8a3e553365203f43 (patch)
tree676b85e4a6ffee092e413e723f7dce8ba01bb48f /nixpkgs/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-check-hook.sh
parent5a1826585861b32ce2509c0643e793196d81893e (diff)
parentd603719ec6e294f034936c0d0dc06f689d91b6c3 (diff)
downloadnixlib-6402b188ddd100b3cd6afe7b8a3e553365203f43.tar
nixlib-6402b188ddd100b3cd6afe7b8a3e553365203f43.tar.gz
nixlib-6402b188ddd100b3cd6afe7b8a3e553365203f43.tar.bz2
nixlib-6402b188ddd100b3cd6afe7b8a3e553365203f43.tar.lz
nixlib-6402b188ddd100b3cd6afe7b8a3e553365203f43.tar.xz
nixlib-6402b188ddd100b3cd6afe7b8a3e553365203f43.tar.zst
nixlib-6402b188ddd100b3cd6afe7b8a3e553365203f43.zip
Merge remote-tracking branch 'nixpkgs/nixos-unstable'
Diffstat (limited to 'nixpkgs/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-check-hook.sh')
-rw-r--r--nixpkgs/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-check-hook.sh62
1 files changed, 44 insertions, 18 deletions
diff --git a/nixpkgs/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-check-hook.sh b/nixpkgs/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-check-hook.sh
index 507721ef9818..c91251f4f180 100644
--- a/nixpkgs/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-check-hook.sh
+++ b/nixpkgs/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-check-hook.sh
@@ -1,39 +1,65 @@
-# inherit arguments from derivation
-dotnetTestFlags=( ${dotnetTestFlags[@]-} )
-
 dotnetCheckHook() {
     echo "Executing dotnetCheckHook"
 
     runHook preCheck
 
-    if [ "${disabledTests-}" ]; then
-        local -r disabledTestsFlag="--filter @disabledTests@"
+    local -r hostRuntimeId=@runtimeId@
+    local -r dotnetBuildType="${dotnetBuildType-Release}"
+    local -r dotnetRuntimeId="${dotnetRuntimeId-$hostRuntimeId}"
+
+    if [[ -n $__structuredAttrs ]]; then
+        local dotnetProjectFilesArray=( "${dotnetProjectFiles[@]}" )
+        local dotnetTestProjectFilesArray=( "${dotnetTestProjectFiles[@]}" )
+        local dotnetTestFlagsArray=( "${dotnetTestFlags[@]}" )
+        local dotnetDisabledTestsArray=( "${dotnetDisabledTests[@]}" )
+        local dotnetRuntimeDepsArray=( "${dotnetRuntimeDeps[@]}" )
+    else
+        local dotnetProjectFilesArray=($dotnetProjectFiles)
+        local dotnetTestProjectFilesArray=($dotnetTestProjectFiles)
+        local dotnetTestFlagsArray=($dotnetTestFlags)
+        local dotnetDisabledTestsArray=($dotnetDisabledTests)
+        local dotnetRuntimeDepsArray=($dotnetRuntimeDeps)
+    fi
+
+    if (( ${#dotnetDisabledTestsArray[@]} > 0 )); then
+        local disabledTestsFilters=("${dotnetDisabledTestsArray[@]/#/FullyQualifiedName!=}")
+        local OLDIFS="$IFS" IFS='&'
+        dotnetTestFlagsArray+=("--filter:${disabledTestsFilters[*]//,/%2C}")
+        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 [ "${enableParallelBuilding-}" ]; then
+    if [[ -n ${enableParallelBuilding-} ]]; then
         local -r maxCpuFlag="$NIX_BUILD_CORES"
     else
         local -r maxCpuFlag="1"
     fi
 
-    for project in ${testProjectFile[@]-${projectFile[@]}}; do
-        runtimeIdFlags=()
-        if [[ "$project" == *.csproj ]]; then
-            runtimeIdFlags=("--runtime @runtimeId@")
+    local projectFile
+    for projectFile in "${dotnetTestProjectFilesArray[@]-${dotnetProjectFilesArray[@]}}"; do
+        local runtimeIdFlagsArray=()
+        if [[ $projectFile == *.csproj ]]; then
+            runtimeIdFlagsArray=("--runtime" "$dotnetRuntimeId")
         fi
 
-        env "LD_LIBRARY_PATH=@libraryPath@" \
-            dotnet test "$project" \
-              -maxcpucount:$maxCpuFlag \
+        LD_LIBRARY_PATH=$libraryPath \
+            dotnet test "$projectFile" \
+              -maxcpucount:"$maxCpuFlag" \
               -p:ContinuousIntegrationBuild=true \
               -p:Deterministic=true \
-              --configuration "@buildType@" \
+              --configuration "$dotnetBuildType" \
               --no-build \
               --logger "console;verbosity=normal" \
-              ${disabledTestsFlag-} \
-              ${runtimeIdFlags[@]} \
-              "${dotnetTestFlags[@]}"  \
-              "${dotnetFlags[@]}"
+              "${runtimeIdFlagsArray[@]}" \
+              "${dotnetTestFlagsArray[@]}" \
+              "${dotnetFlagsArray[@]}"
     done
 
     runHook postCheck