From c79c5dfffe4cec3a30e4e7828f47d8b623d0f5c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BF=AE=E9=9B=A8?= Date: Thu, 16 Jul 2026 12:21:27 +0800 Subject: [PATCH] test(windows): isolate portable import side effects --- internal/app/auth_command_test.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/internal/app/auth_command_test.go b/internal/app/auth_command_test.go index fb8b89b8..a0065247 100644 --- a/internal/app/auth_command_test.go +++ b/internal/app/auth_command_test.go @@ -185,9 +185,12 @@ func TestCrossPlatformCoverageAuthImportRejectsWindowsDPAPIBackend(t *testing.T) if runtime.GOOS != "windows" { t.Skip("Windows DPAPI contract requires a native Windows runner") } - t.Cleanup(CloseFileLogger) root := t.TempDir() + // NewRootCommand initializes the normal CLI file logger below configDir. + // Register its cleanup after TempDir so the Windows handle is closed before + // testing removes the temporary directory. + t.Cleanup(CloseFileLogger) configDir := filepath.Join(root, ".dws") keychainDir := filepath.Join(root, "keychain") inputPath := filepath.Join(root, "bundle.tar.gz") @@ -215,7 +218,14 @@ func TestCrossPlatformCoverageAuthImportRejectsWindowsDPAPIBackend(t *testing.T) t.Fatalf("error = %v, want substring %q", err, want) } } - for _, path := range []string{configDir, keychainDir} { + // The root command may create configDir/logs as part of normal CLI startup. + // The capability guard must still run before any auth state is imported. + for _, path := range []string{ + keychainDir, + authpkg.ProfilesPath(configDir), + filepath.Join(configDir, "app.json"), + filepath.Join(configDir, "token.json"), + } { if _, statErr := os.Stat(path); !os.IsNotExist(statErr) { t.Fatalf("unsupported Windows import touched %s: stat error = %v", path, statErr) }