@@ -9,7 +9,6 @@ delete process.env['VITEST']
99delete process . env [ 'VITEST_WORKER_ID' ]
1010
1111const cleanupModule = await import ( '../src/commands/CleanupUtils' )
12- const fallbackModule = await import ( '../src/commands/CleanupUtils.fallback' )
1312const pluginCore = await import ( '../src/plugins/plugin-core' )
1413
1514function createMockLogger ( ) : ILogger {
@@ -106,21 +105,18 @@ async function main(): Promise<void> {
106105 const cleanCtx = createCleanContext ( workspaceDir )
107106
108107 const nativePlan = await cleanupModule . collectDeletionTargets ( [ plugin ] , cleanCtx )
109- const fallbackPlan = await fallbackModule . collectDeletionTargets ( [ plugin ] , cleanCtx )
110-
111- const sortPaths = ( value : { filesToDelete : string [ ] , dirsToDelete : string [ ] , excludedScanGlobs : string [ ] } ) => ( {
112- ...value ,
113- filesToDelete : [ ...value . filesToDelete ] . sort ( ) ,
114- dirsToDelete : [ ...value . dirsToDelete ] . sort ( ) ,
115- excludedScanGlobs : [ ...value . excludedScanGlobs ] . sort ( )
116- } )
117-
118- if ( JSON . stringify ( sortPaths ( nativePlan ) ) !== JSON . stringify ( sortPaths ( fallbackPlan ) ) ) {
119- throw new Error ( `Native cleanup plan mismatch.\nNative: ${ JSON . stringify ( nativePlan , null , 2 ) } \nFallback: ${ JSON . stringify ( fallbackPlan , null , 2 ) } ` )
108+ expectSetEqual ( nativePlan . filesToDelete , [ rootOutput , childOutput ] , 'native cleanup plan files' )
109+ expectSetEqual ( nativePlan . dirsToDelete , [
110+ legacySkillDir ,
111+ path . join ( workspaceDir , 'project-a' , 'commands' ) ,
112+ path . join ( workspaceDir , 'project-a' )
113+ ] , 'native cleanup plan directories' )
114+ if ( nativePlan . violations . length > 0 || nativePlan . conflicts . length > 0 ) {
115+ throw new Error ( `Unexpected native cleanup plan: ${ JSON . stringify ( nativePlan , null , 2 ) } ` )
120116 }
121117
122118 const result = await cleanupModule . performCleanup ( [ plugin ] , cleanCtx , createMockLogger ( ) )
123- if ( result . deletedFiles !== 2 || result . deletedDirs !== 1 || result . errors . length > 0 ) {
119+ if ( result . deletedFiles !== 2 || result . deletedDirs !== 3 || result . errors . length > 0 ) {
124120 throw new Error ( `Unexpected native cleanup result: ${ JSON . stringify ( result , null , 2 ) } ` )
125121 }
126122
@@ -138,4 +134,12 @@ async function main(): Promise<void> {
138134 }
139135}
140136
137+ function expectSetEqual ( actual : readonly string [ ] , expected : readonly string [ ] , label : string ) : void {
138+ const actualSorted = [ ...actual ] . sort ( )
139+ const expectedSorted = [ ...expected ] . sort ( )
140+ if ( JSON . stringify ( actualSorted ) !== JSON . stringify ( expectedSorted ) ) {
141+ throw new Error ( `Unexpected ${ label } : ${ JSON . stringify ( actualSorted ) } !== ${ JSON . stringify ( expectedSorted ) } ` )
142+ }
143+ }
144+
141145await main ( )
0 commit comments