WIP 시험 임시 폴더 검사: 실행마다 %TEMP%\t_jjrun_<표> 로 TEMP · TMP 를 돌려 그 안만 셈 - 다른 세션 시험과 섞여 거짓 실패하던 것 · 앱 코드가 남긴 것도 잡음 · 도우미가 표 밖에 생기면 실패 · Edge 데이터 폴더 (앱이 끝날 때까지 잡힘) 는 jj_held_ 로 보이기만 하고 함께 지움 (관리자 지시 10/20, 검토 대기)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tmptag
RyuJongJin 2026-10-20 12:39:46 +09:00
parent 8cce03d99c
commit 84863c1569
8 changed files with 67 additions and 49 deletions

View File

@ -28,7 +28,7 @@ void main() {
await req.response.close(); await req.response.close();
}); });
final url = 'http://127.0.0.1:${server.port}/page'; final url = 'http://127.0.0.1:${server.port}/page';
final dataDir = testTempDir('jj_keep_').path; final dataDir = testTempDir('jj_keep_', heldByApp: true).path;
final c = AppController(PlatformServices(mediaTool: ProcessMediaTool('x', 'y'), storage: DesktopStorageService())); final c = AppController(PlatformServices(mediaTool: ProcessMediaTool('x', 'y'), storage: DesktopStorageService()));
c.settings c.settings

View File

@ -32,7 +32,7 @@ void main() {
await req.response.close(); await req.response.close();
}); });
final url = 'http://127.0.0.1:${server.port}/'; final url = 'http://127.0.0.1:${server.port}/';
final dataDir = testTempDir('jj_webview_').path; final dataDir = testTempDir('jj_webview_', heldByApp: true).path;
final c = AppController(PlatformServices(mediaTool: ProcessMediaTool('x', 'y'), storage: DesktopStorageService())); final c = AppController(PlatformServices(mediaTool: ProcessMediaTool('x', 'y'), storage: DesktopStorageService()));
c.settings.webViewDataDir = dataDir; c.settings.webViewDataDir = dataDir;

View File

