Skip to content

Commit 2fe57b6

Browse files
authored
Merge pull request #875 from SteveL-MSFT/get-all-default
Backport 3.1: Fix regression in get-all default output
2 parents bdec7d0 + 49f6916 commit 2fe57b6

File tree

3 files changed

+28
-19
lines changed

3 files changed

+28
-19
lines changed

dsc/src/resource_command.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ pub fn get_all(dsc: &DscManager, resource_type: &str, format: Option<&GetOutputF
116116
let format = match format {
117117
Some(&GetOutputFormat::PrettyJson) => Some(&OutputFormat::PrettyJson),
118118
Some(&GetOutputFormat::Yaml) => Some(&OutputFormat::Yaml),
119+
None => None,
119120
_ => Some(&OutputFormat::Json),
120121
};
121122
write_object(&json, format, include_separator);

powershell-adapter/Tests/win_powershellgroup.tests.ps1

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,22 @@ Describe 'WindowsPowerShell adapter resource tests - requires elevated permissio
66
BeforeAll {
77
if ($isWindows) {
88
winrm quickconfig -quiet -force
9-
}
10-
$OldPSModulePath = $env:PSModulePath
11-
$env:PSModulePath += [System.IO.Path]::PathSeparator + $PSScriptRoot
9+
$OldPSModulePath = $env:PSModulePath
10+
$env:PSModulePath += [System.IO.Path]::PathSeparator + $PSScriptRoot
1211

13-
$winpsConfigPath = Join-path $PSScriptRoot "winps_resource.dsc.yaml"
14-
if ($isWindows) {
15-
$cacheFilePath_v5 = Join-Path $env:LocalAppData "dsc" "WindowsPSAdapterCache.json"
12+
$winpsConfigPath = Join-path $PSScriptRoot "winps_resource.dsc.yaml"
13+
if ($isWindows) {
14+
$cacheFilePath_v5 = Join-Path $env:LocalAppData "dsc" "WindowsPSAdapterCache.json"
15+
}
1616
}
1717
}
1818
AfterAll {
19-
$env:PSModulePath = $OldPSModulePath
19+
if ($isWindows) {
20+
$env:PSModulePath = $OldPSModulePath
2021

21-
# Remove after all the tests are done
22-
Remove-Module $script:winPSModule -Force -ErrorAction Ignore
22+
# Remove after all the tests are done
23+
Remove-Module $script:winPSModule -Force -ErrorAction Ignore
24+
}
2325
}
2426

2527
BeforeEach {
@@ -161,7 +163,7 @@ resources:
161163
- "[resourceId('Microsoft.Windows/WindowsPowerShell', 'File')]"
162164
- name: TestPSRepository
163165
type: PSTestModule/TestPSRepository
164-
properties:
166+
properties:
165167
Name: NuGet
166168
dependsOn:
167169
- "[resourceId('Microsoft.Windows/WindowsPowerShell', 'File')]"
@@ -201,7 +203,7 @@ resources:
201203
type: PsDesiredStateConfiguration/Service
202204
properties:
203205
Name: Spooler
204-
State: $SecondState
206+
State: $SecondState
205207
"@
206208

207209
$inDesiredState = if ($FirstState -eq $SecondState) {
@@ -242,11 +244,11 @@ resources:
242244
# Instead of calling dsc.exe we call the cmdlet directly to be able to test the output and mocks
243245
$resourceObject = Get-DscResourceObject -jsonInput $jsonInput
244246
$cacheEntry = Invoke-DscCacheRefresh -Module PSDesiredStateConfiguration
245-
247+
246248
$out = Invoke-DscOperation -Operation Test -DesiredState $resourceObject -dscResourceCache $cacheEntry
247249
$LASTEXITCODE | Should -Be 0
248250
$out.properties.InDesiredState.InDesiredState | Should -Be $false
249-
251+
250252
Should -Invoke -CommandName ConvertTo-SecureString -Exactly -Times 1 -Scope It
251253
}
252254

@@ -261,7 +263,7 @@ resources:
261263
Credential:
262264
UserName: 'User'
263265
OtherProperty: 'Password'
264-
"@
266+
"@
265267
# Compared to PowerShell we use test here as it filters out the properties
266268
$out = dsc config test -i $yaml 2>&1 | Out-String
267269
$LASTEXITCODE | Should -Be 2
@@ -339,7 +341,7 @@ class PSClassResource {
339341
}
340342
341343
[void] Set() {
342-
344+
343345
}
344346
345347
static [PSClassResource[]] Export()
@@ -374,23 +376,23 @@ class PSClassResource {
374376
}
375377

376378
It 'Get works with class-based PS DSC resources' -Skip:(!$IsWindows) {
377-
379+
378380
$out = dsc resource get -r PSClassResource/PSClassResource --input (@{Name = 'TestName' } | ConvertTo-Json) | ConvertFrom-Json
379381
$LASTEXITCODE | Should -Be 0
380382
$out.actualState.Name | Should -Be 'TestName'
381-
$propCount = $out.actualState | Get-Member -MemberType NoteProperty
383+
$propCount = $out.actualState | Get-Member -MemberType NoteProperty
382384
$propCount.Count | Should -Be 1 # Only the DscProperty should be returned
383385
}
384386

385387
It 'Set works with class-based PS DSC resources' -Skip:(!$IsWindows) {
386-
388+
387389
$out = dsc resource set -r PSClassResource/PSClassResource --input (@{Name = 'TestName' } | ConvertTo-Json) | ConvertFrom-Json
388390
$LASTEXITCODE | Should -Be 0
389391
$out.afterstate.InDesiredState | Should -Be $true
390392
}
391393

392394
It 'Export works with class-based PS DSC resources' -Skip:(!$IsWindows) {
393-
395+
394396
$out = dsc resource export -r PSClassResource/PSClassResource | ConvertFrom-Json
395397
$LASTEXITCODE | Should -Be 0
396398
$out | Should -Not -BeNullOrEmpty

process/src/main.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,18 @@ fn get_task_list() -> Vec<ProcessInfo>
1313
let mut result = Vec::new();
1414
let mut s = System::new();
1515
s.refresh_processes(ProcessesToUpdate::All, true);
16+
let mut count = 0;
1617
for (pid, process) in s.processes() {
1718
let mut p = ProcessInfo::new();
1819
p.pid = pid.as_u32();
1920
p.name = process.name().to_string_lossy().to_string();
2021
p.cmdline = format!("{:?}", process.cmd());
2122
result.push(p);
23+
count += 1;
24+
if count > 3 {
25+
// limit to 3 processes as this is just for testing
26+
break;
27+
}
2228
}
2329

2430
result

0 commit comments

Comments
 (0)