@@ -118,7 +118,7 @@ test.serial("Build application.a project multiple times", async (t) => {
118118 } ) ;
119119
120120
121- // #6 build (with cache, no changes, with custom tasks)
121+ // #7 build (with cache, no changes, with custom tasks)
122122 await fixtureTester . buildProject ( {
123123 graphConfig : { rootConfigPath : "ui5-customTask.yaml" } ,
124124 config : { destPath, cleanDest : true } ,
@@ -130,7 +130,7 @@ test.serial("Build application.a project multiple times", async (t) => {
130130 } ) ;
131131
132132
133- // #7 build (with cache, no changes, with custom tasks)
133+ // #8 build (with cache, no changes, with custom tasks)
134134 await fixtureTester . buildProject ( {
135135 graphConfig : { rootConfigPath : "ui5-customTask.yaml" } ,
136136 config : { destPath, cleanDest : true } ,
@@ -140,7 +140,7 @@ test.serial("Build application.a project multiple times", async (t) => {
140140 } ) ;
141141
142142
143- // #8 build (with cache, no changes, with dependencies)
143+ // #9 build (with cache, no changes, with dependencies)
144144 await fixtureTester . buildProject ( {
145145 config : { destPath, cleanDest : true , dependencyIncludes : { includeAllDependencies : true } } ,
146146 assertions : {
@@ -170,7 +170,7 @@ test.serial("Build application.a project multiple times", async (t) => {
170170 )
171171 ) ;
172172
173- // #9 build (with cache, with changes)
173+ // #10 build (with cache, with changes)
174174 await fixtureTester . buildProject ( {
175175 config : { destPath, cleanDest : true } ,
176176 assertions : {
@@ -193,8 +193,8 @@ test.serial("Build application.a project multiple times", async (t) => {
193193 `console.log("SOME NEW CONTENT");\n`
194194 ) ;
195195
196- // #10 build (with cache, with changes - someNew.js added)
197- // Tasks that don't depend on someNew.js can reuse their caches from build #9 .
196+ // #11 build (with cache, with changes - someNew.js added)
197+ // Tasks that don't depend on someNew.js can reuse their caches from build #10 .
198198 await fixtureTester . buildProject ( {
199199 config : { destPath, cleanDest : true } ,
200200 assertions : {
@@ -211,8 +211,8 @@ test.serial("Build application.a project multiple times", async (t) => {
211211
212212 await fs . rm ( `${ fixtureTester . fixturePath } /webapp/someNew.js` ) ;
213213
214- // #11 build (with cache, with changes - someNew.js removed)
215- // Source state matches build #9 's cached result -> cache reused, everything skipped
214+ // #12 build (with cache, with changes - someNew.js removed)
215+ // Source state matches build #10 's cached result -> cache reused, everything skipped
216216 await fixtureTester . buildProject ( {
217217 config : { destPath, cleanDest : true } ,
218218 assertions : {
@@ -337,6 +337,87 @@ test.serial("Build application.a (with various dependencies)", async (t) => {
337337 } ) ;
338338} ) ;
339339
340+ test . serial ( "Build application.a (including only some dependencies)" , async ( t ) => {
341+ const fixtureTester = new FixtureTester ( t , "application.a" ) ;
342+ const destPath = fixtureTester . destPath ;
343+
344+ // In this test, we're testing the "dependencyIncludes" build option
345+ // which allows to include only a subset of the dependencies of a project in the build.
346+ // "application.a" has 4 dependencies defined: library.a, library.b, library.c and library.d.
347+
348+ // #1 build
349+ // Only include library.a and library.b as dependencies, but not library.c and library.d:
350+ await fixtureTester . buildProject ( {
351+ config : { destPath, cleanDest : false ,
352+ dependencyIncludes : { includeDependency : [ "library.a" , "library.b" ] } } ,
353+ assertions : {
354+ projects : {
355+ "library.a" : { } ,
356+ "library.b" : { } ,
357+ "application.a" : { }
358+ }
359+ }
360+ } ) ;
361+
362+ // Check that only the included dependencies are in the destPath:
363+ await t . notThrowsAsync ( fs . readFile ( `${ destPath } /resources/library/a/library-preload.js` ,
364+ { encoding : "utf8" } ) ) ;
365+ await t . notThrowsAsync ( fs . readFile ( `${ destPath } /resources/library/b/library-preload.js` ,
366+ { encoding : "utf8" } ) ) ;
367+ await t . throwsAsync ( fs . readFile ( `${ destPath } /resources/library/c/library-preload.js` ,
368+ { encoding : "utf8" } ) ) ;
369+ await t . throwsAsync ( fs . readFile ( `${ destPath } /resources/library/d/library-preload.js` ,
370+ { encoding : "utf8" } ) ) ;
371+
372+
373+ // #2 build
374+ // Exclude library.d as dependency, but include all other dependencies
375+ // (builds of library.a and library.b can be reused from cache):
376+ await fixtureTester . buildProject ( {
377+ config : { destPath, cleanDest : false ,
378+ dependencyIncludes : { includeAllDependencies : true , excludeDependency : [ "library.d" ] } } ,
379+ assertions : {
380+ projects : {
381+ "library.c" : { } ,
382+ }
383+ }
384+ } ) ;
385+
386+ // Check that only the included dependencies are in the destPath:
387+ await t . notThrowsAsync ( fs . readFile ( `${ destPath } /resources/library/a/library-preload.js` ,
388+ { encoding : "utf8" } ) ) ;
389+ await t . notThrowsAsync ( fs . readFile ( `${ destPath } /resources/library/b/library-preload.js` ,
390+ { encoding : "utf8" } ) ) ;
391+ await t . notThrowsAsync ( fs . readFile ( `${ destPath } /resources/library/c/library-preload.js` ,
392+ { encoding : "utf8" } ) ) ;
393+ await t . throwsAsync ( fs . readFile ( `${ destPath } /resources/library/d/library-preload.js` ,
394+ { encoding : "utf8" } ) ) ;
395+
396+
397+ // #3 build
398+ // Include all dependencies (only library.d is built)
399+ // (builds of library.a, library.b, and library.c can be reused from cache):
400+ await fixtureTester . buildProject ( {
401+ config : { destPath, cleanDest : false ,
402+ dependencyIncludes : { includeAllDependencies : true } } ,
403+ assertions : {
404+ projects : {
405+ "library.d" : { } ,
406+ }
407+ }
408+ } ) ;
409+
410+ // Check that all dependencies are in the destPath:
411+ await t . notThrowsAsync ( fs . readFile ( `${ destPath } /resources/library/a/library-preload.js` ,
412+ { encoding : "utf8" } ) ) ;
413+ await t . notThrowsAsync ( fs . readFile ( `${ destPath } /resources/library/b/library-preload.js` ,
414+ { encoding : "utf8" } ) ) ;
415+ await t . notThrowsAsync ( fs . readFile ( `${ destPath } /resources/library/c/library-preload.js` ,
416+ { encoding : "utf8" } ) ) ;
417+ await t . notThrowsAsync ( fs . readFile ( `${ destPath } /resources/library/d/library-preload.js` ,
418+ { encoding : "utf8" } ) ) ;
419+ } ) ;
420+
340421test . serial ( "Build application.a (custom task and tag handling)" , async ( t ) => {
341422 const fixtureTester = new FixtureTester ( t , "application.a" ) ;
342423 const destPath = fixtureTester . destPath ;
0 commit comments