@@ -33,7 +33,7 @@ test.afterEach.always((t) => {
3333 process . off ( "ui5.project-build-status" , t . context . projectBuildStatusEventStub ) ;
3434} ) ;
3535
36- test . serial ( "Build application project multiple times" , async ( t ) => {
36+ test . serial ( "Build application.a project multiple times" , async ( t ) => {
3737 const fixtureTester = new FixtureTester ( t , "application.a" ) ;
3838
3939 let projectBuilder ; let buildStatusEventArgs ;
@@ -118,7 +118,83 @@ test.serial("Build application project multiple times", async (t) => {
118118 const builtFileContent = await fs . readFile ( `${ destPath } /test.js` , { encoding : "utf8" } ) ;
119119 t . true ( builtFileContent . includes ( `test("line added");` ) , "Build dest contains changed file content" ) ;
120120
121- // // #4 build (with cache, no changes)
121+ // #4 build (with cache, no changes)
122+ projectBuilder = await fixtureTester . createProjectBuilder ( ) ;
123+ await projectBuilder . build ( { destPath, cleanDest : true } ) ;
124+
125+ t . is ( projectBuilder . _buildProject . callCount , 0 , "No projects built in build #4" ) ;
126+ } ) ;
127+
128+ test . serial ( "Build library.d project multiple times" , async ( t ) => {
129+ const fixtureTester = new FixtureTester ( t , "library.d" ) ;
130+
131+ let projectBuilder ; let buildStatusEventArgs ;
132+ const destPath = fixtureTester . destPath ;
133+
134+ // #1 build (with empty cache)
135+ projectBuilder = await fixtureTester . createProjectBuilder ( ) ;
136+ await projectBuilder . build ( { destPath, cleanDest : false /* No clean dest needed for build #1 */ } ) ;
137+
138+ t . is ( projectBuilder . _buildProject . callCount , 1 ) ;
139+ t . is (
140+ projectBuilder . _buildProject . getCall ( 0 ) . args [ 0 ] . getProject ( ) . getName ( ) ,
141+ "library.d" ,
142+ "library.d built in build #1"
143+ ) ;
144+
145+ buildStatusEventArgs = t . context . projectBuildStatusEventStub . args . map ( ( args ) => args [ 0 ] ) ;
146+ t . deepEqual (
147+ buildStatusEventArgs . filter ( ( { status} ) => status === "task-skip" ) , [ ] ,
148+ "No 'task-skip' status in build #1"
149+ ) ;
150+
151+ // #2 build (with cache, no changes)
152+ projectBuilder = await fixtureTester . createProjectBuilder ( ) ;
153+ await projectBuilder . build ( { destPath, cleanDest : true } ) ;
154+
155+ t . is ( projectBuilder . _buildProject . callCount , 0 , "No projects built in build #2" ) ;
156+
157+ // Change a source file in library.d
158+ const changedFilePath = `${ fixtureTester . fixturePath } /main/src/library/d/.library` ;
159+ await fs . writeFile (
160+ changedFilePath ,
161+ ( await fs . readFile ( changedFilePath , { encoding : "utf8" } ) ) . replace (
162+ `<copyright>Some fancy copyright</copyright>` ,
163+ `<copyright>Some new fancy copyright</copyright>`
164+ )
165+ ) ;
166+
167+ // #3 build (with cache, with changes)
168+ projectBuilder = await fixtureTester . createProjectBuilder ( ) ;
169+ await projectBuilder . build ( { destPath, cleanDest : true } ) ;
170+
171+ t . is ( projectBuilder . _buildProject . callCount , 1 ) ;
172+ t . is (
173+ projectBuilder . _buildProject . getCall ( 0 ) . args [ 0 ] . getProject ( ) . getName ( ) ,
174+ "library.d" ,
175+ "library.d rebuilt in build #3"
176+ ) ;
177+
178+ buildStatusEventArgs = t . context . projectBuildStatusEventStub . args . map ( ( args ) => args [ 0 ] ) ;
179+ t . deepEqual (
180+ buildStatusEventArgs . filter ( ( { status} ) => status === "task-skip" ) , [ ] ,
181+ "No 'task-skip' status in build #3"
182+ ) ;
183+
184+ // Check whether the changed file is in the destPath
185+ const builtFileContent = await fs . readFile ( `${ destPath } /resources/library/d/.library` , { encoding : "utf8" } ) ;
186+ t . true (
187+ builtFileContent . includes ( `<copyright>Some new fancy copyright</copyright>` ) ,
188+ "Build dest contains changed file content"
189+ ) ;
190+ // Check whether the updated copyright replacement took place
191+ const builtSomeJsContent = await fs . readFile ( `${ destPath } /resources/library/d/some.js` , { encoding : "utf8" } ) ;
192+ t . true (
193+ builtSomeJsContent . includes ( `Some new fancy copyright` ) ,
194+ "Build dest contains updated copyright in some.js"
195+ ) ;
196+
197+ // #4 build (with cache, no changes)
122198 projectBuilder = await fixtureTester . createProjectBuilder ( ) ;
123199 await projectBuilder . build ( { destPath, cleanDest : true } ) ;
124200
0 commit comments