From cb360dcd7444d23c379116d128bbf9d47300be01 Mon Sep 17 00:00:00 2001 From: luckyteagirl <290248872+luckyteagirl@users.noreply.github.com> Date: Wed, 25 Nov 2026 21:07:53 -0800 Subject: [PATCH] Scripts: mark untracked crate inputs in smoke reports --- scripts/smoke.ps1 | 2 +- scripts/test-smoke-dirty.tests.ps1 | 39 ++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 scripts/test-smoke-dirty.tests.ps1 diff --git a/scripts/smoke.ps1 b/scripts/smoke.ps1 index db296218b2..62becaf228 100644 --- a/scripts/smoke.ps1 +++ b/scripts/smoke.ps1 @@ -32,7 +32,7 @@ if ($PSBoundParameters.ContainsKey('Title')) { if (-not (Test-Path $Xcl)) { throw "no $Xcl - build it first (cargo build --release -p xcl)" } $root = Split-Path $PSScriptRoot -Parent $commit = (git -C $root rev-parse HEAD).Trim() -$dirty = [bool](git -C $root status --porcelain --untracked-files=no -- crates Cargo.toml Cargo.lock) +$dirty = [bool](git -C $root status --porcelain --untracked-files=normal -- crates Cargo.toml Cargo.lock) # Use ProcessStartInfo instead of Start-Process: the latter cannot build its # environment block on Windows PowerShell 5.1 when PATH is present twice with diff --git a/scripts/test-smoke-dirty.tests.ps1 b/scripts/test-smoke-dirty.tests.ps1 new file mode 100644 index 0000000000..6573fa6d71 --- /dev/null +++ b/scripts/test-smoke-dirty.tests.ps1 @@ -0,0 +1,39 @@ +# Run with powershell.exe or pwsh.exe. Tests the smoke block's build-input dirty marker. +$ErrorActionPreference = 'Stop' +$temp = (Resolve-Path -LiteralPath ([IO.Path]::GetTempPath())).Path +$fixture = Join-Path $temp ('xcl-smoke-dirty-' + [guid]::NewGuid()) +$paths = @('scripts', 'crates', 'target') +foreach ($path in $paths) { $null = New-Item -ItemType Directory -Path (Join-Path $fixture $path) -Force } +try { + $runner = Join-Path $fixture 'scripts\smoke.ps1' + Copy-Item -LiteralPath (Join-Path $PSScriptRoot 'smoke.ps1') -Destination $runner + $xcl = Join-Path $fixture 'xcl.cmd' + [IO.File]::WriteAllText($xcl, "@echo off`r`necho Log: %~dp0xcl.log`r`n") + [IO.File]::WriteAllText((Join-Path $fixture 'xcl.log'), "(1 frames shown, 1 PresentX calls)`n") + [IO.File]::WriteAllText((Join-Path $fixture 'report.json'), '{"d3d12":{"adapter":"Fixture GPU"}}') + [IO.File]::WriteAllText((Join-Path $fixture '.gitignore'), "ignored.rs`n") + + git -C $fixture init --quiet + if ($LASTEXITCODE -ne 0) { throw 'Could not initialize the fixture repository.' } + git -C $fixture -c core.autocrlf=false add .gitignore + if ($LASTEXITCODE -ne 0) { throw 'Could not stage the fixture ignore rules.' } + git -C $fixture -c user.name=Fixture -c user.email=fixture@example.invalid -c commit.gpgsign=false commit --quiet -m 'Fixture' + if ($LASTEXITCODE -ne 0) { throw 'Could not commit the fixture ignore rules.' } + $head = git -C $fixture rev-parse HEAD + + function Get-SmokeCommit { + $block = & $runner -Game (Join-Path $fixture 'Game') -Xcl $xcl -Seconds 1 -Title 'Fixture' + $block -split "`n" | Where-Object { $_ -like 'commit:*' } | ForEach-Object { $_.Trim() } + } + + [IO.File]::WriteAllText((Join-Path $fixture 'crates\ignored.rs'), '') + [IO.File]::WriteAllText((Join-Path $fixture 'target\build.txt'), '') + if ((Get-SmokeCommit) -ne "commit: $head") { throw 'Ignored or out-of-scope files made the smoke block dirty.' } + + [IO.File]::WriteAllText((Join-Path $fixture 'crates\local.rs'), '') + if ((Get-SmokeCommit) -ne "commit: $head (uncommitted changes)") { throw 'An untracked crate file did not mark the smoke block dirty.' } + 'smoke-dirty: ok' +} finally { + $resolved = (Resolve-Path -LiteralPath $fixture).Path + if ((Split-Path -Parent $resolved) -eq $temp) { Remove-Item -LiteralPath $resolved -Recurse -Force } +}