Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 29 additions & 3 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -266,14 +289,17 @@ 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
Test = $true
ExcludeRustTests = $true
Verbose = $true
}
if ('${{matrix.exclude}}') {
$params.PesterExcludePath = '${{matrix.exclude}}'
}
./build.ps1 @params -PesterTestGroup ${{matrix.group}}
- name: Generate coverage report
if: always()
Expand All @@ -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

Expand Down
5 changes: 4 additions & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*?'
}
Expand Down Expand Up @@ -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'"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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('"', '\"')
Expand Down Expand Up @@ -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 = @"
Expand Down Expand Up @@ -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'
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ BeforeDiscovery {
'y2j'
)
$localeFolders = $rootFolders | ForEach-Object -Process {
Get-ChildItem $PSScriptRoot/../../$_/locales -Recurse -Directory
Get-ChildItem $PSScriptRoot/../../../$_/locales -Recurse -Directory
}

$projects = @()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 @"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
}
Expand All @@ -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 {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 4 additions & 1 deletion helpers.build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -2856,8 +2856,8 @@ function Test-ProjectWithPester {
[cmdletbinding()]
param(
[DscProjectDefinition[]]$Project,
[ValidateSet("dsc", "adapters", "extensions", "grammars", "resources")]
[string[]]$Group,
[string[]]$ExcludePath,
[switch]$UsingADO
)

Expand Down Expand Up @@ -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
}
}
Expand Down
Loading