@@ -187,3 +187,36 @@ func TestLoadFileWithExtendProject(t *testing.T) {
187187 }
188188 }
189189}
190+
191+ // TestLoad_ReloadAfterExtends locks in the fix for the reload-after-extends
192+ // bug: Load() must persist the user-supplied FileNames on the returned project,
193+ // not the slice that loadExtendProject mutates while resolving `extends:`.
194+ // ProjectRunner.ReloadProject reuses project.FileNames as input to the next
195+ // Load(); if the extends target leaks into that slice, the Contains check in
196+ // loadExtendProject false-fires on the loader's own bookkeeping.
197+ func TestLoad_ReloadAfterExtends (t * testing.T ) {
198+ fixture := filepath .Join (".." , ".." , "fixtures-code" , "process-compose-with-extends.yaml" )
199+
200+ opts1 := & LoaderOptions {
201+ FileNames : []string {fixture },
202+ IsInternalLoader : true ,
203+ }
204+ project1 , err := Load (opts1 )
205+ if err != nil {
206+ t .Fatalf ("initial load failed: %v" , err )
207+ }
208+ if len (project1 .FileNames ) != 1 || project1 .FileNames [0 ] != fixture {
209+ t .Fatalf ("project.FileNames = %v, want [%s]" , project1 .FileNames , fixture )
210+ }
211+
212+ // Mimic ProjectRunner.ReloadProject: feed the previous project's FileNames
213+ // as the next Load's input. Before the fix this fails with
214+ // "project ... is already specified in files to load".
215+ opts2 := & LoaderOptions {
216+ FileNames : project1 .FileNames ,
217+ IsInternalLoader : true ,
218+ }
219+ if _ , err := Load (opts2 ); err != nil {
220+ t .Fatalf ("reload after extends failed: %v" , err )
221+ }
222+ }
0 commit comments