diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 1bfe045df..41127ae43 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -247,7 +247,30 @@ jobs: strategy: fail-fast: false matrix: - group: [dsc, adapters, extensions, resources] + include: + - name: dsc-expressions + group: dsc/tests/expressions + - name: dsc-functions + group: dsc/tests/functions + - name: dsc-discovery + group: dsc/tests/discovery + - name: dsc-config + group: dsc/tests/config + - name: dsc-other + group: dsc/tests/other + - name: adapters + group: adapters + - name: extensions + group: extensions + - name: resources + group: resources + exclude: '*dism_dsc*' + - name: dism-windows-feature + group: resources/dism_dsc/tests/WindowsFeature + - name: dism-optional-feature + group: resources/dism_dsc/tests/OptionalFeature + - name: dism-feature-on-demand + group: resources/dism_dsc/tests/FeatureOnDemand runs-on: windows-latest steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -266,7 +289,7 @@ jobs: $profPattern = Join-Path $profDir.FullName '%m_%p.profraw' "LLVM_PROFILE_FILE=$profPattern" | Out-File -Append -Encoding utf8 -FilePath $env:GITHUB_ENV "prof_dir=$($profDir.FullName)" | Out-File -Append -Encoding utf8 -FilePath $env:GITHUB_OUTPUT - - name: Test ${{matrix.group}} + - name: Test ${{matrix.name}} run: |- $params = @{ SkipBuild = $true @@ -274,6 +297,9 @@ jobs: ExcludeRustTests = $true Verbose = $true } + if ('${{matrix.exclude}}') { + $params.PesterExcludePath = '${{matrix.exclude}}' + } ./build.ps1 @params -PesterTestGroup ${{matrix.group}} - name: Generate coverage report if: always() @@ -299,7 +325,7 @@ jobs: if: always() uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: - name: windows-pester-${{matrix.group}}-coverage + name: windows-pester-${{matrix.name}}-coverage path: pester-lcov.info if-no-files-found: ignore diff --git a/build.ps1 b/build.ps1 index 2ee850d14..37c3f07d5 100755 --- a/build.ps1 +++ b/build.ps1 @@ -141,8 +141,8 @@ param( [switch]$ExcludeRustTests, [string]$RustTestFilter, [switch]$ExcludePesterTests, - [ValidateSet("dsc", "adapters", "extensions", "grammars", "resources")] [string[]]$PesterTestGroup, + [string[]]$PesterExcludePath, [switch]$GetPackageVersion, [switch]$SkipLinkCheck, [switch]$UseX64MakeAppx, @@ -379,6 +379,9 @@ process { if ($null -ne $PesterTestGroup) { $pesterParams.Group = $PesterTestGroup } + if ($null -ne $PesterExcludePath) { + $pesterParams.ExcludePath = $PesterExcludePath + } Write-BuildProgress @progressParams -Status "Installing PowerShell test prerequisites" Install-PowerShellTestPrerequisite @installParams @VerboseParam Write-BuildProgress @progressParams -Status "Invoking pester" diff --git a/dsc/tests/dsc_args.tests.ps1 b/dsc/tests/config/dsc_args.tests.ps1 similarity index 98% rename from dsc/tests/dsc_args.tests.ps1 rename to dsc/tests/config/dsc_args.tests.ps1 index fecfc8f02..fb4f6df26 100644 --- a/dsc/tests/dsc_args.tests.ps1 +++ b/dsc/tests/config/dsc_args.tests.ps1 @@ -254,7 +254,7 @@ resources: } It 'passing filepath to document arg should error' { - $configFile = Resolve-Path $PSScriptRoot/../examples/osinfo.dsc.json + $configFile = Resolve-Path $PSScriptRoot/../../examples/osinfo.dsc.json $stderr = dsc config get -i $configFile 2>&1 $stderr | Should -Match '.*?--file.*?' } @@ -312,7 +312,7 @@ resources: } It 'Invalid --system-root' { - dsc config --system-root /invalid/path get -f "$PSScriptRoot/../examples/groups.dsc.yaml" 2> $TestDrive/tracing.txt + dsc config --system-root /invalid/path get -f "$PSScriptRoot/../../examples/groups.dsc.yaml" 2> $TestDrive/tracing.txt $LASTEXITCODE | Should -Be 1 "$TestDrive/tracing.txt" | Should -FileContentMatchExactly "Target path does not exist: '/invalid/path'" } diff --git a/dsc/tests/dsc_assertion.tests.ps1 b/dsc/tests/config/dsc_assertion.tests.ps1 similarity index 89% rename from dsc/tests/dsc_assertion.tests.ps1 rename to dsc/tests/config/dsc_assertion.tests.ps1 index 0e13b6de5..316468984 100644 --- a/dsc/tests/dsc_assertion.tests.ps1 +++ b/dsc/tests/config/dsc_assertion.tests.ps1 @@ -10,7 +10,7 @@ Describe 'Assertion resource tests' -Skip:(!$IsWindows) { # @{ operation = 'export' } ) { param($operation) - $jsonPath = Join-Path $PSScriptRoot '../examples/assertion.dsc.yaml' + $jsonPath = Join-Path $PSScriptRoot '../../examples/assertion.dsc.yaml' $out = dsc config $operation -f $jsonPath 2> "$TestDrive/trace.log" $LASTEXITCODE | Should -Be 2 $out | Should -BeNullOrEmpty diff --git a/dsc/tests/dsc_config_export.tests.ps1 b/dsc/tests/config/dsc_config_export.tests.ps1 similarity index 100% rename from dsc/tests/dsc_config_export.tests.ps1 rename to dsc/tests/config/dsc_config_export.tests.ps1 diff --git a/dsc/tests/dsc_config_get.tests.ps1 b/dsc/tests/config/dsc_config_get.tests.ps1 similarity index 98% rename from dsc/tests/dsc_config_get.tests.ps1 rename to dsc/tests/config/dsc_config_get.tests.ps1 index cfc297c7c..8ddc71d33 100644 --- a/dsc/tests/dsc_config_get.tests.ps1 +++ b/dsc/tests/config/dsc_config_get.tests.ps1 @@ -7,7 +7,7 @@ Describe 'dsc config get tests' { @{ config = 'osinfo_registry.dsc.yaml' } ) { param($config) - $jsonPath = Join-Path $PSScriptRoot '../examples' $config + $jsonPath = Join-Path $PSScriptRoot '../../examples' $config $config = Get-Content $jsonPath -Raw $out = $config | dsc config get -f - | ConvertFrom-Json $LASTEXITCODE | Should -Be 0 @@ -25,7 +25,7 @@ Describe 'dsc config get tests' { } It 'will fail if resource schema does not match' -Skip:(!$IsWindows) { - $jsonPath = Join-Path $PSScriptRoot '../examples/invalid_schema.dsc.yaml' + $jsonPath = Join-Path $PSScriptRoot '../../examples/invalid_schema.dsc.yaml' $testError = & {dsc config get -f $jsonPath 2>&1} $testError[0] | Should -match 'Schema:' $LASTEXITCODE | Should -Be 2 diff --git a/dsc/tests/dsc_config_set.tests.ps1 b/dsc/tests/config/dsc_config_set.tests.ps1 similarity index 100% rename from dsc/tests/dsc_config_set.tests.ps1 rename to dsc/tests/config/dsc_config_set.tests.ps1 diff --git a/dsc/tests/dsc_config_test.tests.ps1 b/dsc/tests/config/dsc_config_test.tests.ps1 similarity index 100% rename from dsc/tests/dsc_config_test.tests.ps1 rename to dsc/tests/config/dsc_config_test.tests.ps1 diff --git a/dsc/tests/dsc_config_version.tests.ps1 b/dsc/tests/config/dsc_config_version.tests.ps1 similarity index 100% rename from dsc/tests/dsc_config_version.tests.ps1 rename to dsc/tests/config/dsc_config_version.tests.ps1 diff --git a/dsc/tests/dsc_copy.tests.ps1 b/dsc/tests/config/dsc_copy.tests.ps1 similarity index 100% rename from dsc/tests/dsc_copy.tests.ps1 rename to dsc/tests/config/dsc_copy.tests.ps1 diff --git a/dsc/tests/dsc_export.tests.ps1 b/dsc/tests/config/dsc_export.tests.ps1 similarity index 100% rename from dsc/tests/dsc_export.tests.ps1 rename to dsc/tests/config/dsc_export.tests.ps1 diff --git a/dsc/tests/dsc_group.tests.ps1 b/dsc/tests/config/dsc_group.tests.ps1 similarity index 94% rename from dsc/tests/dsc_group.tests.ps1 rename to dsc/tests/config/dsc_group.tests.ps1 index 0700954c1..8308d0ecd 100644 --- a/dsc/tests/dsc_group.tests.ps1 +++ b/dsc/tests/config/dsc_group.tests.ps1 @@ -3,7 +3,7 @@ Describe 'Group resource tests' { It 'Nested groups should work for get' { - $out = (dsc config get -f $PSScriptRoot/../examples/groups.dsc.yaml -o yaml | Out-String).Trim() + $out = (dsc config get -f $PSScriptRoot/../../examples/groups.dsc.yaml -o yaml | Out-String).Trim() $LASTEXITCODE | Should -Be 0 $out | Should -BeLike @' executionInformation: diff --git a/dsc/tests/dsc_include.tests.ps1 b/dsc/tests/config/dsc_include.tests.ps1 similarity index 96% rename from dsc/tests/dsc_include.tests.ps1 rename to dsc/tests/config/dsc_include.tests.ps1 index b1b7a0b81..88ce8231e 100644 --- a/dsc/tests/dsc_include.tests.ps1 +++ b/dsc/tests/config/dsc_include.tests.ps1 @@ -4,9 +4,9 @@ Describe 'Include tests' { BeforeAll { $includePath = New-Item -ItemType Directory -Path (Join-Path $TestDrive 'include') - Copy-Item (Join-Path $PSScriptRoot '../examples/osinfo_parameters.dsc.yaml') -Destination $includePath + Copy-Item (Join-Path $PSScriptRoot '../../examples/osinfo_parameters.dsc.yaml') -Destination $includePath $osinfoConfigPath = Get-Item (Join-Path $includePath 'osinfo_parameters.dsc.yaml') - Copy-Item (Join-Path $PSScriptRoot '../examples/osinfo.parameters.yaml') -Destination $includePath + Copy-Item (Join-Path $PSScriptRoot '../../examples/osinfo.parameters.yaml') -Destination $includePath $osinfoParametersConfigPath = Get-Item (Join-Path $includePath 'osinfo.parameters.yaml') $logPath = Join-Path $TestDrive 'stderr.log' @@ -91,7 +91,7 @@ Describe 'Include tests' { } It 'Include config JSON content with default parameters' { - $osinfoJsonPath = Join-Path $PSScriptRoot '../examples/osinfo_parameters.dsc.json' + $osinfoJsonPath = Join-Path $PSScriptRoot '../../examples/osinfo_parameters.dsc.json' # for JSON, we can just have it as a single line $includeContent = (Get-Content $osinfoJsonPath -Raw).Replace("`n", "").Replace('"', '\"') @@ -144,7 +144,7 @@ Describe 'Include tests' { } It 'Include config with parameters content' { - $parametersContentFile = Join-Path $PSScriptRoot '../examples/osinfo.parameters.json' + $parametersContentFile = Join-Path $PSScriptRoot '../../examples/osinfo.parameters.json' $parametersContent = (Get-Content $parametersContentFile -Raw).Replace("`n", "").Replace('"', '\"') $config = @" @@ -321,7 +321,7 @@ resources: } It 'Test with include works' { - $includeYaml = Join-Path $PSScriptRoot ../../dsc/examples/include.dsc.yaml + $includeYaml = Join-Path $PSScriptRoot ../../../dsc/examples/include.dsc.yaml $out = dsc config test -f $includeYaml | ConvertFrom-Json $LASTEXITCODE | Should -Be 0 $out.results[0].type | Should -BeExactly 'Microsoft.DSC/Include' diff --git a/dsc/tests/dsc_lambda.tests.ps1 b/dsc/tests/config/dsc_lambda.tests.ps1 similarity index 100% rename from dsc/tests/dsc_lambda.tests.ps1 rename to dsc/tests/config/dsc_lambda.tests.ps1 diff --git a/dsc/tests/dsc_metadata.tests.ps1 b/dsc/tests/config/dsc_metadata.tests.ps1 similarity index 100% rename from dsc/tests/dsc_metadata.tests.ps1 rename to dsc/tests/config/dsc_metadata.tests.ps1 diff --git a/dsc/tests/dsc_parameters.tests.ps1 b/dsc/tests/config/dsc_parameters.tests.ps1 similarity index 98% rename from dsc/tests/dsc_parameters.tests.ps1 rename to dsc/tests/config/dsc_parameters.tests.ps1 index 183e520a6..610deee09 100644 --- a/dsc/tests/dsc_parameters.tests.ps1 +++ b/dsc/tests/config/dsc_parameters.tests.ps1 @@ -284,7 +284,7 @@ Describe 'Parameters tests' { ) { param($operation, $property) - $out = dsc -l trace config -f $PSScriptRoot/../examples/secure_parameters.parameters.yaml $operation -f $PSScriptRoot/../examples/secure_parameters.dsc.yaml 2> $TestDrive/error.log | ConvertFrom-Json + $out = dsc -l trace config -f $PSScriptRoot/../../examples/secure_parameters.parameters.yaml $operation -f $PSScriptRoot/../../examples/secure_parameters.dsc.yaml 2> $TestDrive/error.log | ConvertFrom-Json $LASTEXITCODE | Should -Be 0 if ($operation -eq 'export') { $out.resources.Count | Should -Be 5 @@ -314,7 +314,7 @@ Describe 'Parameters tests' { ) { param($operation, $property) - $out = dsc config -f $PSScriptRoot/../examples/secure_parameters_shown.parameters.yaml $operation -f $PSScriptRoot/../examples/secure_parameters.dsc.yaml | ConvertFrom-Json + $out = dsc config -f $PSScriptRoot/../../examples/secure_parameters_shown.parameters.yaml $operation -f $PSScriptRoot/../../examples/secure_parameters.dsc.yaml | ConvertFrom-Json $LASTEXITCODE | Should -Be 0 if ($operation -eq 'export') { $out.resources.Count | Should -Be 5 -Because ($out | ConvertTo-Json -Dep 10 | Out-String) @@ -380,7 +380,7 @@ Describe 'Parameters tests' { } } | ConvertTo-Json -Compress - $out = $params | dsc config -f - test -f "$PSScriptRoot/../examples/osinfo_parameters.dsc.yaml" 2> $TestDrive/error.log | ConvertFrom-Json + $out = $params | dsc config -f - test -f "$PSScriptRoot/../../examples/osinfo_parameters.dsc.yaml" 2> $TestDrive/error.log | ConvertFrom-Json $LASTEXITCODE | Should -Be 0 -Because (Get-Content -Path $TestDrive/error.log | Out-String) $out.results[0].result.desiredState.family | Should -BeExactly 'Windows' $out.results[0].result.inDesiredState | Should -Be $IsWindows @@ -464,7 +464,7 @@ Describe 'Parameters tests' { osFamily = 'Windows' } | ConvertTo-Json -Compress - $out = $params | dsc config -f - test -f "$PSScriptRoot/../examples/osinfo_parameters.dsc.yaml" 2> $TestDrive/error.log + $out = $params | dsc config -f - test -f "$PSScriptRoot/../../examples/osinfo_parameters.dsc.yaml" 2> $TestDrive/error.log $LASTEXITCODE | Should -Be 4 $out | Should -BeNullOrEmpty $errorMessage = Get-Content -Path $TestDrive/error.log -Raw diff --git a/dsc/tests/dsc_reference.tests.ps1 b/dsc/tests/config/dsc_reference.tests.ps1 similarity index 84% rename from dsc/tests/dsc_reference.tests.ps1 rename to dsc/tests/config/dsc_reference.tests.ps1 index 6e7e83e91..2c3e60dfa 100644 --- a/dsc/tests/dsc_reference.tests.ps1 +++ b/dsc/tests/config/dsc_reference.tests.ps1 @@ -8,7 +8,7 @@ Describe 'Tests for config using reference function' { ) { param($operation) - $out = dsc config $operation -f $PSScriptRoot/../examples/reference.dsc.yaml | ConvertFrom-Json + $out = dsc config $operation -f $PSScriptRoot/../../examples/reference.dsc.yaml | ConvertFrom-Json $LASTEXITCODE | Should -Be 0 $os = if ($IsWindows) { 'Windows' diff --git a/dsc/tests/dsc_restartRequired.tests.ps1 b/dsc/tests/config/dsc_restartRequired.tests.ps1 similarity index 100% rename from dsc/tests/dsc_restartRequired.tests.ps1 rename to dsc/tests/config/dsc_restartRequired.tests.ps1 diff --git a/dsc/tests/dsc_schema_default.tests.ps1 b/dsc/tests/config/dsc_schema_default.tests.ps1 similarity index 100% rename from dsc/tests/dsc_schema_default.tests.ps1 rename to dsc/tests/config/dsc_schema_default.tests.ps1 diff --git a/dsc/tests/dsc_set.tests.ps1 b/dsc/tests/config/dsc_set.tests.ps1 similarity index 100% rename from dsc/tests/dsc_set.tests.ps1 rename to dsc/tests/config/dsc_set.tests.ps1 diff --git a/dsc/tests/dsc_test.tests.ps1 b/dsc/tests/config/dsc_test.tests.ps1 similarity index 100% rename from dsc/tests/dsc_test.tests.ps1 rename to dsc/tests/config/dsc_test.tests.ps1 diff --git a/dsc/tests/dsc_variables.tests.ps1 b/dsc/tests/config/dsc_variables.tests.ps1 similarity index 95% rename from dsc/tests/dsc_variables.tests.ps1 rename to dsc/tests/config/dsc_variables.tests.ps1 index de0d44a18..048d062d8 100644 --- a/dsc/tests/dsc_variables.tests.ps1 +++ b/dsc/tests/config/dsc_variables.tests.ps1 @@ -3,7 +3,7 @@ Describe 'Configruation variables tests' { It 'Variables example config works' { - $configFile = "$PSSCriptRoot/../examples/variables.dsc.yaml" + $configFile = "$PSScriptRoot/../../examples/variables.dsc.yaml" $out = dsc config get -f $configFile | ConvertFrom-Json $LASTEXITCODE | Should -Be 0 $out.results[0].result.actualState.output | Should -BeExactly 'myOutput is: Hello world!, myObject is: baz' diff --git a/dsc/tests/dsc_whatif.tests.ps1 b/dsc/tests/config/dsc_whatif.tests.ps1 similarity index 99% rename from dsc/tests/dsc_whatif.tests.ps1 rename to dsc/tests/config/dsc_whatif.tests.ps1 index 19b20b96d..3e5e76036 100644 --- a/dsc/tests/dsc_whatif.tests.ps1 +++ b/dsc/tests/config/dsc_whatif.tests.ps1 @@ -52,7 +52,7 @@ Describe 'whatif tests' { } It 'config set whatif for group resource' { - $result = dsc config set -f $PSScriptRoot/../examples/groups.dsc.yaml -w 2>&1 + $result = dsc config set -f $PSScriptRoot/../../examples/groups.dsc.yaml -w 2>&1 $LASTEXITCODE | Should -Be 2 $result | Should -Match 'ERROR.*?Not implemented.*?what-if' } diff --git a/dsc/tests/dsc_adaptedResource.tests.ps1 b/dsc/tests/discovery/dsc_adaptedResource.tests.ps1 similarity index 100% rename from dsc/tests/dsc_adaptedResource.tests.ps1 rename to dsc/tests/discovery/dsc_adaptedResource.tests.ps1 diff --git a/dsc/tests/dsc_adapter.tests.ps1 b/dsc/tests/discovery/dsc_adapter.tests.ps1 similarity index 99% rename from dsc/tests/dsc_adapter.tests.ps1 rename to dsc/tests/discovery/dsc_adapter.tests.ps1 index 31bc09541..694cff549 100644 --- a/dsc/tests/dsc_adapter.tests.ps1 +++ b/dsc/tests/discovery/dsc_adapter.tests.ps1 @@ -5,7 +5,7 @@ Describe 'Tests for adapter support' { Context 'Adapter support single resource' { BeforeAll { $OldPSModulePath = $env:PSModulePath - $env:PSModulePath += [System.IO.Path]::PathSeparator + (Resolve-Path "$PSScriptRoot/../../adapters/powershell/Tests") + $env:PSModulePath += [System.IO.Path]::PathSeparator + (Resolve-Path "$PSScriptRoot/../../../adapters/powershell/Tests") } AfterAll { diff --git a/dsc/tests/dsc_discovery.tests.ps1 b/dsc/tests/discovery/dsc_discovery.tests.ps1 similarity index 99% rename from dsc/tests/dsc_discovery.tests.ps1 rename to dsc/tests/discovery/dsc_discovery.tests.ps1 index e7a6207cd..029d69e0a 100644 --- a/dsc/tests/dsc_discovery.tests.ps1 +++ b/dsc/tests/discovery/dsc_discovery.tests.ps1 @@ -115,7 +115,7 @@ Describe 'tests for resource discovery' { # perform List on an adapter - this should create adapter lookup table file $oldPSModulePath = $env:PSModulePath - $TestClassResourcePath = Resolve-Path "$PSScriptRoot/../../adapters/powershell/Tests" + $TestClassResourcePath = Resolve-Path "$PSScriptRoot/../../../adapters/powershell/Tests" $env:DSC_RESTRICTED_PATH = $null $env:PSModulePath += [System.IO.Path]::PathSeparator + $TestClassResourcePath dsc resource list -a Microsoft.DSC/PowerShell | Out-Null @@ -132,7 +132,7 @@ Describe 'tests for resource discovery' { # perform Get on an adapter - this should create adapter lookup table file $oldPSModulePath = $env:PSModulePath - $TestClassResourcePath = Resolve-Path "$PSScriptRoot/../../adapters/powershell/Tests" + $TestClassResourcePath = Resolve-Path "$PSScriptRoot/../../../adapters/powershell/Tests" $env:DSC_RESTRICTED_PATH = $null $env:PSModulePath += [System.IO.Path]::PathSeparator + $TestClassResourcePath "{'Name':'TestClassResource1'}" | dsc resource get -r 'TestClassResource/TestClassResource' -f - | Out-Null @@ -145,7 +145,7 @@ Describe 'tests for resource discovery' { It 'Verify adapter lookup table is used on repeat invocations' { $oldPSModulePath = $env:PSModulePath - $TestClassResourcePath = Resolve-Path "$PSScriptRoot/../../adapters/powershell/Tests" + $TestClassResourcePath = Resolve-Path "$PSScriptRoot/../../../adapters/powershell/Tests" $env:DSC_RESTRICTED_PATH = $null $env:PSModulePath += [System.IO.Path]::PathSeparator + $TestClassResourcePath diff --git a/dsc/tests/dsc_extension_discover.tests.ps1 b/dsc/tests/discovery/dsc_extension_discover.tests.ps1 similarity index 99% rename from dsc/tests/dsc_extension_discover.tests.ps1 rename to dsc/tests/discovery/dsc_extension_discover.tests.ps1 index ad006a553..19bfaea69 100644 --- a/dsc/tests/dsc_extension_discover.tests.ps1 +++ b/dsc/tests/discovery/dsc_extension_discover.tests.ps1 @@ -12,7 +12,7 @@ BeforeDiscovery { Describe 'Discover extension tests' { BeforeAll { $oldPath = $env:PATH - $toolPath = Resolve-Path -Path "$PSScriptRoot/../../extensions/test/discover" + $toolPath = Resolve-Path -Path "$PSScriptRoot/../../../extensions/test/discover" $env:PATH = "$toolPath" + [System.IO.Path]::PathSeparator + $oldPath } diff --git a/dsc/tests/dsc_extension_import.tests.ps1 b/dsc/tests/discovery/dsc_extension_import.tests.ps1 similarity index 100% rename from dsc/tests/dsc_extension_import.tests.ps1 rename to dsc/tests/discovery/dsc_extension_import.tests.ps1 diff --git a/dsc/tests/dsc_extension_manifest.tests.ps1 b/dsc/tests/discovery/dsc_extension_manifest.tests.ps1 similarity index 100% rename from dsc/tests/dsc_extension_manifest.tests.ps1 rename to dsc/tests/discovery/dsc_extension_manifest.tests.ps1 diff --git a/dsc/tests/dsc_extension_secret.tests.ps1 b/dsc/tests/discovery/dsc_extension_secret.tests.ps1 similarity index 99% rename from dsc/tests/dsc_extension_secret.tests.ps1 rename to dsc/tests/discovery/dsc_extension_secret.tests.ps1 index 6a6bca168..59f300de5 100644 --- a/dsc/tests/dsc_extension_secret.tests.ps1 +++ b/dsc/tests/discovery/dsc_extension_secret.tests.ps1 @@ -4,7 +4,7 @@ Describe 'Tests for the secret() function and extensions' { BeforeAll { $oldPath = $env:PATH - $toolPath = Resolve-Path -Path "$PSScriptRoot/../../extensions/test/secret" + $toolPath = Resolve-Path -Path "$PSScriptRoot/../../../extensions/test/secret" $env:PATH = "$toolPath" + [System.IO.Path]::PathSeparator + $oldPath } diff --git a/dsc/tests/dsc_i18n.tests.ps1 b/dsc/tests/discovery/dsc_i18n.tests.ps1 similarity index 99% rename from dsc/tests/dsc_i18n.tests.ps1 rename to dsc/tests/discovery/dsc_i18n.tests.ps1 index a70c7c8d8..57cc8215b 100644 --- a/dsc/tests/dsc_i18n.tests.ps1 +++ b/dsc/tests/discovery/dsc_i18n.tests.ps1 @@ -200,7 +200,7 @@ BeforeDiscovery { 'y2j' ) $localeFolders = $rootFolders | ForEach-Object -Process { - Get-ChildItem $PSScriptRoot/../../$_/locales -Recurse -Directory + Get-ChildItem $PSScriptRoot/../../../$_/locales -Recurse -Directory } $projects = @() diff --git a/dsc/tests/dsc_resource_deprecated.tests.ps1 b/dsc/tests/discovery/dsc_resource_deprecated.tests.ps1 similarity index 100% rename from dsc/tests/dsc_resource_deprecated.tests.ps1 rename to dsc/tests/discovery/dsc_resource_deprecated.tests.ps1 diff --git a/dsc/tests/dsc_resource_list.tests.ps1 b/dsc/tests/discovery/dsc_resource_list.tests.ps1 similarity index 100% rename from dsc/tests/dsc_resource_list.tests.ps1 rename to dsc/tests/discovery/dsc_resource_list.tests.ps1 diff --git a/dsc/tests/dsc_resource_manifest.tests.ps1 b/dsc/tests/discovery/dsc_resource_manifest.tests.ps1 similarity index 100% rename from dsc/tests/dsc_resource_manifest.tests.ps1 rename to dsc/tests/discovery/dsc_resource_manifest.tests.ps1 diff --git a/dsc/tests/dsc_expressions.tests.ps1 b/dsc/tests/expressions/dsc_expressions.tests.ps1 similarity index 99% rename from dsc/tests/dsc_expressions.tests.ps1 rename to dsc/tests/expressions/dsc_expressions.tests.ps1 index 51d1d417c..3bbc97e67 100644 --- a/dsc/tests/dsc_expressions.tests.ps1 +++ b/dsc/tests/expressions/dsc_expressions.tests.ps1 @@ -77,7 +77,7 @@ Describe 'Expressions tests' { } It 'Multi-line string literals work' { - $yamlPath = "$PSScriptRoot/../examples/multiline.dsc.yaml" + $yamlPath = "$PSScriptRoot/../../examples/multiline.dsc.yaml" $out = dsc config get -f $yamlPath | ConvertFrom-Json $LASTEXITCODE | Should -Be 0 $out.results[0].result.actualState.output | Should -BeExactly @" diff --git a/dsc/tests/dsc_function_list.tests.ps1 b/dsc/tests/expressions/dsc_function_list.tests.ps1 similarity index 100% rename from dsc/tests/dsc_function_list.tests.ps1 rename to dsc/tests/expressions/dsc_function_list.tests.ps1 diff --git a/dsc/tests/dsc_user_functions.tests.ps1 b/dsc/tests/expressions/dsc_user_functions.tests.ps1 similarity index 100% rename from dsc/tests/dsc_user_functions.tests.ps1 rename to dsc/tests/expressions/dsc_user_functions.tests.ps1 diff --git a/dsc/tests/dsc_functions.tests.ps1 b/dsc/tests/functions/dsc_functions.tests.ps1 similarity index 100% rename from dsc/tests/dsc_functions.tests.ps1 rename to dsc/tests/functions/dsc_functions.tests.ps1 diff --git a/dsc/tests/dsc.exist.tests.ps1 b/dsc/tests/other/dsc.exist.tests.ps1 similarity index 100% rename from dsc/tests/dsc.exist.tests.ps1 rename to dsc/tests/other/dsc.exist.tests.ps1 diff --git a/dsc/tests/dsc.exit_code.tests.ps1 b/dsc/tests/other/dsc.exit_code.tests.ps1 similarity index 100% rename from dsc/tests/dsc.exit_code.tests.ps1 rename to dsc/tests/other/dsc.exit_code.tests.ps1 diff --git a/dsc/tests/dsc_brew.tests.ps1 b/dsc/tests/other/dsc_brew.tests.ps1 similarity index 77% rename from dsc/tests/dsc_brew.tests.ps1 rename to dsc/tests/other/dsc_brew.tests.ps1 index 3987de98a..17554ee82 100644 --- a/dsc/tests/dsc_brew.tests.ps1 +++ b/dsc/tests/other/dsc_brew.tests.ps1 @@ -7,14 +7,14 @@ Describe 'Brew resource tests' { } It 'Config get works' -Skip:(-not $brewExists) { - $out = dsc config get -f $PSScriptRoot/../examples/brew.dsc.yaml | ConvertFrom-Json -Depth 10 + $out = dsc config get -f $PSScriptRoot/../../examples/brew.dsc.yaml | ConvertFrom-Json -Depth 10 $LASTEXITCODE | Should -Be 0 $exists = $null -ne (Get-Command gitui -CommandType Application -ErrorAction Ignore) $out.results[1].result.actualState._exist | Should -Be $exists } It 'Config test works' -Skip:(-not $brewExists) { - $out = dsc config test -f $PSScriptRoot/../examples/brew.dsc.yaml | ConvertFrom-Json -Depth 10 + $out = dsc config test -f $PSScriptRoot/../../examples/brew.dsc.yaml | ConvertFrom-Json -Depth 10 $LASTEXITCODE | Should -Be 0 $exists = $null -ne (Get-Command gitui -CommandType Application -ErrorAction Ignore) $out.results[1].result.inDesiredState | Should -Be $exists diff --git a/dsc/tests/dsc_osinfo.tests.ps1 b/dsc/tests/other/dsc_osinfo.tests.ps1 similarity index 79% rename from dsc/tests/dsc_osinfo.tests.ps1 rename to dsc/tests/other/dsc_osinfo.tests.ps1 index f45e53e74..d0a50b432 100644 --- a/dsc/tests/dsc_osinfo.tests.ps1 +++ b/dsc/tests/other/dsc_osinfo.tests.ps1 @@ -3,7 +3,7 @@ Describe 'Tests for osinfo examples' { It 'Config with default parameters and get works' { - $out = dsc config get -f $PSScriptRoot/../examples/osinfo_parameters.dsc.yaml | ConvertFrom-Json -Depth 10 + $out = dsc config get -f $PSScriptRoot/../../examples/osinfo_parameters.dsc.yaml | ConvertFrom-Json -Depth 10 $LASTEXITCODE | Should -Be 0 $expected = if ($IsWindows) { 'Windows' @@ -17,7 +17,7 @@ Describe 'Tests for osinfo examples' { } It 'Config test works' { - $out = dsc config -f $PSScriptRoot/../examples/osinfo.parameters.yaml test -f $PSScriptRoot/../examples/osinfo_parameters.dsc.yaml | ConvertFrom-Json -Depth 10 + $out = dsc config -f $PSScriptRoot/../../examples/osinfo.parameters.yaml test -f $PSScriptRoot/../../examples/osinfo_parameters.dsc.yaml | ConvertFrom-Json -Depth 10 $LASTEXITCODE | Should -Be 0 $out.results[0].result.inDesiredState | Should -Be $IsMacOS } @@ -32,7 +32,7 @@ Describe 'Tests for osinfo examples' { $new_path = ($oldPath.Split([System.IO.Path]::PathSeparator) | Where-Object { $_ -ne $exe_path }) -join [System.IO.Path]::PathSeparator $env:PATH = $new_path - $null = & "$exe_path/dsc" config test -f "$PSScriptRoot/../examples/osinfo_parameters.dsc.yaml" + $null = & "$exe_path/dsc" config test -f "$PSScriptRoot/../../examples/osinfo_parameters.dsc.yaml" $LASTEXITCODE | Should -Be 0 } finally { diff --git a/dsc/tests/dsc_output.tests.ps1 b/dsc/tests/other/dsc_output.tests.ps1 similarity index 100% rename from dsc/tests/dsc_output.tests.ps1 rename to dsc/tests/other/dsc_output.tests.ps1 diff --git a/dsc/tests/dsc_resource_condition.tests.ps1 b/dsc/tests/other/dsc_resource_condition.tests.ps1 similarity index 100% rename from dsc/tests/dsc_resource_condition.tests.ps1 rename to dsc/tests/other/dsc_resource_condition.tests.ps1 diff --git a/dsc/tests/dsc_resource_export.tests.ps1 b/dsc/tests/other/dsc_resource_export.tests.ps1 similarity index 100% rename from dsc/tests/dsc_resource_export.tests.ps1 rename to dsc/tests/other/dsc_resource_export.tests.ps1 diff --git a/dsc/tests/dsc_resource_get.tests.ps1 b/dsc/tests/other/dsc_resource_get.tests.ps1 similarity index 100% rename from dsc/tests/dsc_resource_get.tests.ps1 rename to dsc/tests/other/dsc_resource_get.tests.ps1 diff --git a/dsc/tests/dsc_resource_input.tests.ps1 b/dsc/tests/other/dsc_resource_input.tests.ps1 similarity index 100% rename from dsc/tests/dsc_resource_input.tests.ps1 rename to dsc/tests/other/dsc_resource_input.tests.ps1 diff --git a/dsc/tests/dsc_resource_schema.tests.ps1 b/dsc/tests/other/dsc_resource_schema.tests.ps1 similarity index 100% rename from dsc/tests/dsc_resource_schema.tests.ps1 rename to dsc/tests/other/dsc_resource_schema.tests.ps1 diff --git a/dsc/tests/dsc_resource_securitycontext.tests.ps1 b/dsc/tests/other/dsc_resource_securitycontext.tests.ps1 similarity index 100% rename from dsc/tests/dsc_resource_securitycontext.tests.ps1 rename to dsc/tests/other/dsc_resource_securitycontext.tests.ps1 diff --git a/dsc/tests/dsc_resource_set.tests.ps1 b/dsc/tests/other/dsc_resource_set.tests.ps1 similarity index 100% rename from dsc/tests/dsc_resource_set.tests.ps1 rename to dsc/tests/other/dsc_resource_set.tests.ps1 diff --git a/dsc/tests/dsc_resource_test.tests.ps1 b/dsc/tests/other/dsc_resource_test.tests.ps1 similarity index 100% rename from dsc/tests/dsc_resource_test.tests.ps1 rename to dsc/tests/other/dsc_resource_test.tests.ps1 diff --git a/dsc/tests/dsc_schema.tests.ps1 b/dsc/tests/other/dsc_schema.tests.ps1 similarity index 100% rename from dsc/tests/dsc_schema.tests.ps1 rename to dsc/tests/other/dsc_schema.tests.ps1 diff --git a/dsc/tests/dsc_securitycontext.tests.ps1 b/dsc/tests/other/dsc_securitycontext.tests.ps1 similarity index 96% rename from dsc/tests/dsc_securitycontext.tests.ps1 rename to dsc/tests/other/dsc_securitycontext.tests.ps1 index d05a49156..e45c5bd27 100644 --- a/dsc/tests/dsc_securitycontext.tests.ps1 +++ b/dsc/tests/other/dsc_securitycontext.tests.ps1 @@ -13,7 +13,7 @@ Describe 'Tests for configuration security context metadata' { } It 'Require admin' { - $out = dsc config get -f $PSScriptRoot/../examples/require_admin.yaml 2>$null + $out = dsc config get -f $PSScriptRoot/../../examples/require_admin.yaml 2>$null if ($isAdmin) { $LASTEXITCODE | Should -Be 0 $out | Should -Not -BeNullOrEmpty @@ -47,7 +47,7 @@ resources: } It 'Require non-admin' { - $out = dsc config get -f $PSScriptRoot/../examples/require_nonadmin.yaml 2>$null + $out = dsc config get -f $PSScriptRoot/../../examples/require_nonadmin.yaml 2>$null if ($isAdmin) { $LASTEXITCODE | Should -Be 2 } diff --git a/dsc/tests/dsc_server.tests.ps1 b/dsc/tests/other/dsc_server.tests.ps1 similarity index 100% rename from dsc/tests/dsc_server.tests.ps1 rename to dsc/tests/other/dsc_server.tests.ps1 diff --git a/dsc/tests/dsc_settings.tests.ps1 b/dsc/tests/other/dsc_settings.tests.ps1 similarity index 100% rename from dsc/tests/dsc_settings.tests.ps1 rename to dsc/tests/other/dsc_settings.tests.ps1 diff --git a/dsc/tests/dsc_settings_policy_security.tests.ps1 b/dsc/tests/other/dsc_settings_policy_security.tests.ps1 similarity index 100% rename from dsc/tests/dsc_settings_policy_security.tests.ps1 rename to dsc/tests/other/dsc_settings_policy_security.tests.ps1 diff --git a/dsc/tests/dsc_sshdconfig.tests.ps1 b/dsc/tests/other/dsc_sshdconfig.tests.ps1 similarity index 100% rename from dsc/tests/dsc_sshdconfig.tests.ps1 rename to dsc/tests/other/dsc_sshdconfig.tests.ps1 diff --git a/dsc/tests/dsc_test_resource_errors.tests.ps1 b/dsc/tests/other/dsc_test_resource_errors.tests.ps1 similarity index 100% rename from dsc/tests/dsc_test_resource_errors.tests.ps1 rename to dsc/tests/other/dsc_test_resource_errors.tests.ps1 diff --git a/dsc/tests/dsc_tracing.tests.ps1 b/dsc/tests/other/dsc_tracing.tests.ps1 similarity index 100% rename from dsc/tests/dsc_tracing.tests.ps1 rename to dsc/tests/other/dsc_tracing.tests.ps1 diff --git a/dsc/tests/dsc_version.tests.ps1 b/dsc/tests/other/dsc_version.tests.ps1 similarity index 100% rename from dsc/tests/dsc_version.tests.ps1 rename to dsc/tests/other/dsc_version.tests.ps1 diff --git a/helpers.build.psm1 b/helpers.build.psm1 index b1f8bdc55..90ce65703 100644 --- a/helpers.build.psm1 +++ b/helpers.build.psm1 @@ -2856,8 +2856,8 @@ function Test-ProjectWithPester { [cmdletbinding()] param( [DscProjectDefinition[]]$Project, - [ValidateSet("dsc", "adapters", "extensions", "grammars", "resources")] [string[]]$Group, + [string[]]$ExcludePath, [switch]$UsingADO ) @@ -2930,6 +2930,9 @@ function Test-ProjectWithPester { } else { Write-Verbose "Invoking pester for all groups and projects" } + if ($ExcludePath) { + $pesterParams.ExcludePath = $ExcludePath + } Invoke-Pester @pesterParams } } diff --git a/resources/dism_dsc/tests/featureOnDemand_export.tests.ps1 b/resources/dism_dsc/tests/FeatureOnDemand/featureOnDemand_export.tests.ps1 similarity index 100% rename from resources/dism_dsc/tests/featureOnDemand_export.tests.ps1 rename to resources/dism_dsc/tests/FeatureOnDemand/featureOnDemand_export.tests.ps1 diff --git a/resources/dism_dsc/tests/featureOnDemand_get.tests.ps1 b/resources/dism_dsc/tests/FeatureOnDemand/featureOnDemand_get.tests.ps1 similarity index 100% rename from resources/dism_dsc/tests/featureOnDemand_get.tests.ps1 rename to resources/dism_dsc/tests/FeatureOnDemand/featureOnDemand_get.tests.ps1 diff --git a/resources/dism_dsc/tests/featureOnDemand_set.tests.ps1 b/resources/dism_dsc/tests/FeatureOnDemand/featureOnDemand_set.tests.ps1 similarity index 100% rename from resources/dism_dsc/tests/featureOnDemand_set.tests.ps1 rename to resources/dism_dsc/tests/FeatureOnDemand/featureOnDemand_set.tests.ps1 diff --git a/resources/dism_dsc/tests/optionalFeature_export.tests.ps1 b/resources/dism_dsc/tests/OptionalFeature/optionalFeature_export.tests.ps1 similarity index 100% rename from resources/dism_dsc/tests/optionalFeature_export.tests.ps1 rename to resources/dism_dsc/tests/OptionalFeature/optionalFeature_export.tests.ps1 diff --git a/resources/dism_dsc/tests/optionalFeature_get.tests.ps1 b/resources/dism_dsc/tests/OptionalFeature/optionalFeature_get.tests.ps1 similarity index 100% rename from resources/dism_dsc/tests/optionalFeature_get.tests.ps1 rename to resources/dism_dsc/tests/OptionalFeature/optionalFeature_get.tests.ps1 diff --git a/resources/dism_dsc/tests/optionalFeature_set.tests.ps1 b/resources/dism_dsc/tests/OptionalFeature/optionalFeature_set.tests.ps1 similarity index 100% rename from resources/dism_dsc/tests/optionalFeature_set.tests.ps1 rename to resources/dism_dsc/tests/OptionalFeature/optionalFeature_set.tests.ps1 diff --git a/resources/dism_dsc/tests/windowsFeature_export.tests.ps1 b/resources/dism_dsc/tests/WindowsFeature/windowsFeature_export.tests.ps1 similarity index 100% rename from resources/dism_dsc/tests/windowsFeature_export.tests.ps1 rename to resources/dism_dsc/tests/WindowsFeature/windowsFeature_export.tests.ps1 diff --git a/resources/dism_dsc/tests/windowsFeature_get.tests.ps1 b/resources/dism_dsc/tests/WindowsFeature/windowsFeature_get.tests.ps1 similarity index 100% rename from resources/dism_dsc/tests/windowsFeature_get.tests.ps1 rename to resources/dism_dsc/tests/WindowsFeature/windowsFeature_get.tests.ps1 diff --git a/resources/dism_dsc/tests/windowsFeature_set.tests.ps1 b/resources/dism_dsc/tests/WindowsFeature/windowsFeature_set.tests.ps1 similarity index 100% rename from resources/dism_dsc/tests/windowsFeature_set.tests.ps1 rename to resources/dism_dsc/tests/WindowsFeature/windowsFeature_set.tests.ps1 diff --git a/resources/dism_dsc/tests/windowsFeature_whatif.tests.ps1 b/resources/dism_dsc/tests/WindowsFeature/windowsFeature_whatif.tests.ps1 similarity index 100% rename from resources/dism_dsc/tests/windowsFeature_whatif.tests.ps1 rename to resources/dism_dsc/tests/WindowsFeature/windowsFeature_whatif.tests.ps1