@@ -1606,6 +1606,27 @@ class FixtureTester {
16061606 }
16071607
16081608 _assertBuild ( assertions ) {
1609+ /**
1610+ * assertions object structure:
1611+ * {
1612+ * projects: {
1613+ * "projectName": {
1614+ * executedTasks: ["task1", "task2"],
1615+ * skippedTasks: ["task3", "task4"],
1616+ * writtenResources: {
1617+ * "taskName": ["/resources/path/a", "/resources/path/b"],
1618+ * },
1619+ * },
1620+ * // ...
1621+ * }
1622+ * }
1623+ *
1624+ * writtenResources - optional per project, asserts the exact set of resource paths a task
1625+ * wrote (sourced from the `writtenResourcePaths` field of the `task-end` build-status
1626+ * event). Only tasks listed are asserted; other tasks are ignored. This is the signal for
1627+ * delta-build correctness: it reveals WHAT a task did (which outputs it (re-)wrote), not
1628+ * just whether it ran.
1629+ */
16091630 const { projects = { } } = assertions ;
16101631
16111632 const projectsInOrder = [ ] ;
@@ -1623,16 +1644,19 @@ class FixtureTester {
16231644 }
16241645 }
16251646
1626- // Extract task status to identify skipped & executed tasks per project
1647+ // Extract task status to identify skipped & executed tasks and written resources per project
16271648 const projectBuildStatusEvents = this . _t . context . projectBuildStatusEventStub . args . map ( ( args ) => args [ 0 ] ) ;
16281649 for ( const event of projectBuildStatusEvents ) {
16291650 if ( ! tasksByProject [ event . projectName ] ) {
1630- tasksByProject [ event . projectName ] = { executed : [ ] , skipped : [ ] } ;
1651+ tasksByProject [ event . projectName ] = { executed : [ ] , skipped : [ ] , writtenResources : { } } ;
16311652 }
16321653 if ( event . status === "task-skip" ) {
16331654 tasksByProject [ event . projectName ] . skipped . push ( event . taskName ) ;
16341655 } else if ( event . status === "task-start" ) {
16351656 tasksByProject [ event . projectName ] . executed . push ( event . taskName ) ;
1657+ } else if ( event . status === "task-end" ) {
1658+ tasksByProject [ event . projectName ] . writtenResources [ event . taskName ] =
1659+ event . writtenResourcePaths ;
16361660 }
16371661 }
16381662
@@ -1651,12 +1675,23 @@ class FixtureTester {
16511675 "Executed tasks for project " + projectName + " do not match expected" ) ;
16521676 }
16531677
1654- // Assert skipped tasks per project
1655- for ( const [ projectName , expectedSkipped ] of Object . entries ( projects ) ) {
1656- const skippedTasks = expectedSkipped . skippedTasks || [ ] ;
1678+ // Assert skipped tasks and written resources per project
1679+ for ( const [ projectName , expected ] of Object . entries ( projects ) ) {
1680+ const skippedTasks = expected . skippedTasks || [ ] ;
16571681 const actualSkipped = ( tasksByProject [ projectName ] ?. skipped || [ ] ) . sort ( ) ;
16581682 const expectedArray = skippedTasks . sort ( ) ;
16591683 this . _t . deepEqual ( actualSkipped , expectedArray ) ;
1684+
1685+ if ( expected . writtenResources ) {
1686+ const actualWritten = tasksByProject [ projectName ] ?. writtenResources || { } ;
1687+ for ( const [ taskName , expectedPaths ] of Object . entries ( expected . writtenResources ) ) {
1688+ this . _t . deepEqual (
1689+ [ ...( actualWritten [ taskName ] || [ ] ) ] . sort ( ) ,
1690+ [ ...expectedPaths ] . sort ( ) ,
1691+ `Written resources of task '${ taskName } ' in project '${ projectName } ' should match expected`
1692+ ) ;
1693+ }
1694+ }
16601695 }
16611696 }
16621697}
0 commit comments