Skip to content

Commit

Permalink
add atomic runner hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
clr2of8 committed Oct 3, 2023
1 parent ea668fb commit 78c6442
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions Public/Invoke-AtomicRunner.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
. "$PSScriptRoot\Invoke-RunnerScheduleMethods.ps1"

function Invoke-AtomicRunner {
[CmdletBinding(
SupportsShouldProcess = $true,
Expand Down Expand Up @@ -59,13 +58,17 @@ function Invoke-AtomicRunner {
$tr.InputArgs = ConvertFrom-StringData -StringData $theArgs
}
$sc = $tr.AtomicsFolder
if ($Cleanup) { if (Get-Command 'Invoke-AtomicRunnerPreAtomicCleanupHook' -errorAction SilentlyContinue) { Invoke-AtomicRunnerPreAtomicCleanupHook } }
elseif (-not($ShowDetails -or $CheckPrereqs -or $ShowDetailsBrief -or $GetPrereqs)) { if (Get-Command 'Invoke-AtomicRunnerPreAtomicHook' -errorAction SilentlyContinue) { Invoke-AtomicRunnerPreAtomicHook } }
#Run the Test based on if scheduleContext is 'private' or 'public'
if (($sc -eq 'public') -or ($null -eq $sc)) {
Invoke-AtomicTest $tr.Technique -TestGuids $tr.auto_generated_guid -InputArgs $tr.InputArgs -TimeoutSeconds $tr.TimeoutSeconds -ExecutionLogPath $artConfig.execLogPath -PathToAtomicsFolder $artConfig.PathToPublicAtomicsFolder @htvars -Cleanup:$Cleanup -supressPathToAtomicsFolder
}
elseif ($sc -eq 'private') {
Invoke-AtomicTest $tr.Technique -TestGuids $tr.auto_generated_guid -InputArgs $tr.InputArgs -TimeoutSeconds $tr.TimeoutSeconds -ExecutionLogPath $artConfig.execLogPath -PathToAtomicsFolder $artConfig.PathToPrivateAtomicsFolder @htvars -Cleanup:$Cleanup -supressPathToAtomicsFolder
}
if ($Cleanup) { if (Get-Command 'Invoke-AtomicRunnerPostAtomicCleanupHook' -errorAction SilentlyContinue) { Invoke-AtomicRunnerPostAtomicCleanupHook } }
elseif (-not($ShowDetails -or $CheckPrereqs -or $ShowDetailsBrief -or $GetPrereqs)) { if (Get-Command 'Invoke-AtomicRunnerPostAtomicHook' -errorAction SilentlyContinue) { Invoke-AtomicRunnerPostAtomicHook } }
}

function Rename-ThisComputer ($tr, $basehostname) {
Expand Down Expand Up @@ -170,7 +173,6 @@ function Invoke-AtomicRunner {
}
return
}

# exit if file stop.txt is found
If (Test-Path $artConfig.stopFile) {
LogRunnerMsg "exiting script because $($artConfig.stopFile) does exist"
Expand All @@ -192,15 +194,11 @@ function Invoke-AtomicRunner {
}

if ($null -ne $tr) {
if (Get-Command 'Invoke-AtomicRunnerPreAtomicHook' -errorAction SilentlyContinue) { Invoke-AtomicRunnerPreAtomicHook }
Invoke-AtomicTestFromScheduleRow $tr
if (Get-Command 'Invoke-AtomicRunnerPostAtomicHook' -errorAction SilentlyContinue) { Invoke-AtomicRunnerPostAtomicHook }
Write-Host -Fore cyan "Sleeping for $SleepTillCleanup seconds before cleaning up"; Start-Sleep -Seconds $SleepTillCleanup

# Cleanup after running test
if (Get-Command 'Invoke-AtomicRunnerPreAtomicCleanupHook' -errorAction SilentlyContinue) { Invoke-AtomicRunnerPreAtomicCleanupHook }
Invoke-AtomicTestFromScheduleRow $tr $true
if (Get-Command 'Invoke-AtomicRunnerPostAtomicCleanupHook' -errorAction SilentlyContinue) { Invoke-AtomicRunnerPostAtomicCleanupHook }
}
else {
LogRunnerMsg "Could not find Test: $guid in schedule. Please update schedule to run this test."
Expand Down

0 comments on commit 78c6442

Please sign in to comment.