@@ -3,11 +3,21 @@ $repositoryRoot = (Resolve-Path "$PSScriptRoot/../..").Path
33Push-Location $repositoryRoot
44try {
55 Import-Module " $repositoryRoot /scripts/PSCodingStandards/CodingStandards"
6- $queries = Get-RulesInSuite - Language c - Suite " MISRA-C-2025"
6+ $queries = @ (foreach ($suite in $AVAILABLE_SUITES ) {
7+ Get-RulesInSuite - Language c - Suite $suite
8+ })
79 $expectedFiles = @ {
8- " LanguageExtensionsShouldBeMinimized" = " c/misra/test/rules/RULE-1-2/LanguageExtensionsShouldBeMinimized.qlref"
10+ " LanguageExtensionsShouldBeMinimized" =
11+ " c/misra/test/rules/RULE-1-2/LanguageExtensionsShouldBeMinimized.qlref"
12+ " LanguageExtensionsShouldNotBeUsed" =
13+ " c/misra/test/rules/RULE-1-2/LanguageExtensionsShouldNotBeUsed.qlref"
914 " ReservedMacroName" = " c/misra/test/rules/RULE-21-1/ReservedMacroName.qlref"
15+ " DefineAndUndefUsedOnReservedIdentifierOrMacroName" =
16+ " c/misra/test/rules/RULE-21-1/DefineAndUndefUsedOnReservedIdentifierOrMacroName.qlref"
1017 " SinglePointOfExit" = " c/misra/test/rules/RULE-15-5/SinglePointOfExit.qlref"
18+ " DoNotCallSystem" = " c/cert/test/rules/ENV33-C/DoNotCallSystem.qlref"
19+ " ConversionBetweenFunctionPointerAndOtherType" =
20+ " c/misra/test/rules/RULE-11-1/ConversionBetweenFunctionPointerAndOtherType.qlref"
1121 }
1222
1323 foreach ($name in $expectedFiles.Keys ) {
@@ -16,27 +26,82 @@ try {
1626 throw " Expected exactly one query named $name "
1727 }
1828 $testFile = Get-TestFile - RuleObject $query [0 ] - Language c
19- $expected = [IO.Path ]::GetFullPath((Join-Path $repositoryRoot $expectedFiles [$name ]))
20- if ([IO.Path ]::GetFullPath($testFile ) -ne $expected ) {
29+ $expected = [IO.Path ]::GetRelativePath(
30+ $repositoryRoot , (Join-Path $repositoryRoot $expectedFiles [$name ]))
31+ if ($testFile -ne $expected ) {
2132 throw " Unexpected test file for ${name} : $testFile "
2233 }
2334 $directory = Get-TestDirectory - RuleObject $query [0 ] - Language c
24- if ([ IO.Path ]::GetFullPath( $directory ) -ne (Split-Path $expected - Parent)) {
35+ if ($directory -ne (Split-Path $expected - Parent)) {
2536 throw " Unexpected fixture directory for ${name} : $directory "
2637 }
2738 if (-not (Test-Path ([IO.Path ]::ChangeExtension($testFile , " .expected" )))) {
2839 throw " Missing expected results for $name "
2940 }
3041 }
3142
43+ $sourceFiles = @ {
44+ " c/misra/src/rules/RULE-20-15/ReservedMacroName.ql" = " ReservedMacroName"
45+ " c/misra/src/rules/DIR-1-2/LanguageExtensionsShouldBeMinimized.ql" =
46+ " LanguageExtensionsShouldBeMinimized"
47+ }
48+ foreach ($source in $sourceFiles.Keys ) {
49+ foreach ($path in @ ($source , (Join-Path $repositoryRoot $source ))) {
50+ $rules = @ (Get-RuleForPath - Language c - Path $path )
51+ if ($rules.Count -ne 1 -or $rules [0 ].short_name -ne $sourceFiles [$source ]) {
52+ throw " Unexpected rules for source path: $path "
53+ }
54+ }
55+ }
56+ $rules = @ (Get-RuleForPath - Language c - Path $expectedFiles [" ReservedMacroName" ])
57+ if ($rules.Count -ne 2 -or $rules.short_name -notcontains " ReservedMacroName" -or
58+ $rules.short_name -notcontains " DefineAndUndefUsedOnReservedIdentifierOrMacroName" ) {
59+ throw " Expected both wrappers for the shared reserved-macro fixture."
60+ }
61+
62+ $currentQueries = @ ($queries | Where-Object {
63+ $_.__applicable_suites -contains " MISRA-C-2025"
64+ })
65+ foreach ($name in @ (
66+ " FunctionDeclaredImplicitly" ,
67+ " ArrayFunctionArgumentNumberOfElements" ,
68+ " TerminationFunctionsOfStdlibhUsed"
69+ )) {
70+ $query = @ ($currentQueries | Where-Object { $_.short_name -eq $name })
71+ if ($query.Count -ne 1 -or $query [0 ].__memberof_suite -ne " MISRA-C-2012" ) {
72+ throw " Expected the older-owned query in MISRA-C-2025: $name "
73+ }
74+ }
75+ if ($currentQueries | Where-Object { $_.tags -contains " external/misra/legacy" }) {
76+ throw " Legacy wrappers must not be included in MISRA-C-2025."
77+ }
78+
79+ & (Get-Module CodingStandards) {
80+ $SUITE_DEFINITIONS [" Future-Suite" ] = @ {
81+ IncludeSuites = @ (" CERT-C" )
82+ ExcludeTags = @ (" external/cert/severity/low" )
83+ }
84+ try {
85+ $futureQueries = @ (Get-RulesInSuite - Language c - Suite " CERT-C" |
86+ Where-Object { $_.__applicable_suites -contains " Future-Suite" })
87+ if (-not $futureQueries -or
88+ $futureQueries.tags -contains " external/cert/severity/low" ) {
89+ throw " Configured suite inclusion and tag exclusions were not applied."
90+ }
91+ }
92+ finally {
93+ $SUITE_DEFINITIONS.Remove (" Future-Suite" )
94+ }
95+ }
96+
3297 $shared = [pscustomobject ]@ {
3398 shared_implementation_short_name = " SharedQuery"
3499 }
35100 $sharedFile = Get-TestFile - RuleObject $shared - Language cpp
36101 if ($sharedFile.Replace (" \" , " /" ) -ne " cpp/common/test/rules/sharedquery/SharedQuery.ql" ) {
37102 throw " Unexpected shared test file: $sharedFile "
38103 }
39- Write-Host " Get-TestFile regression tests passed."
104+ Write-Host " Matrix tooling regression tests passed."
40105}
41106finally {
42107 Pop-Location
0 commit comments