@@ -1478,6 +1478,10 @@ void main() {
1478
1478
});
1479
1479
1480
1480
group ('incremental builds with cached graph' , () {
1481
+ // Using `resumeFrom: result` to pass the filesystem between `testBuilders`
1482
+ // calls causes the serialized graph from the previous build to be loaded,
1483
+ // exactly as in real builds.
1484
+
1481
1485
test ('one new asset, one modified asset, one unchanged asset' , () async {
1482
1486
var builders = [copyABuilderApplication];
1483
1487
@@ -1489,9 +1493,6 @@ void main() {
1489
1493
);
1490
1494
1491
1495
// Followup build with modified inputs.
1492
- var serializedGraph = result.readerWriter.testing.readBytes (
1493
- makeAssetId ('a|$assetGraphPath ' ),
1494
- );
1495
1496
await testBuilders (
1496
1497
builders,
1497
1498
{
@@ -1500,7 +1501,6 @@ void main() {
1500
1501
'a|lib/b.txt' : 'b' ,
1501
1502
'a|lib/b.txt.copy' : 'b' ,
1502
1503
'a|lib/c.txt' : 'c' ,
1503
- 'a|$assetGraphPath ' : serializedGraph,
1504
1504
},
1505
1505
outputs: {'a|web/a.txt.copy' : 'a2' , 'a|lib/c.txt.copy' : 'c' },
1506
1506
resumeFrom: result,
@@ -1528,17 +1528,10 @@ void main() {
1528
1528
);
1529
1529
1530
1530
// Followup build with the 2nd output missing.
1531
- var serializedGraph = result.readerWriter.testing.readBytes (
1532
- makeAssetId ('a|$assetGraphPath ' ),
1533
- );
1534
1531
result.readerWriter.testing.delete (AssetId ('a' , 'lib/a.txt.2' ));
1535
1532
await testBuilders (
1536
1533
builders,
1537
- {
1538
- 'a|lib/a.txt' : 'a' ,
1539
- 'a|lib/a.txt.1' : 'a' ,
1540
- 'a|$assetGraphPath ' : serializedGraph,
1541
- },
1534
+ {'a|lib/a.txt' : 'a' , 'a|lib/a.txt.1' : 'a' },
1542
1535
outputs: {'a|lib/a.txt.1' : 'a' , 'a|lib/a.txt.2' : 'a' },
1543
1536
resumeFrom: result,
1544
1537
);
@@ -1581,51 +1574,39 @@ void main() {
1581
1574
);
1582
1575
1583
1576
// Followup build with modified unused inputs should have no outputs.
1584
- var serializedGraph = result.readerWriter.testing.readBytes (
1585
- makeAssetId ('a|$assetGraphPath ' ),
1586
- );
1587
1577
await testBuilders (
1588
1578
builders,
1589
1579
{
1590
1580
'a|lib/a.txt' : 'a' ,
1591
1581
'a|lib/a.txt.used' : 'b' ,
1592
1582
'a|lib/a.txt.unused' : 'd' , // changed the content of this one
1593
1583
'a|lib/a.txt.copy' : 'ab' ,
1594
- 'a|$assetGraphPath ' : serializedGraph,
1595
1584
},
1596
1585
outputs: {},
1597
1586
resumeFrom: result,
1598
1587
);
1599
1588
1600
1589
// And now modify a real input.
1601
- serializedGraph = result.readerWriter.testing.readBytes (
1602
- makeAssetId ('a|$assetGraphPath ' ),
1603
- );
1604
1590
await testBuilders (
1605
1591
builders,
1606
1592
{
1607
1593
'a|lib/a.txt' : 'a' ,
1608
1594
'a|lib/a.txt.used' : 'e' ,
1609
1595
'a|lib/a.txt.unused' : 'd' ,
1610
1596
'a|lib/a.txt.copy' : 'ab' ,
1611
- 'a|$assetGraphPath ' : serializedGraph,
1612
1597
},
1613
1598
outputs: {'a|lib/a.txt.copy' : 'ae' },
1614
1599
resumeFrom: result,
1615
1600
);
1616
1601
1617
1602
// Finally modify the primary input.
1618
- serializedGraph = result.readerWriter.testing.readBytes (
1619
- makeAssetId ('a|$assetGraphPath ' ),
1620
- );
1621
1603
await testBuilders (
1622
1604
builders,
1623
1605
{
1624
1606
'a|lib/a.txt' : 'f' ,
1625
1607
'a|lib/a.txt.used' : 'e' ,
1626
1608
'a|lib/a.txt.unused' : 'd' ,
1627
1609
'a|lib/a.txt.copy' : 'ae' ,
1628
- 'a|$assetGraphPath ' : serializedGraph,
1629
1610
},
1630
1611
outputs: {'a|lib/a.txt.copy' : 'fe' },
1631
1612
resumeFrom: result,
@@ -1653,32 +1634,20 @@ void main() {
1653
1634
);
1654
1635
1655
1636
// Followup build with modified primary input should have no outputs.
1656
- var serializedGraph = result.readerWriter.testing.readBytes (
1657
- makeAssetId ('a|$assetGraphPath ' ),
1658
- );
1659
1637
await testBuilders (
1660
1638
builders,
1661
- {
1662
- 'a|lib/a.txt' : 'b' ,
1663
- 'a|lib/a.txt.used' : '' ,
1664
- 'a|lib/a.txt.copy' : 'a' ,
1665
- 'a|$assetGraphPath ' : serializedGraph,
1666
- },
1639
+ {'a|lib/a.txt' : 'b' , 'a|lib/a.txt.used' : '' , 'a|lib/a.txt.copy' : 'a' },
1667
1640
outputs: {},
1668
1641
resumeFrom: result,
1669
1642
);
1670
1643
1671
1644
// But modifying other inputs still causes a rebuild.
1672
- serializedGraph = result.readerWriter.testing.readBytes (
1673
- makeAssetId ('a|$assetGraphPath ' ),
1674
- );
1675
1645
await testBuilders (
1676
1646
builders,
1677
1647
{
1678
1648
'a|lib/a.txt' : 'b' ,
1679
1649
'a|lib/a.txt.used' : 'b' ,
1680
1650
'a|lib/a.txt.copy' : 'a' ,
1681
- 'a|$assetGraphPath ' : serializedGraph,
1682
1651
},
1683
1652
outputs: {'a|lib/a.txt.copy' : 'b' },
1684
1653
resumeFrom: result,
@@ -1706,13 +1675,10 @@ void main() {
1706
1675
);
1707
1676
1708
1677
// Delete the primary input, the output shoud still be deleted
1709
- var serializedGraph = result.readerWriter.testing.readBytes (
1710
- makeAssetId ('a|$assetGraphPath ' ),
1711
- );
1712
1678
result.readerWriter.testing.delete (AssetId ('a' , 'lib/a.txt' ));
1713
1679
await testBuilders (
1714
1680
builders,
1715
- {'a|lib/a.txt.copy' : 'a' , 'a|$ assetGraphPath ' : serializedGraph },
1681
+ {'a|lib/a.txt.copy' : 'a' },
1716
1682
outputs: {},
1717
1683
resumeFrom: result,
1718
1684
);
@@ -1743,17 +1709,10 @@ void main() {
1743
1709
);
1744
1710
1745
1711
// Followup build with deleted input + cached graph.
1746
- var serializedGraph = result.readerWriter.testing.readBytes (
1747
- makeAssetId ('a|$assetGraphPath ' ),
1748
- );
1749
1712
result.readerWriter.testing.delete (AssetId ('a' , 'lib/a.txt' ));
1750
1713
await testBuilders (
1751
1714
builders,
1752
- {
1753
- 'a|lib/a.txt.copy' : 'a' ,
1754
- 'a|lib/a.txt.clone' : 'a' ,
1755
- 'a|$assetGraphPath ' : serializedGraph,
1756
- },
1715
+ {'a|lib/a.txt.copy' : 'a' , 'a|lib/a.txt.clone' : 'a' },
1757
1716
outputs: {},
1758
1717
resumeFrom: result,
1759
1718
);
@@ -1784,14 +1743,7 @@ void main() {
1784
1743
);
1785
1744
1786
1745
// Followup build with same sources + cached graph.
1787
- var serializedGraph = result.readerWriter.testing.readBytes (
1788
- makeAssetId ('a|$assetGraphPath ' ),
1789
- );
1790
- await testBuilders (builders, {
1791
- 'a|web/a.txt' : 'a' ,
1792
- 'a|web/a.txt.copy' : 'a' ,
1793
- 'a|$assetGraphPath ' : serializedGraph,
1794
- }, outputs: {});
1746
+ await testBuilders (builders, {}, outputs: {}, resumeFrom: result);
1795
1747
});
1796
1748
1797
1749
test ('no outputs if no changed sources using `hideOutput: true`' , () async {
@@ -1809,14 +1761,7 @@ void main() {
1809
1761
);
1810
1762
1811
1763
// Followup build with same sources + cached graph.
1812
- var serializedGraph = result.readerWriter.testing.readBytes (
1813
- makeAssetId ('a|$assetGraphPath ' ),
1814
- );
1815
- await testBuilders (builders, {
1816
- 'a|web/a.txt' : 'a' ,
1817
- 'a|web/a.txt.copy' : 'a' ,
1818
- 'a|$assetGraphPath ' : serializedGraph,
1819
- }, outputs: {});
1764
+ await testBuilders (builders, {}, outputs: {}, resumeFrom: result);
1820
1765
});
1821
1766
1822
1767
test ('inputs/outputs are updated if they change' , () async {
@@ -1836,10 +1781,6 @@ void main() {
1836
1781
1837
1782
// Followup build with same sources + cached graph, but configure the
1838
1783
// builder to read a different file.
1839
- var serializedGraph = result.readerWriter.testing.readBytes (
1840
- makeAssetId ('a|$assetGraphPath ' ),
1841
- );
1842
-
1843
1784
await testBuilders (
1844
1785
[
1845
1786
applyToRoot (
@@ -1856,7 +1797,6 @@ void main() {
1856
1797
// builder but pretending its the same.
1857
1798
'a|lib/file.b' : 'b2' ,
1858
1799
'a|lib/file.c' : 'c' ,
1859
- 'a|$assetGraphPath ' : serializedGraph,
1860
1800
},
1861
1801
outputs: {'a|lib/file.a.copy' : 'c' },
1862
1802
resumeFrom: result,
@@ -1901,17 +1841,13 @@ void main() {
1901
1841
1902
1842
// Modify the primary input of `file.a.copy`, but its output doesn't
1903
1843
// change so `file.a.copy.copy` shouldn't be rebuilt.
1904
- var serializedGraph = result.readerWriter.testing.readBytes (
1905
- makeAssetId ('a|$assetGraphPath ' ),
1906
- );
1907
1844
await testBuilders (
1908
1845
builders,
1909
1846
{
1910
1847
'a|lib/file.a' : 'a2' ,
1911
1848
'a|lib/file.b' : 'b' ,
1912
1849
'a|lib/file.a.copy' : 'b' ,
1913
1850
'a|lib/file.a.copy.copy' : 'b' ,
1914
- 'a|$assetGraphPath ' : serializedGraph,
1915
1851
},
1916
1852
outputs: {'a|lib/file.a.copy' : 'b' },
1917
1853
resumeFrom: result,
@@ -1922,22 +1858,24 @@ void main() {
1922
1858
var builders = [applyToRoot (SiblingCopyBuilder ())];
1923
1859
1924
1860
// Initial build.
1925
- final result = await testBuilders (
1861
+ var result = await testBuilders (
1926
1862
builders,
1927
1863
{'a|web/a.txt' : 'a' , 'a|web/a.txt.sibling' : 'sibling' },
1928
1864
outputs: {'a|web/a.txt.new' : 'sibling' },
1929
1865
);
1930
1866
1931
1867
// Followup build with cached graph and a changed primary input, but the
1932
1868
// actual file that was read has not changed.
1933
- await testBuilders (builders, {
1934
- 'a|web/a.txt' : 'b' ,
1935
- 'a|web/a.txt.sibling' : 'sibling' ,
1936
- 'a|web/a.txt.new' : 'sibling' ,
1937
- 'a|$assetGraphPath ' : result.readerWriter.testing.readBytes (
1938
- makeAssetId ('a|$assetGraphPath ' ),
1939
- ),
1940
- }, outputs: {});
1869
+ result = await testBuilders (
1870
+ builders,
1871
+ {
1872
+ 'a|web/a.txt' : 'b' ,
1873
+ 'a|web/a.txt.sibling' : 'sibling' ,
1874
+ 'a|web/a.txt.new' : 'sibling' ,
1875
+ },
1876
+ outputs: {},
1877
+ resumeFrom: result,
1878
+ );
1941
1879
1942
1880
// And now try modifying the sibling to make sure that still works.
1943
1881
await testBuilders (
@@ -1946,11 +1884,9 @@ void main() {
1946
1884
'a|web/a.txt' : 'b' ,
1947
1885
'a|web/a.txt.sibling' : 'new!' ,
1948
1886
'a|web/a.txt.new' : 'sibling' ,
1949
- 'a|$assetGraphPath ' : result.readerWriter.testing.readBytes (
1950
- makeAssetId ('a|$assetGraphPath ' ),
1951
- ),
1952
1887
},
1953
1888
outputs: {'a|web/a.txt.new' : 'new!' },
1889
+ resumeFrom: result,
1954
1890
);
1955
1891
});
1956
1892
});
@@ -1986,13 +1922,9 @@ void main() {
1986
1922
'a|lib/a.source' : 'true' ,
1987
1923
}, status: BuildStatus .failure);
1988
1924
1989
- var serializedGraph = result.readerWriter.testing.readBytes (
1990
- makeAssetId ('a|$assetGraphPath ' ),
1991
- );
1992
-
1993
1925
await testBuilders (
1994
1926
builders,
1995
- {'a|lib/a.source' : 'false' , 'a|$ assetGraphPath ' : serializedGraph },
1927
+ {'a|lib/a.source' : 'false' },
1996
1928
outputs: {},
1997
1929
resumeFrom: result,
1998
1930
);
@@ -2070,30 +2002,22 @@ void main() {
2070
2002
),
2071
2003
),
2072
2004
];
2073
- final result = await testBuilders (builders, {
2005
+ var result = await testBuilders (builders, {
2074
2006
'a|web/a.source' : 'true' ,
2075
2007
}, status: BuildStatus .failure);
2076
2008
2077
- var serializedGraph = result.readerWriter.testing.readBytes (
2078
- makeAssetId ('a|$assetGraphPath ' ),
2079
- );
2080
-
2081
- await testBuilders (
2009
+ result = await testBuilders (
2082
2010
builders,
2083
- {'a|web/a.source' : 'false' , 'a|$ assetGraphPath ' : serializedGraph },
2011
+ {'a|web/a.source' : 'false' },
2084
2012
outputs: {'a|web/a.g1' : '' , 'a|web/a.g2' : '' , 'a|web/a.g3' : '' },
2085
2013
resumeFrom: result,
2086
2014
);
2087
2015
2088
- serializedGraph = result.readerWriter.testing.readBytes (
2089
- makeAssetId ('a|$assetGraphPath ' ),
2090
- );
2091
-
2092
2016
// Make sure if we mark the original node as a failure again, that we
2093
2017
// also mark all its primary outputs as failures.
2094
2018
await testBuilders (
2095
2019
builders,
2096
- {'a|web/a.source' : 'true' , 'a|$ assetGraphPath ' : serializedGraph },
2020
+ {'a|web/a.source' : 'true' },
2097
2021
outputs: {},
2098
2022
status: BuildStatus .failure,
2099
2023
resumeFrom: result,
0 commit comments