Skip to content

Commit

Permalink
fail out of AND tests as soon as 1 came back false
Browse files Browse the repository at this point in the history
This could fix / work around issue #103 because the problematic package:
https://download.lenovo.com/pccbbs/mobiles/n3acv41w_2_.xml
has lots of idependency tests in a long AND-clause and the one that's
hanging is the very last one. So if any previous test had already failed
we could just skip all the others, thus avoiding the problematic
ExternalDetection with MCUFWRevCheck.exe.
  • Loading branch information
jantari committed Jan 12, 2024
1 parent 0588736 commit 485be02
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions private/Resolve-XMLDependencies.ps1
Expand Up @@ -6,13 +6,16 @@
[Parameter( Mandatory = $true )]
[string]$PackagePath,
[switch]$TreatUnsupportedAsPassed,
[switch]$FailInboxDrivers
[switch]$FailInboxDrivers,
[switch]$ParentNodeIsAnd
)

$XMLTreeDepth++
[DependencyParserState]$ParserState = 0

$i = 0
foreach ($XMLTREE in $XMLIN) {
$i++
Write-Debug "$('- ' * $XMLTreeDepth )|> Node: $($XMLTREE.SchemaInfo.Name)"

if ($XMLTREE.SchemaInfo.Name -eq 'Not') {
Expand All @@ -34,7 +37,7 @@
}
}
} else {
$SubtreeResults = Resolve-XMLDependencies -XMLIN $XMLTREE.ChildNodes -PackagePath $PackagePath -TreatUnsupportedAsPassed:$TreatUnsupportedAsPassed -FailInboxDrivers:$FailInboxDrivers
$SubtreeResults = Resolve-XMLDependencies -XMLIN $XMLTREE.ChildNodes -PackagePath $PackagePath -TreatUnsupportedAsPassed:$TreatUnsupportedAsPassed -FailInboxDrivers:$FailInboxDrivers -ParentNodeIsAnd:($XMLTREE.SchemaInfo.Name -eq 'And')
switch ($XMLTREE.SchemaInfo.Name) {
'And' {
Write-Debug "$('- ' * $XMLTreeDepth)Tree was AND: Results: $subtreeresults"
Expand All @@ -50,6 +53,11 @@
Write-Debug "$('- ' * $XMLTreeDepth)< Returning $($Result -bxor $ParserState) from node $($XMLTREE.SchemaInfo.Name)"

$Result -bxor $ParserState
if ($ParentNodeIsAnd -and $i -ne $XMLIN.Count -and -not ($Result -bxor $ParserState)) {
Write-Debug "$('- ' * $XMLTreeDepth)Quitting AND evaluation early because we already got one FALSE."
$ParserState = 0 # DO_HAVE
break;
}
$ParserState = 0 # DO_HAVE
}

Expand Down

1 comment on commit 485be02

@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 : ./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/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/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'.

Location : ./public/Install-LSUpdate.ps1 [152, 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 [189, 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/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'.

Please sign in to comment.