Skip to content

Commit

Permalink
Revert "test passing _Driver tests after only one device (#83)"
Browse files Browse the repository at this point in the history
This reverts commit fbd2984.

I should've created a separate branch for experiments like this, but it
was most likely not the right solution anyway. Will try more on other
branches.
  • Loading branch information
jantari committed Mar 30, 2023
1 parent fbd2984 commit 21e7d97
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions private/Test-MachineSatisfiesDependency.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@

if ($DevicesToTest.Count -ge 1) {
$TestResults = [System.Collections.Generic.List[bool]]::new()
$PerDeviceTestResults = [System.Collections.Generic.List[bool]]::new()
foreach ($Device in $DevicesToTest) {
$PerDeviceTestResults.Clear()
Write-Debug "$('- ' * $DebugIndent)Testing $($Device.DeviceId)"
# First, check if there is a driver installed for the device at all before proceeding (issue#24)
if ($Device.Problem -eq 'CM_PROB_FAILED_INSTALL') {
Expand Down Expand Up @@ -183,10 +181,10 @@
Write-Debug "$('- ' * $DebugIndent)[Got: $DriverDate, Expected: $LenovoDate]"
if ($DriverDate -ge $LenovoDate) {
Write-Debug "$('- ' * $DebugIndent)Passed DriverDate test"
$PerDeviceTestResults.Add($true)
$TestResults.Add($true)
} else {
Write-Debug "$('- ' * $DebugIndent)Failed DriverDate test"
$PerDeviceTestResults.Add($false)
$TestResults.Add($false)
}
} else {
Write-Verbose "Device '$($Device.InstanceId)' does not report its driver date"
Expand All @@ -203,26 +201,18 @@
Write-Debug "$('- ' * $DebugIndent)[Got: $DriverVersion, Expected: $($Dependency.Version)]"
if ((Test-VersionPattern -LenovoString $Dependency.Version -SystemString $DriverVersion) -eq 0) {
Write-Debug "$('- ' * $DebugIndent)Passed DriverVersion test"
$PerDeviceTestResults.Add($true)
$TestResults.Add($true)
} else {
Write-Debug "$('- ' * $DebugIndent)Failed DriverVersion test"
$PerDeviceTestResults.Add($false)
$TestResults.Add($false)
}
} else {
Write-Verbose "Device '$($Device.InstanceId)' does not report its driver version"
}
}

# If all HardwareID-tests were successful for even just one HardwareID, return SUCCESS
if ($env:LSUCLIENT_PASS_DRIVER_ONE_HARDWAREID -and -not ($PerDeviceTestResults -contains $false)) {
return 0 #SUCCESS
}

$TestResults.AddRange($PerDeviceTestResults)
## end of foreach device loop
}

# If all HardwareID-tests were successful for ALL HardwareIDs, return SUCCESS
# If all HardwareID-tests were successful, return SUCCESS
if (-not ($TestResults -contains $false)) {
return 0 #SUCCESS
}
Expand Down

1 comment on commit 21e7d97

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PSScriptAnalyzer results as of this commit:

  • 2 Information
  • 8 Warning
See details
Location : ./public/Set-LSUClientConfiguration.ps1 [1, 10]
RuleName : PSUseShouldProcessForStateChangingFunctions
Severity : Warning
Message  : Function 'Set-LSUClientConfiguration' has verb that could change system state
           . Therefore, the function has to support 'ShouldProcess'.

Location : ./public/Install-LSUpdate.ps1 [135, 21]
RuleName : PSUseOutputTypeCorrectly
Severity : Information
Message  : The cmdlet 'Install-LSUpdate' returns an object of type 'PackageInstallResult
           ' but this type is not declared in the OutputType attribute.

Location : ./public/Install-LSUpdate.ps1 [172, 21]
RuleName : PSUseOutputTypeCorrectly
Severity : Information
Message  : The cmdlet 'Install-LSUpdate' returns an object of type 'PackageInstallResult
           ' but this type is not declared in the OutputType attribute.

Location : ./private/Resolve-XMLDependencies.ps1 [1, 10]
RuleName : PSUseSingularNouns
Severity : Warning
Message  : The cmdlet 'Resolve-XMLDependencies' uses a plural noun. A singular noun shou
           ld be used instead.

Location : ./private/Compare-Array.ps1 [30, 17]
RuleName : PSReviewUnusedParameter
Severity : Warning
Message  : The parameter 'in' has been declared but not used. 

Location : ./private/Invoke-PackageCommand.ps1 [303, 29]
RuleName : PSAvoidUsingEmptyCatchBlock
Severity : Warning
Message  : Empty catch block is used. Please use Write-Error or throw statements in catc
           h blocks.

Location : ./private/Split-ExecutableAndArguments.ps1 [1, 10]
RuleName : PSUseSingularNouns
Severity : Warning
Message  : The cmdlet 'Split-ExecutableAndArguments' uses a plural noun. A singular noun
            should be used instead.

Location : ./private/Debug-LongRunningProcess.ps1 [44, 13]
RuleName : PSAvoidUsingEmptyCatchBlock
Severity : Warning
Message  : Empty catch block is used. Please use Write-Error or throw statements in catc
           h blocks.

Location : ./private/Debug-LongRunningProcess.ps1 [139, 82]
RuleName : PSReviewUnusedParameter
Severity : Warning
Message  : The parameter 'lParam' has been declared but not used. 

Location : ./private/Set-BIOSUpdateRegistryFlag.ps1 [1, 10]
RuleName : PSUseShouldProcessForStateChangingFunctions
Severity : Warning
Message  : Function 'Set-BIOSUpdateRegistryFlag' has verb that could change system state
           . Therefore, the function has to support 'ShouldProcess'.

Please sign in to comment.