Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ REGRESS-RESULT {"pass":true,"summary":"到登录页 41 秒;进游戏后 52.7 f
| 项 | 脚本 | 说明 |
| --- | --- | --- |
| ime-pkg | `items\ime-pkg.ps1` | `-Package <组包目录>`(`release\ModAVD-<版本>-win-x64`,只读):按包根清单装进 `PackageRoot`、新建 9 号临时实例,核对正式签名的输入法开机自动装好、设为默认,带窗口跑通道 20 项,再核对开发签名的换成正式签名、稳态不变;跑完删临时实例,根目录停在这个包上,日志留在 `-Work` 下 |
| fetch | `items\fetch.ps1` | `-Package <组包目录>`(只读):搭两个只够补全组件用的新根目录,一个跑 `tools\modavd.exe components fetch`,一个用重定向的输入跑「补全组件.bat」(新版先选下载源,回车是自动;再同意许可协议),两样都要装好,再跑一次 `fetch` 都算齐全;新版批处理还要把下载源记成 `auto`。只有取许可协议清单要联网,`-Cache`(本机配置 `ComponentCache`)给了放着两个 zip 的目录时不下载,没给时命令行那遍下载一次、批处理那遍用它留下的 zip;不开模拟器;根目录跑完删掉 |
| fetch | `items\fetch.ps1` | `-Package <组包目录>`(只读):搭只够补全组件用的新根目录,跑 `tools\modavd.exe components fetch`;包根还有「补全组件.bat」的(0.38.1 及更早)再另搭一个,用重定向的输入跑它(同意许可协议)。都要装好,再跑一次 `fetch` 都算齐全。跑的时候 `LOCALAPPDATA` 指到工作目录里的空目录,不读写本机记住的下载源(管理器 0.5.0 起)。只有取许可协议清单要联网,`-Cache`(本机配置 `ComponentCache`)给了放着两个 zip 的目录时不下载,没给时命令行那遍下载一次、批处理那遍用它留下的 zip;不开模拟器;根目录跑完删掉 |

## 以后有了专门跑测试的机器

Expand Down
95 changes: 50 additions & 45 deletions items/fetch.ps1
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# 打完包补跑:用组包目录搭新的根目录,从空补全组件(adb 和系统镜像),命令行和「补全组件.bat」两条路各一遍。
# 打完包补跑:用组包目录搭新的根目录,从空补全组件(adb 和系统镜像)。
# 0.37.0–0.38.0 的「补全组件.bat」装系统镜像必然失败,回归一直没测出来:别的项都把组件链到官方 SDK,不走补全组件。
# - 命令行:tools\modavd.exe components fetch --accept-license --keep-downloads --json,两样都装好、都是这次下的。
# - 批处理:另搭一个根目录,把上一步下好的两个 zip 放进 downloads\(不重下 1.5 GB),用重定向的输入跑「补全组件.bat」:
# 新的批处理(tools\ 里有 components-sources.txt,0.38.1 起)先问下载源,回车选自动;再同意许可协议,结尾 pause 也喂一个回车。
# 老的批处理(调 fetch-components.ps1)只问许可协议。退出码 0,下载源记成 auto(新的批处理才有)。
# - 两个根目录最后都再跑一次 components fetch:两样都算齐全、跳过(「齐全」按 fetch 的严格规则,不是 status 的宽松规则)。
# - 批处理:只有包根还有「补全组件.bat」时才跑(0.38.1 及更早;0.39 起包里没有批处理,补全组件在管理器和命令行里,
# ModAVD/ModAVD#119)。另搭一个根目录,把上一步下好的两个 zip 放进 downloads\(不重下 1.5 GB),用重定向的输入跑它:
# 它调 fetch-components.ps1,只问许可协议,结尾 pause 也喂一个回车,退出码 0。
# - 各个根目录最后都再跑一次 components fetch:两样都算齐全、跳过(「齐全」按 fetch 的严格规则,不是 status 的宽松规则)。
# 管理器 0.5.0 起按 Windows 用户记住下载源(%LOCALAPPDATA%\ModAVD\components-settings.json):跑的时候 LOCALAPPDATA
# 指到工作目录里的空目录,不读也不写本机真的设置,下载源照默认(自动)。
# 只有取许可协议清单要联网;-Cache 给了放着这两个 zip 的目录时,命令行那一步也不下载。
# 根目录只放补全组件用得到的:包根的批处理、tools\、sdk\emulator 里的 emulator.exe 和 source.properties。跑完删掉(-Keep 留着)。
# 不开模拟器,不起 adb server。
# 根目录只放补全组件用得到的:包根的批处理(有的话)、tools\、sdk\emulator 里的 emulator.exe 和 source.properties。
# 跑完删掉(-Keep 留着)。不开模拟器,不起 adb server。
param(
# 组包目录(release\ModAVD-<版本>-win-x64,只读)
[Parameter(Mandatory)][string]$Package,
Expand All @@ -25,10 +27,11 @@ if (-not $Work) { $Work = Join-Path (Use-Local TempRoot $null '-Work') 'regress-
$Work = [IO.Path]::GetFullPath($Work)
Assert-NotProduction $Work '工作目录'
$Package = (Resolve-Path -LiteralPath $Package).Path
$fetchBat = Join-Path $Package '补全组件.bat'
if (-not (Test-Path -LiteralPath (Join-Path $Package 'tools\modavd.exe')) -or -not (Test-Path -LiteralPath $fetchBat)) {
throw "不是组包目录(要有 tools\modavd.exe 和「补全组件.bat」):$Package"
if (-not (Test-Path -LiteralPath (Join-Path $Package 'tools\modavd.exe'))) {
throw "不是组包目录(要有 tools\modavd.exe):$Package"
}
# 0.38.1 及更早的包才有批处理
$hasBat = Test-Path -LiteralPath (Join-Path $Package '补全组件.bat')
if (Test-Path -LiteralPath $Work) { throw "-Work 要是不存在的新目录:$Work" }
$zips = @('platform-tools_r37.0.1-win.zip', 'x86_64-34_r14.zip')
$problems = @()
Expand Down Expand Up @@ -58,9 +61,13 @@ function Test-Complete([string]$Dir, [string]$Label) {
}

$made = $false
$savedLocalAppData = $env:LOCALAPPDATA
try {
New-Item -ItemType Directory -Path $Work | Out-Null
$made = $true
# 记住的下载源按 Windows 用户存:指到空目录,命令行和批处理(它的子进程继承环境)都读不到、也写不进本机真的设置
$env:LOCALAPPDATA = Join-Path $Work 'localappdata'
New-Item -ItemType Directory -Force $env:LOCALAPPDATA | Out-Null

# 1. 命令行
$cliRoot = Join-Path $Work 'cli'
Expand All @@ -86,48 +93,46 @@ try {
Say " $($notes[-1])"
}

# 2. 批处理:zip 用上一步留下的(或缓存的)
$batRoot = Join-Path $Work 'bat'
New-FetchRoot $batRoot
$from = if ($Cache) { $Cache } else { Join-Path $cliRoot 'downloads' }
$have = @($zips | Where-Object { Test-Path -LiteralPath (Join-Path $from $_) })
if ($have.Count -eq $zips.Count) {
New-Item -ItemType Directory -Force (Join-Path $batRoot 'downloads') | Out-Null
foreach ($z in $zips) { Copy-Item -LiteralPath (Join-Path $from $z) -Destination (Join-Path $batRoot 'downloads') }
# 2. 批处理(只有 0.38.1 及更早的包有):zip 用上一步留下的(或缓存的)
if (-not $hasBat) {
$notes += '包里没有「补全组件.bat」(0.39 起),只跑了命令行这一遍'
} else {
$notes += '批处理那遍要从网上下载(命令行那遍没留下 zip)'
}
$newBat = Test-Path -LiteralPath (Join-Path $batRoot 'tools\components-sources.txt')
# 新的:下载源(回车 = 自动)、许可协议、pause;老的:许可协议、pause
$answers = if ($newBat) { "`r`ny`r`n`r`n" } else { "y`r`n`r`n" }
$inFile = Join-Path $Work 'bat-input.txt'
[IO.File]::WriteAllText($inFile, $answers, [Text.Encoding]::ASCII)
$batLog = Join-Path $Work 'bat-output.txt'
Say "批处理:「补全组件.bat」($(if ($newBat) { '调命令行的新版' } else { '调 PowerShell 脚本的老版' }))"
$t0 = Get-Date
$p = Start-Process -FilePath (Join-Path $env:WINDIR 'System32\cmd.exe') -ArgumentList ('/d /c ""' + (Join-Path $batRoot '补全组件.bat') + '""') `
-WorkingDirectory $batRoot -RedirectStandardInput $inFile -RedirectStandardOutput $batLog `
-RedirectStandardError (Join-Path $Work 'bat-stderr.txt') -WindowStyle Hidden -PassThru
if (-not $p.WaitForExit(30 * 60 * 1000)) {
# 只结束自己起的这个 cmd 和它的子进程
& taskkill.exe /PID $p.Id /T /F 2>&1 | Out-Null
$problems += '批处理 30 分钟没结束,结束了它'
} elseif ($p.ExitCode -ne 0) {
$tail = @(Get-Content -LiteralPath $batLog -Encoding utf8 -ErrorAction SilentlyContinue | Where-Object { $_ -match '失败|原因|错误' } | Select-Object -Last 2) -join ' / '
$problems += "批处理补全组件失败(退出码 $($p.ExitCode)):$tail"
} else {
$notes += "批处理 $([int]((Get-Date) - $t0).TotalSeconds) 秒装好"
Test-Complete $batRoot '批处理'
if ($newBat) {
$src = Join-Path $batRoot 'downloads\source.txt'
$saved = if (Test-Path -LiteralPath $src) { (Get-Content -LiteralPath $src -Raw).Trim() } else { '' }
if ($saved -ne 'auto') { $problems += "批处理:downloads\source.txt 是「$saved」,应当记成 auto" }
$batRoot = Join-Path $Work 'bat'
New-FetchRoot $batRoot
$from = if ($Cache) { $Cache } else { Join-Path $cliRoot 'downloads' }
$have = @($zips | Where-Object { Test-Path -LiteralPath (Join-Path $from $_) })
if ($have.Count -eq $zips.Count) {
New-Item -ItemType Directory -Force (Join-Path $batRoot 'downloads') | Out-Null
foreach ($z in $zips) { Copy-Item -LiteralPath (Join-Path $from $z) -Destination (Join-Path $batRoot 'downloads') }
} else {
$notes += '批处理那遍要从网上下载(命令行那遍没留下 zip)'
}
# 调 fetch-components.ps1 的批处理:许可协议、pause
$inFile = Join-Path $Work 'bat-input.txt'
[IO.File]::WriteAllText($inFile, "y`r`n`r`n", [Text.Encoding]::ASCII)
$batLog = Join-Path $Work 'bat-output.txt'
Say '批处理:「补全组件.bat」'
$t0 = Get-Date
$p = Start-Process -FilePath (Join-Path $env:WINDIR 'System32\cmd.exe') -ArgumentList ('/d /c ""' + (Join-Path $batRoot '补全组件.bat') + '""') `
-WorkingDirectory $batRoot -RedirectStandardInput $inFile -RedirectStandardOutput $batLog `
-RedirectStandardError (Join-Path $Work 'bat-stderr.txt') -WindowStyle Hidden -PassThru
if (-not $p.WaitForExit(30 * 60 * 1000)) {
# 只结束自己起的这个 cmd 和它的子进程
& taskkill.exe /PID $p.Id /T /F 2>&1 | Out-Null
$problems += '批处理 30 分钟没结束,结束了它'
} elseif ($p.ExitCode -ne 0) {
$tail = @(Get-Content -LiteralPath $batLog -Encoding utf8 -ErrorAction SilentlyContinue | Where-Object { $_ -match '失败|原因|错误' } | Select-Object -Last 2) -join ' / '
$problems += "批处理补全组件失败(退出码 $($p.ExitCode)):$tail"
} else {
$notes += "批处理 $([int]((Get-Date) - $t0).TotalSeconds) 秒装好"
Test-Complete $batRoot '批处理'
}
}
if ($notes) { Say " $($notes[-1])" }
} catch {
$problems += "出错:$($_.Exception.Message)"
} finally {
$env:LOCALAPPDATA = $savedLocalAppData
if ($made -and -not $Keep) {
for ($k = 0; $k -lt 10 -and (Test-Path -LiteralPath $Work); $k++) {
try { Remove-Item -LiteralPath $Work -Recurse -Force -ErrorAction Stop } catch { Start-Sleep 2 }
Expand Down