28
28
# is a substring of the path once the substitution `/src/` -> `/test/` is
29
29
# applied
30
30
31
+ $global :ruleCacheC = $null ;
32
+ $global :ruleCacheCPP = $null ;
33
+ $global :enableRuleCache = $false
31
34
function Get-RuleForPath {
32
35
param ([Parameter (Mandatory )]
33
36
[string ]
@@ -41,9 +44,30 @@ function Get-RuleForPath {
41
44
$allQueries = @ ()
42
45
$queriesToCheck = @ ()
43
46
44
- # load all the queries
45
- foreach ($s in $AVAILABLE_SUITES ) {
46
- $allQueries += Get-RulesInSuite - Suite $s - Language $Language
47
+ if ($global :enableRuleCache ){
48
+ # load all the queries
49
+ if ($Language -eq ' cpp' ){
50
+ $ruleCache = $global :ruleCacheCPP
51
+ }else {
52
+ $ruleCache = $global :ruleCacheC
53
+ }
54
+ }
55
+
56
+ if (-not $ruleCache ){
57
+
58
+ foreach ($s in $AVAILABLE_SUITES ) {
59
+ $allQueries += Get-RulesInSuite - Suite $s - Language $Language
60
+ }
61
+
62
+ if ($global :enableRuleCache ){
63
+ if ($Language -eq ' cpp' ){
64
+ $global :ruleCacheCPP = $allQueries
65
+ }else {
66
+ $global :ruleCacheC = $allQueries
67
+ }
68
+ }
69
+ }else {
70
+ $allQueries = $ruleCache
47
71
}
48
72
49
73
$modifiedPathWithReplacement = Join-Path (Resolve-Path . - Relative) $Path
@@ -57,12 +81,11 @@ function Get-RuleForPath {
57
81
58
82
# for each query, create the test directory
59
83
foreach ($q in $allQueries ){
60
-
61
84
# get test directory
62
85
$testDirs = (Get-ATestDirectory - RuleObject $q - Language $Language )
63
86
foreach ($testDirectory in $testDirs ){
64
87
# resolve path to be compatible
65
- $testPath = Join-Path (Resolve-Path . - Relative) $testDirectory
88
+ $testPath = ( Join-Path (Resolve-Path . - Relative) $testDirectory ) + [ IO.Path ]::DirectorySeparatorChar
66
89
67
90
# see if the TEST directory is a substring of the full path
68
91
if ($modifiedPath.StartsWith ($testPath )){
0 commit comments