@@ -8,6 +8,7 @@ import { fileURLToPath } from "url";
88const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) ) ;
99const POST_SCRIPT_PATH = path . join ( __dirname , ".." , "post.js" ) ;
1010const CLEAN_SCRIPT_PATH = path . join ( __dirname , ".." , "clean.sh" ) ;
11+ const INSTALL_COPILOT_CLI_SCRIPT_PATH = path . join ( __dirname , ".." , "sh" , "install_copilot_cli.sh" ) ;
1112
1213const tempDirs = [ ] ;
1314
@@ -136,3 +137,19 @@ describe("clean.sh chroot-home cleanup", () => {
136137 expect ( fs . readFileSync ( logPath , "utf8" ) ) . toContain ( "-exec rm -rf -- {} +" ) ;
137138 } ) ;
138139} ) ;
140+
141+ describe ( "install_copilot_cli.sh chroot-home cleanup" , ( ) => {
142+ it ( "cleans stale chroot-home directories before starting Copilot CLI installation" , ( ) => {
143+ const script = fs . readFileSync ( INSTALL_COPILOT_CLI_SCRIPT_PATH , "utf8" ) ;
144+
145+ const ownershipFixIndex = script . indexOf ( 'sudo chown -R "$(id -u):$(id -g)" "$COPILOT_DIR"' ) ;
146+ const cleanupBannerIndex = script . indexOf ( 'echo "Cleaning up stale AWF chroot home directories..."' ) ;
147+ const cleanupCommandIndex = script . indexOf (
148+ "sudo find /tmp -maxdepth 1 -name 'awf-*-chroot-home' -type d -exec rm -rf -- {} + 2>/dev/null || true"
149+ ) ;
150+
151+ expect ( ownershipFixIndex ) . toBeGreaterThanOrEqual ( 0 ) ;
152+ expect ( cleanupBannerIndex ) . toBeGreaterThan ( ownershipFixIndex ) ;
153+ expect ( cleanupCommandIndex ) . toBeGreaterThan ( cleanupBannerIndex ) ;
154+ } ) ;
155+ } ) ;
0 commit comments