Skip to content

Commit 75a5bca

Browse files
committed
test(artifacts): streamline test output lifecycle
Record owned compiler intermediates before building, clean only successful Standard intermediates, retain Full/Acceptance and failed runs, and support explicit verified archiving with exact restore. Reduce default UI capture persistence to reusable evidence while keeping all assertions. Add synthetic lifecycle and archive coverage, renderer compatibility checks, and updated suite entry points.
1 parent 503ef48 commit 75a5bca

19 files changed

Lines changed: 976 additions & 22 deletions

‎tests/render-ui-captures.py‎

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Rasterize the test fixture's real ImGui mesh/atlas for visual inspection."""
22
import argparse
33
import json
4+
import sys
45
from pathlib import Path
56

67
import numpy as np
@@ -10,7 +11,8 @@
1011
def render(path, output_directory=None, image_format='png'):
1112
mesh = json.loads(path.read_text(encoding='utf-8'))
1213
width, height = int(mesh['width']), int(mesh['height'])
13-
atlas = np.frombuffer(path.with_suffix('.rgba').read_bytes(), dtype=np.uint8)
14+
atlas_path = capture_atlas(path, mesh)
15+
atlas = np.frombuffer(atlas_path.read_bytes(), dtype=np.uint8)
1416
atlas = atlas.reshape(mesh['atlas_height'], mesh['atlas_width'], 4).astype(np.float32) / 255
1517
image = np.zeros((height, width, 3), np.float32)
1618
image[:] = (0.055, 0.06, 0.07)
@@ -53,6 +55,19 @@ def render(path, output_directory=None, image_format='png'):
5355
print(output)
5456

5557

