mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 16:33:15 +00:00
buildDotnetModule: add testFilters
arg (#336571)
This commit is contained in:
commit
7bc85af0c5
@ -118,6 +118,7 @@ For more detail about managing the `deps.nix` file, see [Generating and updating
|
|||||||
* `dotnet-sdk` is useful in cases where you need to change what dotnet SDK is being used. You can also set this to the result of `dotnetSdkPackages.combinePackages`, if the project uses multiple SDKs to build.
|
* `dotnet-sdk` is useful in cases where you need to change what dotnet SDK is being used. You can also set this to the result of `dotnetSdkPackages.combinePackages`, if the project uses multiple SDKs to build.
|
||||||
* `dotnet-runtime` is useful in cases where you need to change what dotnet runtime is being used. This can be either a regular dotnet runtime, or an aspnetcore.
|
* `dotnet-runtime` is useful in cases where you need to change what dotnet runtime is being used. This can be either a regular dotnet runtime, or an aspnetcore.
|
||||||
* `testProjectFile` is useful in cases where the regular project file does not contain the unit tests. It gets restored and build, but not installed. You may need to regenerate your nuget lockfile after setting this. Note that if set, only tests from this project are executed.
|
* `testProjectFile` is useful in cases where the regular project file does not contain the unit tests. It gets restored and build, but not installed. You may need to regenerate your nuget lockfile after setting this. Note that if set, only tests from this project are executed.
|
||||||
|
* `testFilters` is used to disable running unit tests based on various [filters](https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-test#filter-option-details). This gets passed as: `dotnet test --filter "{}"`, with each filter being concatenated using `"&"`.
|
||||||
* `disabledTests` is used to disable running specific unit tests. This gets passed as: `dotnet test --filter "FullyQualifiedName!={}"`, to ensure compatibility with all unit test frameworks.
|
* `disabledTests` is used to disable running specific unit tests. This gets passed as: `dotnet test --filter "FullyQualifiedName!={}"`, to ensure compatibility with all unit test frameworks.
|
||||||
* `dotnetRestoreFlags` can be used to pass flags to `dotnet restore`.
|
* `dotnetRestoreFlags` can be used to pass flags to `dotnet restore`.
|
||||||
* `dotnetBuildFlags` can be used to pass flags to `dotnet build`.
|
* `dotnetBuildFlags` can be used to pass flags to `dotnet build`.
|
||||||
|
@ -67,7 +67,12 @@ let
|
|||||||
# platforms in meta.platforms which are supported by the sdk.
|
# platforms in meta.platforms which are supported by the sdk.
|
||||||
runtimeId ? null,
|
runtimeId ? null,
|
||||||
|
|
||||||
|
# Test filters. This gets passed to `dotnet test --filter`, concatenated using `&`.
|
||||||
|
# You may also use `disabledTests` to filter tests based on their name.
|
||||||
|
# See https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-test#filter-option-details for more details.
|
||||||
|
testFilters ? [ ],
|
||||||
# Tests to disable. This gets passed to `dotnet test --filter "FullyQualifiedName!={}"`, to ensure compatibility with all frameworks.
|
# Tests to disable. This gets passed to `dotnet test --filter "FullyQualifiedName!={}"`, to ensure compatibility with all frameworks.
|
||||||
|
# You may also use `testFilters` to pass more generic filters to `dotnet test --filter`.
|
||||||
# See https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-test#filter-option-details for more details.
|
# See https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-test#filter-option-details for more details.
|
||||||
disabledTests ? [ ],
|
disabledTests ? [ ],
|
||||||
# The project file to run unit tests against. This is usually referenced in the regular project file, but sometimes it needs to be manually set.
|
# The project file to run unit tests against. This is usually referenced in the regular project file, but sometimes it needs to be manually set.
|
||||||
@ -132,6 +137,7 @@ let
|
|||||||
dotnetBuildType = buildType;
|
dotnetBuildType = buildType;
|
||||||
dotnetProjectFiles = projectFiles;
|
dotnetProjectFiles = projectFiles;
|
||||||
dotnetTestProjectFiles = testProjectFiles;
|
dotnetTestProjectFiles = testProjectFiles;
|
||||||
|
dotnetTestFilters = testFilters;
|
||||||
dotnetDisabledTests = disabledTests;
|
dotnetDisabledTests = disabledTests;
|
||||||
dotnetRuntimeIds = lib.singleton (
|
dotnetRuntimeIds = lib.singleton (
|
||||||
if runtimeId != null then runtimeId else systemToDotnetRid stdenvNoCC.hostPlatform.system
|
if runtimeId != null then runtimeId else systemToDotnetRid stdenvNoCC.hostPlatform.system
|
||||||
|
@ -9,6 +9,7 @@ dotnetCheckHook() {
|
|||||||
local dotnetProjectFilesArray=( "${dotnetProjectFiles[@]}" )
|
local dotnetProjectFilesArray=( "${dotnetProjectFiles[@]}" )
|
||||||
local dotnetTestProjectFilesArray=( "${dotnetTestProjectFiles[@]}" )
|
local dotnetTestProjectFilesArray=( "${dotnetTestProjectFiles[@]}" )
|
||||||
local dotnetTestFlagsArray=( "${dotnetTestFlags[@]}" )
|
local dotnetTestFlagsArray=( "${dotnetTestFlags[@]}" )
|
||||||
|
local dotnetTestFiltersArray=( "${dotnetTestFilters[@]}" )
|
||||||
local dotnetDisabledTestsArray=( "${dotnetDisabledTests[@]}" )
|
local dotnetDisabledTestsArray=( "${dotnetDisabledTests[@]}" )
|
||||||
local dotnetRuntimeDepsArray=( "${dotnetRuntimeDeps[@]}" )
|
local dotnetRuntimeDepsArray=( "${dotnetRuntimeDeps[@]}" )
|
||||||
local dotnetRuntimeIdsArray=( "${dotnetRuntimeIds[@]}" )
|
local dotnetRuntimeIdsArray=( "${dotnetRuntimeIds[@]}" )
|
||||||
@ -16,6 +17,7 @@ dotnetCheckHook() {
|
|||||||
local dotnetProjectFilesArray=($dotnetProjectFiles)
|
local dotnetProjectFilesArray=($dotnetProjectFiles)
|
||||||
local dotnetTestProjectFilesArray=($dotnetTestProjectFiles)
|
local dotnetTestProjectFilesArray=($dotnetTestProjectFiles)
|
||||||
local dotnetTestFlagsArray=($dotnetTestFlags)
|
local dotnetTestFlagsArray=($dotnetTestFlags)
|
||||||
|
local dotnetTestFiltersArray=($dotnetTestFilters)
|
||||||
local dotnetDisabledTestsArray=($dotnetDisabledTests)
|
local dotnetDisabledTestsArray=($dotnetDisabledTests)
|
||||||
local dotnetRuntimeDepsArray=($dotnetRuntimeDeps)
|
local dotnetRuntimeDepsArray=($dotnetRuntimeDeps)
|
||||||
local dotnetRuntimeIdsArray=($dotnetRuntimeIds)
|
local dotnetRuntimeIdsArray=($dotnetRuntimeIds)
|
||||||
@ -23,8 +25,12 @@ dotnetCheckHook() {
|
|||||||
|
|
||||||
if (( ${#dotnetDisabledTestsArray[@]} > 0 )); then
|
if (( ${#dotnetDisabledTestsArray[@]} > 0 )); then
|
||||||
local disabledTestsFilters=("${dotnetDisabledTestsArray[@]/#/FullyQualifiedName!=}")
|
local disabledTestsFilters=("${dotnetDisabledTestsArray[@]/#/FullyQualifiedName!=}")
|
||||||
|
dotnetTestFiltersArray=( "${dotnetTestFiltersArray[@]}" "${disabledTestsFilters[@]//,/%2C}" )
|
||||||
|
fi
|
||||||
|
|
||||||
|
if (( ${#dotnetTestFiltersArray[@]} > 0 )); then
|
||||||
local OLDIFS="$IFS" IFS='&'
|
local OLDIFS="$IFS" IFS='&'
|
||||||
dotnetTestFlagsArray+=("--filter:${disabledTestsFilters[*]//,/%2C}")
|
dotnetTestFlagsArray+=("--filter:${dotnetTestFiltersArray[*]}")
|
||||||
IFS="$OLDIFS"
|
IFS="$OLDIFS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -71,23 +71,21 @@ buildDotnetModule (finalAttrs: {
|
|||||||
|
|
||||||
doCheck = true;
|
doCheck = true;
|
||||||
|
|
||||||
dotnetTestFlags = [
|
dotnetTestFlags = [ "--environment=USER=nobody" ];
|
||||||
"--environment=USER=nobody"
|
|
||||||
(
|
testFilters = [
|
||||||
"--filter="
|
|
||||||
+ lib.strings.concatStringsSep "&" (
|
|
||||||
[
|
|
||||||
"Category!=Disabled"
|
"Category!=Disabled"
|
||||||
"FlakeyTest!=True"
|
"FlakeyTest!=True"
|
||||||
"RequiresNetworking!=True"
|
"RequiresNetworking!=True"
|
||||||
"FullyQualifiedName!=NexusMods.UI.Tests.ImageCacheTests.Test_LoadAndCache_RemoteImage"
|
];
|
||||||
"FullyQualifiedName!=NexusMods.UI.Tests.ImageCacheTests.Test_LoadAndCache_ImageStoredFile"
|
|
||||||
|
disabledTests =
|
||||||
|
[
|
||||||
|
"NexusMods.UI.Tests.ImageCacheTests.Test_LoadAndCache_RemoteImage"
|
||||||
|
"NexusMods.UI.Tests.ImageCacheTests.Test_LoadAndCache_ImageStoredFile"
|
||||||
]
|
]
|
||||||
++ lib.optionals (!_7zz.meta.unfree) [
|
++ lib.optionals (!_7zz.meta.unfree) [
|
||||||
"FullyQualifiedName!=NexusMods.Games.FOMOD.Tests.FomodXmlInstallerTests.InstallsFilesSimple_UsingRar"
|
"NexusMods.Games.FOMOD.Tests.FomodXmlInstallerTests.InstallsFilesSimple_UsingRar"
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
];
|
];
|
||||||
|
|
||||||
passthru = {
|
passthru = {
|
||||||
|
Loading…
Reference in New Issue
Block a user