@ -25,7 +25,8 @@ void main() {
for (var i = 0; i < 8; i++) { for (var i = 0; i < 8; i++) {
ComGuard.releaseForTest(); ComGuard.releaseForTest();
} }
final dir = testTempDir('jj_com_').path; // Edge 가 앱이 끝날 때까지 사용자 데이터 폴더를 잡는다 (test_temp_check 가 찾음, 관리자 지시 10/20)
final dir = testTempDir('jj_com_', heldByApp: true).path;
final raw = await tester.runAsync<Object?>(() async { final raw = await tester.runAsync<Object?>(() async {
try { try {
await WebViewEnvironment.create(settings: WebViewEnvironmentSettings(userDataFolder: '${dir}_raw')); await WebViewEnvironment.create(settings: WebViewEnvironmentSettings(userDataFolder: '${dir}_raw'));

View File

@ -4,13 +4,25 @@ import 'package:flutter_test/flutter_test.dart';
/// 관리자 지시 (10/19, 28 이 찾음): 통합 시험 · 캡처가 %TEMP%\jj_* 시험 폴더를 남겼다 - 시험 끝 (실패해도) 에 지운다. /// 관리자 지시 (10/19, 28 이 찾음): 통합 시험 · 캡처가 %TEMP%\jj_* 시험 폴더를 남겼다 - 시험 끝 (실패해도) 에 지운다.
/// [base] 가 있으면 그 아래 (짧은 경로가 필요한 캡처). 반드시 시험 (testWidgets · test) 안에서 부른다 (addTearDown). /// [base] 가 있으면 그 아래 (짧은 경로가 필요한 캡처). 반드시 시험 (testWidgets · test) 안에서 부른다 (addTearDown).
Directory testTempDir(String prefix, {String? base}) { /// [heldByApp]: 앱이 끝날 때까지 놓지 않는 폴더 (Edge 사용자 데이터 - Windows 판 플러그인에는 환경 닫기가 없다).
/// 이름 앞에 jj_held_ 를 붙이고, tool/test_temp_check.ps1 은 이것을 실패로 세지 않고 앱이 끝난 뒤 실행 폴더와 함께 지운다
Directory testTempDir(String prefix, {String? base, bool heldByApp = false}) {
final root = base == null || base.isEmpty ? Directory.systemTemp : (Directory(base)..createSync(recursive: true)); final root = base == null || base.isEmpty ? Directory.systemTemp : (Directory(base)..createSync(recursive: true));
final dir = root.createTempSync(prefix); final dir = root.createTempSync(heldByApp ? 'jj_held_$prefix' : prefix);
addTearDown(() => deleteTestTemp(dir)); addTearDown(() => deleteTestTemp(dir));
if (base == null || base.isEmpty) expectInTaggedTemp(dir);
return dir; return dir;
} }
/// 관리자 지시 (10/20): tool/test_temp_check.ps1 이 TEMP · TMP 를 실행 폴더 (%TEMP%\t_jjrun_<표>) 로 돌리고 표를 JJ_TEST_TMP_TAG 로 넘긴다.
/// 표가 있는데 임시 폴더가 그 밖에 생기면 (환경 변수가 시험 · 앱까지 오지 않음) 다른 세션 시험과 섞이므로 시험을 실패시킨다
void expectInTaggedTemp(Directory dir) {
final tag = Platform.environment['JJ_TEST_TMP_TAG'] ?? '';
if (tag.isEmpty) return;
expect(dir.absolute.path.toLowerCase(), contains('t_jjrun_$tag'.toLowerCase()),
reason: 'TEMP 가 시험 실행 폴더로 오지 않음 (JJ_TEST_TMP_TAG=$tag)');
}
/// 시험 폴더 지우기 - Windows 에서 앱 · WebView · 백신이 파일을 잠깐 잡고 있으면 몇 번 다시 해 본다 (기다림은 실제 시간: 가짜 시계 밖). /// 시험 폴더 지우기 - Windows 에서 앱 · WebView · 백신이 파일을 잠깐 잡고 있으면 몇 번 다시 해 본다 (기다림은 실제 시간: 가짜 시계 밖).
/// 긴 경로는 \\?\ 로. 끝내 못 지우면 알리기만 하고 시험은 실패시키지 않는다 (tool/test_temp_check.ps1 이 남은 것을 잡는다) /// 긴 경로는 \\?\ 로. 끝내 못 지우면 알리기만 하고 시험은 실패시키지 않는다 (tool/test_temp_check.ps1 이 남은 것을 잡는다)
void deleteTestTemp(Directory dir) { void deleteTestTemp(Directory dir) {

View File

@ -43,7 +43,7 @@ void main() {
await c.init(); await c.init();
await c.addVideos([video]); await c.addVideos([video]);
}); });
c.settings.webViewDataDir = testTempDir('jj_webview_').path; c.settings.webViewDataDir = testTempDir('jj_webview_', heldByApp: true).path;
final v = c.videos.single; final v = c.videos.single;
// 같은 폴더의 movie.en.srt 가 자동으로 잡힘 // 같은 폴더의 movie.en.srt 가 자동으로 잡힘
final s = v.subtitles.firstWhere((x) => x.path != null && p.equals(x.path!, en)); final s = v.subtitles.firstWhere((x) => x.path != null && p.equals(x.path!, en));

View File

@ -51,7 +51,7 @@ void main() {
await req.response.close(); await req.response.close();
}); });
final url = 'http://127.0.0.1:${server.port}/'; final url = 'http://127.0.0.1:${server.port}/';
final dataDir = testTempDir('jj_webview_').path; final dataDir = testTempDir('jj_webview_', heldByApp: true).path;
final c = AppController(PlatformServices(mediaTool: ProcessMediaTool('x', 'y'), storage: DesktopStorageService())); final c = AppController(PlatformServices(mediaTool: ProcessMediaTool('x', 'y'), storage: DesktopStorageService()));
c.settings c.settings

View File

@ -10,9 +10,19 @@ final _later = <Directory>[];
Directory tempDirUntilEnd(String prefix) { Directory tempDirUntilEnd(String prefix) {
final d = Directory.systemTemp.createTempSync(prefix); final d = Directory.systemTemp.createTempSync(prefix);
_later.add(d); _later.add(d);
expectInTaggedTemp(d);
return d; return d;
} }
/// 관리자 지시 (10/20): tool/test_temp_check.ps1 이 TEMP · TMP 를 실행 폴더 (%TEMP%\t_jjrun_<표>) 로 돌리고 표를 JJ_TEST_TMP_TAG 로 넘긴다.
/// 표가 있는데 임시 폴더가 그 밖에 생기면 (환경 변수가 시험 · 앱까지 오지 않음) 다른 세션 시험과 섞이므로 시험을 실패시킨다
void expectInTaggedTemp(Directory dir) {
final tag = Platform.environment['JJ_TEST_TMP_TAG'] ?? '';
if (tag.isEmpty) return;
expect(dir.absolute.path.toLowerCase(), contains('t_jjrun_$tag'.toLowerCase()),
reason: 'TEMP 가 시험 실행 폴더로 오지 않음 (JJ_TEST_TMP_TAG=$tag)');
}
/// main() 에서 한 번 부른다: 파일의 시험이 다 끝나면 [tempDirUntilEnd] 로 만든 폴더를 지운다 /// main() 에서 한 번 부른다: 파일의 시험이 다 끝나면 [tempDirUntilEnd] 로 만든 폴더를 지운다
/// (늦게 끝난 저장이 다시 만들 수 있어 잠깐씩 기다리며 몇 번 본다) /// (늦게 끝난 저장이 다시 만들 수 있어 잠깐씩 기다리며 몇 번 본다)
void deleteTempDirsAtEnd() { void deleteTempDirsAtEnd() {

View File

@ -1,66 +1,61 @@
# 전체 시험 + 임시 폴더 흔적 검사 (관리자 지시 10/17): 시험이 %TEMP%\jj_* 폴더를 남기지 않는지. # 전체 시험 + 임시 폴더 흔적 검사 (관리자 지시 10/17): 시험이 임시 폴더 (jj_*) 를 남기지 않는지.
# - 시험 전 · 뒤의 %TEMP% 를 비교해, 새로 남은 폴더 중 이름 앞부분이 시험 소스 (test\*.dart) 의 createTemp('jj…') 와 같은 것만 본다 # - 관리자 지시 (10/20): 실행마다 %TEMP%\t_jjrun_<표> 를 만들고 TEMP · TMP 를 그쪽으로 돌려 flutter test 를 돌린다.
# (앱 · 다른 프로그램이 만든 jj_mkvmaker 등은 세지 않음). 하나라도 남으면 이름을 보이고 실패 (exit 2). # 그 폴더 안만 보므로 다른 worktree · 세션이 같은 %TEMP% 에서 동시에 돌린 시험의 폴더가 섞이지 않는다
# - 시험 파일들은 동시에 돌아 파일마다 스스로 확인할 수 없어 (누가 만든 폴더인지 모름) 전체 실행 앞뒤로 본다. # (예전에는 앞뒤 %TEMP% 를 비교해 다른 세션의 jj_explorer_ · jj_sync_ · jj_fake_recycle_ 가 섞여 거짓 실패).
# - 다른 worktree · 세션이 같은 시험을 동시에 돌리면 그쪽 폴더가 섞일 수 있다 (이름으로 확인). # - 앱 코드 (lib) 가 시험 중에 만든 임시 폴더 (jj_up_ · jj_7z_ 등) 도 같은 곳에 생기므로 함께 잡힌다.
# - 이미 있던 폴더는 건드리지 않는다 (지우지 않음). # - 표는 환경 변수 JJ_TEST_TMP_TAG 로도 시험에 넘긴다: 시험 도우미 (test/support/temp_dirs.dart · integration_test/support/temp_dir.dart)
# 가 임시 폴더가 그 안에 생기는지 확인한다 (통합 시험 -d windows 에서 앱까지 환경 변수가 가는지).
# - 끝나면 남은 jj 폴더의 이름을 보이고 (하나라도 있으면 실패, exit 2) 실행 폴더를 통째로 지운다.
# 사용 (app 폴더에서): powershell -ExecutionPolicy Bypass -File tool\test_temp_check.ps1 [flutter test 인자…] # 사용 (app 폴더에서): powershell -ExecutionPolicy Bypass -File tool\test_temp_check.ps1 [flutter test 인자…]
# 통합 시험 · 캡처도 (관리자 지시 10/19, 28 이 찾음): … test_temp_check.ps1 integration_test\windows_b6_shot_test.dart -d windows # 통합 시험 · 캡처도 (관리자 지시 10/19, 28 이 찾음): … test_temp_check.ps1 integration_test\windows_b6_shot_test.dart -d windows
# - 폴더 이름 앞부분은 test 와 integration_test 두 곳의 시험 소스에서 모은다
$ErrorActionPreference = 'Stop' $ErrorActionPreference = 'Stop'
$app = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path $app = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
$temp = [System.IO.Path]::GetTempPath() $temp = [System.IO.Path]::GetTempPath()
# 시험 소스가 쓰는 임시 폴더 이름 앞부분 (createTemp('jj_x_') · createTempSync('jj_x_')) # 표: 짧게 (긴 경로 시험이 경로 길이에 민감하다) - 이름이 jj 로 시작하지 않게 (예전 판 검사가 이 폴더를 시험 폴더로 세지 않게)
# 넘겨받은 시험 파일 (.dart) 이 있으면 그 파일들과 support 폴더만 본다 - 다른 세션 · worktree 가 같은 때 돌린 시험의 폴더를 세지 않게 $tag = -join ((1..6) | ForEach-Object { '{0:x}' -f (Get-Random -Maximum 16) })
# (10/19: b6 캡처 앞뒤에 다른 세션의 단위 시험 폴더 jj_explorer_ · jj_sync_ 가 섞여 거짓 실패) $run = Join-Path $temp "t_jjrun_$tag"
$named = @($args | Where-Object { "$_" -like '*.dart' } | ForEach-Object { Join-Path $app "$_" } | Where-Object { Test-Path $_ }) New-Item -ItemType Directory -Path $run | Out-Null
$sources = if ($named.Count -gt 0) { $saved = @{ TEMP = $env:TEMP; TMP = $env:TMP; JJ_TEST_TMP_TAG = $env:JJ_TEST_TMP_TAG }
# 그 파일들이 가져다 쓰는 support 파일만 함께 (import 'support/…') - 다른 세션의 시험과 이름이 겹치지 않게 (10/19: jj_fake_recycle_) Write-Host "시험 임시 폴더: $run"
$support = @($named | ForEach-Object {
$dir = Split-Path $_
[regex]::Matches((Get-Content $_ -Raw -Encoding utf8), "import '(support/[^']+\.dart)'") |
ForEach-Object { Join-Path $dir $_.Groups[1].Value } })
@($named) + @($support | Where-Object { Test-Path $_ })
} else {
@(@('test', 'integration_test') | ForEach-Object { Join-Path $app $_ } | Where-Object { Test-Path $_ } |
ForEach-Object { Get-ChildItem $_ -Recurse -Filter *.dart | ForEach-Object { $_.FullName } })
}
# 이름이 하나도 없으면 (임시 폴더를 만들지 않는 시험) 새 jj 폴더는 참고로만 보인다
# 이름 앞부분: createTemp('jj_x_') · createTempSync('jj_x_') · testTempDir('jj_x_') (integration_test/support/temp_dir.dart)
$prefixes = @($sources |
ForEach-Object { [regex]::Matches((Get-Content $_ -Raw -Encoding utf8), '(?:createTemp(?:Sync)?|testTempDir)\(''(jj[^''$]*)''') } |
ForEach-Object { $_.Groups[1].Value } | Sort-Object -Unique)
if ($prefixes.Count -eq 0 -and $named.Count -eq 0) { throw '시험 소스에서 임시 폴더 이름을 찾지 못했습니다' }
function Get-TestTemp { $env:TEMP = $run
@(Get-ChildItem $temp -Directory -Filter 'jj*' -ErrorAction SilentlyContinue | ForEach-Object { $_.Name }) $env:TMP = $run
} $env:JJ_TEST_TMP_TAG = $tag
$before = @{}
foreach ($n in Get-TestTemp) { $before[$n] = $true }
Push-Location $app Push-Location $app
try { try {
flutter test @args flutter test @args
$code = $LASTEXITCODE $code = $LASTEXITCODE
} finally { } finally {
Pop-Location Pop-Location
$env:TEMP = $saved.TEMP
$env:TMP = $saved.TMP
$env:JJ_TEST_TMP_TAG = $saved.JJ_TEST_TMP_TAG
} }
# 시험이 끝난 뒤 지우기가 늦게 끝나는 것 (백신 · 색인) 을 잠깐 기다린다 # 시험이 끝난 뒤 지우기가 늦게 끝나는 것 (백신 · 색인) 을 잠깐 기다린다
Start-Sleep -Seconds 3 Start-Sleep -Seconds 3
$left = @(Get-TestTemp | Where-Object { -not $before.ContainsKey($_) } | Where-Object { $items = @(Get-ChildItem -LiteralPath $run -Force -ErrorAction SilentlyContinue)
$n = $_ # jj_held_ 는 앱이 끝날 때까지 놓지 않는 폴더 (integration_test/support/temp_dir.dart 의 heldByApp - Edge 사용자 데이터) - 보이기만 하고 아래에서 함께 지운다
@($prefixes | Where-Object { $n.StartsWith($_) }).Count -gt 0 $held = @($items | Where-Object { $_.Name -like 'jj_held_*' } | ForEach-Object { $_.Name })
}) $left = @($items | Where-Object { $_.Name -like 'jj*' -and $_.Name -notlike 'jj_held_*' } | ForEach-Object { $_.Name })
# 참고: 시험 소스의 이름이 아닌 새 jj 폴더 (앱 코드가 만든 것일 수 있음 - 실패로 세지 않고 보이기만) # 참고: jj 가 아닌 것 (flutter 도구 · 다른 프로그램이 만든 것 - 실패로 세지 않고 보이기만)
$other = @(Get-TestTemp | Where-Object { -not $before.ContainsKey($_) -and $left -notcontains $_ }) $other = @($items | Where-Object { $_.Name -notlike 'jj*' } | ForEach-Object { $_.Name })
if ($other.Count -gt 0) { if ($other.Count -gt 0) {
Write-Host ("참고 - 시험 소스에 없는 이름의 새 jj 폴더 {0}개:" -f $other.Count) Write-Host ("참고 - jj 가 아닌 남은 것 {0}개:" -f $other.Count)
$other | Sort-Object | ForEach-Object { Write-Host " $_" } $other | Sort-Object | ForEach-Object { Write-Host " $_" }
} }
if ($held.Count -gt 0) {
Write-Host ("참고 - 앱이 끝날 때까지 잡혀 있던 것 {0}개 (실행 폴더와 함께 지움):" -f $held.Count)
$held | Sort-Object | ForEach-Object { Write-Host " $_" }
}
if ($left.Count -gt 0) { if ($left.Count -gt 0) {
Write-Host ("시험이 남긴 임시 폴더 {0}개 (%TEMP%):" -f $left.Count) Write-Host ("시험이 남긴 임시 폴더 {0}개 ({1}):" -f $left.Count, $run)
$left | Sort-Object | ForEach-Object { Write-Host " $_" } $left | Sort-Object | ForEach-Object { Write-Host " $_" }
}
# 실행 폴더는 이 스크립트가 만든 것이라 통째로 지운다 (긴 경로는 \\?\ 로)
cmd /c "rd /s /q `"\\?\$run`"" 2>$null
if (Test-Path -LiteralPath $run) { Write-Host "실행 폴더를 다 지우지 못함: $run" }
if ($left.Count -gt 0) {
if ($code -eq 0) { exit 2 } if ($code -eq 0) { exit 2 }
} else { } else {
Write-Host '임시 폴더 흔적: 새로 남은 것 0' Write-Host '임시 폴더 흔적: 새로 남은 것 0'