58+
def capture_atlas(path, mesh):
59+
# Legacy captures use a same-stem atlas; new runs share only within this directory.
60+
name = mesh.get('atlas_file')
61+
if name is None:
62+
return path.with_suffix('.rgba')
63+
if not isinstance(name, str) or not name or '/' in name or '\\' in name or ':' in name or Path(name).name != name:
64+
raise ValueError('Capture atlas must be a local filename')
65+
atlas = path.parent / name
66+
if atlas.suffix != '.rgba' or atlas.is_symlink() or atlas.resolve().parent != path.parent.resolve():
67+
raise ValueError('Capture atlas escapes capture directory')
68+
return atlas
69+
70+
5671
if __name__ == '__main__':
5772
parser = argparse.ArgumentParser(
5873
description=__doc__,
@@ -67,14 +82,26 @@ def render(path, output_directory=None, image_format='png'):
6782
args = parser.parse_args()
6883
if args.documentation and (not args.output_directory or args.format != 'webp'):
6984
parser.error('--documentation requires --output-directory and --format webp')
70-
captures = [path for path in sorted(args.directory.glob(args.pattern))
71-
if path.with_suffix('.rgba').exists()]
85+
captures = []
86+
skipped = 0
87+
for path in sorted(args.directory.glob(args.pattern)):
88+
try:
89+
mesh = json.loads(path.read_text(encoding='utf-8'))
90+
if 'lists' in mesh and capture_atlas(path, mesh).exists():
91+
captures.append(path)
92+
except (OSError, ValueError, TypeError) as error:
93+
print(f'Skipping {path.name}: {error}', file=sys.stderr)
94+
skipped += 1
7295
if not captures:
7396
parser.error('No matching mesh/atlas pairs found')
7497
if args.output_directory:
7598
args.output_directory.mkdir(parents=True, exist_ok=True)
7699
for path in captures:
77-
render(path, args.output_directory, args.format)
100+
try:
101+
render(path, args.output_directory, args.format)
102+
except (OSError, ValueError, KeyError, TypeError) as error:
103+
print(f'Skipping {path.name}: {error}', file=sys.stderr)
104+
skipped += 1
78105
if args.documentation:
79106
# Crops select complete control groups from the production menu, with
80107
# synthetic activity summaries excluded. No game image is synthesized.
@@ -106,3 +133,5 @@ def render(path, output_directory=None, image_format='png'):
106133
with Image.open(args.output_directory / (stem + '.webp')) as original:
107134
sheet.paste(original.crop((0, 174, 650, 742)), (x, y + 42))
108135
sheet.save(args.output_directory / ('themes' + suffix + '.webp'), lossless=True, method=6)
136+
if skipped:
137+
sys.exit(1)

‎tests/run-fg-lifecycle-tests.ps1‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ $OutputDirectory = Initialize-TestOutput $OutputDirectory
1616

1717
$ErrorActionPreference = 'Stop'
1818
$renodx = $HostRoot
19-
$OutputDirectory = [IO.Path]::GetFullPath($OutputDirectory)
20-
if ((Test-Path -LiteralPath $OutputDirectory) -and
21-
(Get-ChildItem -LiteralPath $OutputDirectory -Force | Select-Object -First 1)) {
22-
throw "Refusing nonempty output directory: $OutputDirectory"
23-
}
24-
New-Item -ItemType Directory -Path $OutputDirectory -Force | Out-Null
2519
Write-Host "Lifecycle artifacts: $OutputDirectory"
2620
$inputs = @('fg_lifecycle_sdk.cpp', 'fg_lifecycle_fixture.cpp', 'fg_lifecycle_tests.cpp', 'run-fg-lifecycle-tests.ps1') |
2721
ForEach-Object { Join-Path $PSScriptRoot $_ }
@@ -50,6 +44,7 @@ try {
5044
"/Fe$($target.binary)", '/sourceDependencies', ($target.source + '.dependencies.json'),
5145
'/link', '/INCREMENTAL:NO', '/OPT:NOICF') + $libraries
5246
$arguments | ConvertTo-Json | Set-Content -LiteralPath ($target.source + '.arguments.json') -Encoding utf8
47+
Register-TestCompilerOutput -Directory $OutputDirectory -ObjectPath (Join-Path $OutputDirectory ($target.source + '.obj')) -ExecutablePath (Join-Path $OutputDirectory $target.binary)
5348
& cl.exe @arguments *> ($target.source + '.compile.log')
5449
if ($LASTEXITCODE -ne 0) {
5550
Get-Content -LiteralPath ($target.source + '.compile.log') -Tail 50
@@ -93,3 +88,4 @@ try {
9388
} finally {
9489
Pop-Location
9590
}
91+
Complete-TestOutput $OutputDirectory -Outcome Passed

‎tests/run-package-tests.ps1‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,4 +259,5 @@ try {
259259
Assert-Test (-not (Test-Path -LiteralPath $taskNegative.OutputDirectory)) 'Missing/empty guide left package output.'
260260
} finally { $taskPackage = $taskOriginalPackage }
261261

262+
Complete-TestOutput $taskOutput
262263
[pscustomobject]@{ TestsPassed = $taskPassed; ArchivePath = $taskResult.ArchivePath; OutputDirectory = $taskOutput }

‎tests/run-present-hdr-runtime-constants-tests.ps1‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ try {
6363
'/bigobj', '/utf-8', '/DNOMINMAX', '/DNDEBUG', '/DRESHADE_ADDON=2') +
6464
@($includes | ForEach-Object { "/I$_" }) +
6565
@('/c', $testSource, "/Fo$objectPath", '/sourceDependencies', $dependencyLog)
66+
Register-TestCompilerOutput -Directory $OutputDirectory -ObjectPath $objectPath -ExecutablePath $executable
6667
& cl.exe @compileArguments *> $compileLog
6768
$compileExitCode = $LASTEXITCODE
6869
Add-RunLine "compile_exit_code=$compileExitCode"
@@ -109,3 +110,4 @@ try {
109110
Add-RunLine "error=$($_.Exception.Message)"
110111
throw
111112
}
113+
Complete-TestOutput $OutputDirectory -Outcome Passed

‎tests/run-present-restore-configuration-tests.ps1‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ try {
103103
"/DCONFIG_TEST_SCOPE_SAVE=$ScopeSaveFunction") +
104104
@($includes | ForEach-Object { "/I$_" }) +
105105
@('/c', $testSource, "/Fo$objectPath", '/sourceDependencies', $dependencyLog)
106+
Register-TestCompilerOutput -Directory $OutputDirectory -ObjectPath $objectPath -ExecutablePath $executable
106107
& cl.exe @compileArguments *> $compileLog
107108
$compileExitCode = $LASTEXITCODE
108109
Add-RunLine "compile_exit_code=$compileExitCode"
@@ -199,3 +200,4 @@ try {
199200
Add-RunLine "error=$($_.Exception.Message)"
200201
throw
201202
}
203+
Complete-TestOutput $OutputDirectory -Outcome Passed

‎tests/run-preset-dialog-tests.ps1‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ foreach ($inputPath in $inputs) {
1818
$hashes[$inputPath] = (Get-FileHash -LiteralPath $inputPath -Algorithm SHA256).Hash
1919
}
2020
$hashes | ConvertTo-Json | Set-Content -LiteralPath (Join-Path $OutputDirectory 'input-hashes.json') -Encoding utf8
21+
Register-TestCompilerOutput -Directory $OutputDirectory -ObjectPath $object -ExecutablePath $executable
2122
& cl.exe /nologo /std:c++20 /EHsc /W4 /WX /MT /O2 /utf-8 /DNOMINMAX /DWIN32_LEAN_AND_MEAN "/I$sourceRoot" $testSource "/Fo$object" "/Fe$executable" /link ole32.lib shell32.lib uuid.lib *> $compileLog
2223
if ($LASTEXITCODE -ne 0) {
2324
Get-Content -LiteralPath $compileLog
@@ -30,3 +31,4 @@ foreach ($inputPath in $inputs) {
3031
}
3132
}
3233
Write-Host "Preset dialog tests passed: $OutputDirectory"
34+
Complete-TestOutput $OutputDirectory -Outcome Passed

‎tests/run-preset-store-tests.ps1‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ foreach ($kind in @('exe', 'dll')) {
106106
$arguments += "/Fe$executable"
107107
}
108108
$arguments | ConvertTo-Json | Set-Content -LiteralPath "$OutputDirectory/$kind-arguments.json" -Encoding utf8
109+
$binary = if ($kind -eq 'dll') { $module } else { $executable }
110+
Register-TestCompilerOutput -Directory $OutputDirectory -ObjectPath (Join-Path $OutputDirectory "$kind.obj") -ExecutablePath $binary
109111
& cl.exe @arguments *> "$OutputDirectory/$kind-compile.log"
110112
if ($LASTEXITCODE -ne 0) { throw "Preset $kind build failed; see $OutputDirectory/$kind-compile.log" }
111113
}
@@ -156,3 +158,4 @@ try {
156158
}
157159
}
158160
Write-Host "Preset store outputs: $OutputDirectory"
161+
Complete-TestOutput $OutputDirectory -Outcome Passed

