chore: baseline md-preview 1.4.2 + agent workspace

This commit is contained in:
2026-10-21 16:06:27 +08:00
commit f63aff47a8
30 changed files with 15085 additions and 0 deletions

64
agent/tests/smoke.ps1 Normal file
View File

@@ -0,0 +1,64 @@
#requires -Version 5.1
<#
MD Preview 冒烟测试
cargo test + 关联检查 + 可选隔离启动(不污染真实 %LOCALAPPDATA%)
#>
[CmdletBinding()]
param(
[string]$Exe = 'D:\Scripts\md-preview\MD-Preview-windows-x64.exe',
[switch]$Launch
)
$ErrorActionPreference = 'Stop'
$repoRoot = (Resolve-Path (Join-Path $PSScriptRoot '..\..')).Path
Set-Location $repoRoot
$cargo = Join-Path $env:USERPROFILE '.cargo\bin\cargo.exe'
if (-not (Test-Path $cargo)) { $cargo = (Get-Command cargo -ErrorAction Stop).Source }
if (-not (Test-Path $Exe)) { throw ('missing exe: ' + $Exe + ' (先运行 agent/scripts/build.ps1)') }
Write-Host '==> cargo test' -ForegroundColor Cyan
& $cargo test
if ($LASTEXITCODE -ne 0) { throw 'cargo test failed' }
Write-Host '==> --help' -ForegroundColor Cyan
$help = (& $Exe --help 2>&1 | Out-String)
if ($help -match 'MD Preview') {
Write-Host ' OK'
} else {
Write-Warning '--help 无输出(GUI 子系统在部分终端下不回显,可忽略)'
}
Write-Host '==> registry association' -ForegroundColor Cyan
$reg = Get-ItemProperty 'HKCU:\Software\Classes\MDPreview.md\shell\open\command' -ErrorAction SilentlyContinue
$expected = '"' + $Exe + '" "%1"'
if ($null -eq $reg) {
Write-Warning 'ProgID 未注册(先运行一次 exe)'
} elseif ($reg.'(default)' -ne $expected) {
Write-Warning ('ProgID 指向不一致: ' + $reg.'(default)')
} else {
Write-Host ' OK'
}
if ($Launch) {
Write-Host '==> launch with isolated config' -ForegroundColor Cyan
$config = Join-Path $env:TEMP ('mdp-smoke-' + [guid]::NewGuid().ToString('N'))
New-Item -ItemType Directory -Path $config | Out-Null
$fixture = Join-Path $PSScriptRoot 'fixtures\long-headings.md'
$env:MD_PREVIEW_CONFIG_DIR = $config
try {
$proc = Start-Process -FilePath $Exe -ArgumentList @($fixture) -PassThru
Start-Sleep -Seconds 3
if ($proc.HasExited) { throw ('process exited early: ' + $proc.ExitCode) }
Write-Host ' running - OK'
$proc.CloseMainWindow() | Out-Null
if (-not $proc.WaitForExit(5000)) { $proc.Kill() }
Write-Host ' exit - OK'
} finally {
Remove-Item Env:\MD_PREVIEW_CONFIG_DIR -ErrorAction SilentlyContinue
Remove-Item -Recurse -Force $config -ErrorAction SilentlyContinue
}
}
Write-Host 'SMOKE OK' -ForegroundColor Green