Skip to content

Commit

Permalink
win_regedit: stabilise tests (ansible#38912)
Browse files Browse the repository at this point in the history
(cherry picked from commit 77ef480)
  • Loading branch information
jborean93 committed Apr 17, 2018
1 parent 9178def commit cd1f895
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
1 change: 1 addition & 0 deletions lib/ansible/modules/windows/win_regedit.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,7 @@ $key_prefix[$path]
} finally {
if ($hive) {
[GC]::Collect()
[GC]::WaitForPendingFinalizers()
try {
[Ansible.RegistryUtil]::UnloadHive("ANSIBLE")
} catch [System.ComponentModel.Win32Exception] {
Expand Down
10 changes: 3 additions & 7 deletions test/integration/targets/win_regedit/tasks/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,6 @@
$prop = Get-ItemProperty -Path HKLM:\ANSIBLE\NewKey -Name TestProp -ErrorAction SilentlyContinue
if ($prop) {
$prop.TestProp
$prop.Close()
}
&reg.exe unload HKLM\ANSIBLE > $null
exit 0
Expand Down Expand Up @@ -565,7 +564,6 @@
$prop = Get-ItemProperty -Path HKLM:\ANSIBLE\NewKey -Name TestProp -ErrorAction SilentlyContinue
if ($prop) {
$prop.TestProp
$prop.Close()
}
&reg.exe unload HKLM\ANSIBLE > $null
exit 0
Expand Down Expand Up @@ -607,7 +605,6 @@
$prop = Get-ItemProperty -Path HKLM:\ANSIBLE\NewKey -Name TestProp -ErrorAction SilentlyContinue
if ($prop) {
$prop.TestProp
$prop.Close()
}
&reg.exe unload HKLM\ANSIBLE > $null
exit 0
Expand All @@ -633,7 +630,6 @@
$prop = Get-ItemProperty -Path HKLM:\ANSIBLE\NewKey -Name TestProp -ErrorAction SilentlyContinue
if ($prop) {
$prop.TestProp
$prop.Close()
}
&reg.exe unload HKLM\ANSIBLE > $null
exit 0
Expand Down Expand Up @@ -662,7 +658,7 @@
win_regedit:
path: '{{test_win_regedit_hive_key}}'
state: absent
delete_yes: yes
delete_key: yes
hive: C:\Users\Default\NTUSER.dat
register: remove_key_in_hive_check
check_mode: yes
Expand All @@ -688,7 +684,7 @@
win_regedit:
path: '{{test_win_regedit_hive_key}}'
state: absent
delete_yes: yes
delete_key: yes
hive: C:\Users\Default\NTUSER.dat
register: remove_key_in_hive

Expand All @@ -713,7 +709,7 @@
win_regedit:
path: '{{test_win_regedit_hive_key}}'
state: absent
delete_yes: yes
delete_key: yes
hive: C:\Users\Default\NTUSER.dat
register: remove_key_in_hive_again

Expand Down

0 comments on commit cd1f895

Please sign in to comment.