‎tests/run-profile-store-tests.ps1‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ $arguments = @('/nologo', '/std:c++20', '/EHsc', '/W4', '/WX', '/O2', '/MT', '/u
1919
'/DNOMINMAX', '/DWIN32_LEAN_AND_MEAN', "/I$SourceRoot", "/I$HostRoot/external/json/include",
2020
$source, "/Fo$OutputDirectory/tests.obj", "/Fe$executable", '/sourceDependencies', "$OutputDirectory/dependencies.json")
2121
$arguments | ConvertTo-Json | Set-Content -LiteralPath "$OutputDirectory/arguments.json" -Encoding utf8
22+
Register-TestCompilerOutput -Directory $OutputDirectory -ObjectPath (Join-Path $OutputDirectory 'tests.obj') -ExecutablePath $executable
2223
& cl.exe @arguments *> "$OutputDirectory/compile.log"
2324
if ($LASTEXITCODE -ne 0) { throw "Profile store build failed; see $OutputDirectory/compile.log" }
2425
$dependencies = (Get-Content -LiteralPath "$OutputDirectory/dependencies.json" -Raw | ConvertFrom-Json).Data.Includes
@@ -49,3 +50,4 @@ try {
4950
}
5051
}
5152
Write-Host "Profile store evidence retained: $OutputDirectory"
53+
Complete-TestOutput $OutputDirectory -Outcome Passed

‎tests/run-report-privacy-tests.ps1‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ $exe = Join-Path $OutputDirectory 'report_privacy_tests.exe'
1313
$arguments = @('/nologo', '/std:c++20', '/EHsc', '/W4', '/O2', '/MT', '/utf-8',
1414
'/DNOMINMAX', '/DWIN32_LEAN_AND_MEAN', "/I$HostRoot/external/json/include",
1515
(Join-Path $PSScriptRoot 'report_privacy_tests.cpp'), "/Fo$OutputDirectory/report_privacy_tests.obj", "/Fe$exe")
16+
Register-TestCompilerOutput -Directory $OutputDirectory -ObjectPath (Join-Path $OutputDirectory 'report_privacy_tests.obj') -ExecutablePath $exe
1617
& cl.exe @arguments *> (Join-Path $OutputDirectory 'compile.log')
1718
if ($LASTEXITCODE -ne 0) { throw "Privacy test build failed; see $OutputDirectory/compile.log" }
1819
$data = New-Item -ItemType Directory -Path (Join-Path $OutputDirectory 'data')
@@ -31,3 +32,4 @@ try {
3132
}
3233
} finally { $archive.Dispose() }
3334
Write-Host "ZIP independently read; outputs: $OutputDirectory"
35+
Complete-TestOutput $OutputDirectory -Outcome Passed

‎tests/run-report-tests.ps1‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ foreach ($name in $sources) {
4242
$arguments += @((Join-Path $PSScriptRoot "$name.cpp"), "/Fo$directory/$name.obj", "/Fe$exe",
4343
'/sourceDependencies', "$directory/dependencies.json", '/link','/OPT:REF','/OPT:ICF') + $libraries
4444
$arguments | ConvertTo-Json | Set-Content -LiteralPath "$directory/arguments.json" -Encoding utf8
45+
Register-TestCompilerOutput -Directory $OutputDirectory -ObjectPath (Join-Path $directory.FullName "$name.obj") -ExecutablePath $exe
4546
& cl.exe @arguments *> "$directory/compile.log"
4647
if ($LASTEXITCODE -ne 0) {
4748
Get-Content "$directory/compile.log" -Tail 45
@@ -139,3 +140,4 @@ if ($sources -contains 'report_upload_tests') {
139140
throw 'Upload test source missing; complete report suite cannot be verified.'
140141
}
141142
Write-Host "Report issue, privacy, flow and loopback upload suite passed. Outputs: $OutputDirectory"
143+
Complete-TestOutput $OutputDirectory -Outcome Passed

0 commit comments

Comments
 (0)