Skip to content

Commit

Permalink
fix: allow test discovery to handle oneliner unit-tests (#1134)
Browse files Browse the repository at this point in the history
  • Loading branch information
supervacuus authored Jan 30, 2025
1 parent 4218313 commit 13498e5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
all: test

update-test-discovery:
@perl -ne 'print if s/SENTRY_TEST\(([^)]+)\)/XX(\1)/' tests/unit/*.c | sort | grep -v define | uniq > tests/unit/tests.inc
@perl -ne 'print if s/SENTRY_TEST\(([^)]+)\).*/XX(\1)/' tests/unit/*.c | sort | grep -v define | uniq > tests/unit/tests.inc
.PHONY: update-test-discovery

build/Makefile: CMakeLists.txt
Expand Down
10 changes: 7 additions & 3 deletions scripts/update_test_discovery.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
Get-ChildItem -Path 'tests/unit/*.c' | ForEach-Object {
$lines = Get-ChildItem -Path 'tests/unit/*.c' | ForEach-Object {
Get-Content $_.FullName | ForEach-Object {
if ($_ -match 'SENTRY_TEST\(([^)]+)\)') {
$_ -replace 'SENTRY_TEST\(([^)]+)\)', 'XX($1)'
$_ -replace 'SENTRY_TEST\(([^)]+)\).*', 'XX($1)'
}
}
} | Sort-Object | Where-Object { $_ -notmatch 'define' } | Get-Unique | Set-Content 'tests/unit/tests.inc'
}

[System.Array]::Sort($lines, [System.StringComparer]::Ordinal)

$lines | Where-Object { $_ -notmatch 'define' } | Get-Unique | Set-Content 'tests/unit/tests.inc'

0 comments on commit 13498e5

Please sign in to comment.