Skip to content

Commit e5882e8

Browse files
committed
handle identation in xml
1 parent 45d04a2 commit e5882e8

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

integration-tests/run.ps1

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ function Normalize-Config {
1919

2020
$ext = [System.IO.Path]::GetExtension($file).TrimStart('.')
2121

22+
if ($ext -eq 'xml') {
23+
Normalize-XmlFile $file
24+
return
25+
}
26+
2227
switch ($ext) {
2328
{ $_ -in @('yaml', 'yml') } {
2429
# For YAML files, preserve structure and sort within sections
@@ -72,6 +77,27 @@ function Normalize-Config {
7277
}
7378
}
7479

80+
# Helper function to normalize XML files: strip leading spaces and sort <rule ref=.../> lines
81+
function Normalize-XmlFile {
82+
param([string]$Path)
83+
$lines = Get-Content $Path
84+
$rules = @()
85+
$output = @()
86+
$endTag = $null
87+
88+
foreach ($line in $lines) {
89+
$trimmed = $line.TrimStart()
90+
if ($trimmed -match '^<rule ref=') {
91+
$rules += $trimmed
92+
} elseif ($trimmed -match '^</ruleset>') {
93+
$endTag = $trimmed
94+
} else {
95+
$output += $trimmed
96+
}
97+
}
98+
$output + ($rules | Sort-Object) + $endTag
99+
}
100+
75101
function Compare-Files {
76102
param (
77103
[string]$expectedDir,

0 commit comments

Comments
 (0)