Skip to content

Commit ee0899f

Browse files
committed
Remove unnecessary copy of serialized graph in tests.
1 parent 1e5eda2 commit ee0899f

File tree

1 file changed

+26
-103
lines changed

1 file changed

+26
-103
lines changed

build_runner_core/test/generate/build_test.dart

Lines changed: 26 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,6 +1478,9 @@ void main() {
14781478
});
14791479

14801480
group('incremental builds with cached graph', () {
1481+
// Using `resumeFrom: result` to pass the filesystem between builds causes
1482+
// the serialized graph to be loaded.
1483+
14811484
test('one new asset, one modified asset, one unchanged asset', () async {
14821485
var builders = [copyABuilderApplication];
14831486

@@ -1489,9 +1492,6 @@ void main() {
14891492
);
14901493

14911494
// Followup build with modified inputs.
1492-
var serializedGraph = result.readerWriter.testing.readBytes(
1493-
makeAssetId('a|$assetGraphPath'),
1494-
);
14951495
await testBuilders(
14961496
builders,
14971497
{
@@ -1500,7 +1500,6 @@ void main() {
15001500
'a|lib/b.txt': 'b',
15011501
'a|lib/b.txt.copy': 'b',
15021502
'a|lib/c.txt': 'c',
1503-
'a|$assetGraphPath': serializedGraph,
15041503
},
15051504
outputs: {'a|web/a.txt.copy': 'a2', 'a|lib/c.txt.copy': 'c'},
15061505
resumeFrom: result,
@@ -1528,17 +1527,10 @@ void main() {
15281527
);
15291528

15301529
// Followup build with the 2nd output missing.
1531-
var serializedGraph = result.readerWriter.testing.readBytes(
1532-
makeAssetId('a|$assetGraphPath'),
1533-
);
15341530
result.readerWriter.testing.delete(AssetId('a', 'lib/a.txt.2'));
15351531
await testBuilders(
15361532
builders,
1537-
{
1538-
'a|lib/a.txt': 'a',
1539-
'a|lib/a.txt.1': 'a',
1540-
'a|$assetGraphPath': serializedGraph,
1541-
},
1533+
{'a|lib/a.txt': 'a', 'a|lib/a.txt.1': 'a'},
15421534
outputs: {'a|lib/a.txt.1': 'a', 'a|lib/a.txt.2': 'a'},
15431535
resumeFrom: result,
15441536
);
@@ -1581,51 +1573,39 @@ void main() {
15811573
);
15821574

15831575
// Followup build with modified unused inputs should have no outputs.
1584-
var serializedGraph = result.readerWriter.testing.readBytes(
1585-
makeAssetId('a|$assetGraphPath'),
1586-
);
15871576
await testBuilders(
15881577
builders,
15891578
{
15901579
'a|lib/a.txt': 'a',
15911580
'a|lib/a.txt.used': 'b',
15921581
'a|lib/a.txt.unused': 'd', // changed the content of this one
15931582
'a|lib/a.txt.copy': 'ab',
1594-
'a|$assetGraphPath': serializedGraph,
15951583
},
15961584
outputs: {},
15971585
resumeFrom: result,
15981586
);
15991587

16001588
// And now modify a real input.
1601-
serializedGraph = result.readerWriter.testing.readBytes(
1602-
makeAssetId('a|$assetGraphPath'),
1603-
);
16041589
await testBuilders(
16051590
builders,
16061591
{
16071592
'a|lib/a.txt': 'a',
16081593
'a|lib/a.txt.used': 'e',
16091594
'a|lib/a.txt.unused': 'd',
16101595
'a|lib/a.txt.copy': 'ab',
1611-
'a|$assetGraphPath': serializedGraph,
16121596
},
16131597
outputs: {'a|lib/a.txt.copy': 'ae'},
16141598
resumeFrom: result,
16151599
);
16161600

16171601
// Finally modify the primary input.
1618-
serializedGraph = result.readerWriter.testing.readBytes(
1619-
makeAssetId('a|$assetGraphPath'),
1620-
);
16211602
await testBuilders(
16221603
builders,
16231604
{
16241605
'a|lib/a.txt': 'f',
16251606
'a|lib/a.txt.used': 'e',
16261607
'a|lib/a.txt.unused': 'd',
16271608
'a|lib/a.txt.copy': 'ae',
1628-
'a|$assetGraphPath': serializedGraph,
16291609
},
16301610
outputs: {'a|lib/a.txt.copy': 'fe'},
16311611
resumeFrom: result,
@@ -1653,32 +1633,20 @@ void main() {
16531633
);
16541634

16551635
// Followup build with modified primary input should have no outputs.
1656-
var serializedGraph = result.readerWriter.testing.readBytes(
1657-
makeAssetId('a|$assetGraphPath'),
1658-
);
16591636
await testBuilders(
16601637
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-
},
1638+
{'a|lib/a.txt': 'b', 'a|lib/a.txt.used': '', 'a|lib/a.txt.copy': 'a'},
16671639
outputs: {},
16681640
resumeFrom: result,
16691641
);
16701642

16711643
// But modifying other inputs still causes a rebuild.
1672-
serializedGraph = result.readerWriter.testing.readBytes(
1673-
makeAssetId('a|$assetGraphPath'),
1674-
);
16751644
await testBuilders(
16761645
builders,
16771646
{
16781647
'a|lib/a.txt': 'b',
16791648
'a|lib/a.txt.used': 'b',
16801649
'a|lib/a.txt.copy': 'a',
1681-
'a|$assetGraphPath': serializedGraph,
16821650
},
16831651
outputs: {'a|lib/a.txt.copy': 'b'},
16841652
resumeFrom: result,
@@ -1706,13 +1674,10 @@ void main() {
17061674
);
17071675

17081676
// Delete the primary input, the output shoud still be deleted
1709-
var serializedGraph = result.readerWriter.testing.readBytes(
1710-
makeAssetId('a|$assetGraphPath'),
1711-
);
17121677
result.readerWriter.testing.delete(AssetId('a', 'lib/a.txt'));
17131678
await testBuilders(
17141679
builders,
1715-
{'a|lib/a.txt.copy': 'a', 'a|$assetGraphPath': serializedGraph},
1680+
{'a|lib/a.txt.copy': 'a'},
17161681
outputs: {},
17171682
resumeFrom: result,
17181683
);
@@ -1743,17 +1708,10 @@ void main() {
17431708
);
17441709

17451710
// Followup build with deleted input + cached graph.
1746-
var serializedGraph = result.readerWriter.testing.readBytes(
1747-
makeAssetId('a|$assetGraphPath'),
1748-
);
17491711
result.readerWriter.testing.delete(AssetId('a', 'lib/a.txt'));
17501712
await testBuilders(
17511713
builders,
1752-
{
1753-
'a|lib/a.txt.copy': 'a',
1754-
'a|lib/a.txt.clone': 'a',
1755-
'a|$assetGraphPath': serializedGraph,
1756-
},
1714+
{'a|lib/a.txt.copy': 'a', 'a|lib/a.txt.clone': 'a'},
17571715
outputs: {},
17581716
resumeFrom: result,
17591717
);
@@ -1784,14 +1742,7 @@ void main() {
17841742
);
17851743

17861744
// 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: {});
1745+
await testBuilders(builders, {}, outputs: {}, resumeFrom: result);
17951746
});
17961747

17971748
test('no outputs if no changed sources using `hideOutput: true`', () async {
@@ -1809,14 +1760,7 @@ void main() {
18091760
);
18101761

18111762
// 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: {});
1763+
await testBuilders(builders, {}, outputs: {}, resumeFrom: result);
18201764
});
18211765

18221766
test('inputs/outputs are updated if they change', () async {
@@ -1836,10 +1780,6 @@ void main() {
18361780

18371781
// Followup build with same sources + cached graph, but configure the
18381782
// builder to read a different file.
1839-
var serializedGraph = result.readerWriter.testing.readBytes(
1840-
makeAssetId('a|$assetGraphPath'),
1841-
);
1842-
18431783
await testBuilders(
18441784
[
18451785
applyToRoot(
@@ -1856,7 +1796,6 @@ void main() {
18561796
// builder but pretending its the same.
18571797
'a|lib/file.b': 'b2',
18581798
'a|lib/file.c': 'c',
1859-
'a|$assetGraphPath': serializedGraph,
18601799
},
18611800
outputs: {'a|lib/file.a.copy': 'c'},
18621801
resumeFrom: result,
@@ -1901,17 +1840,13 @@ void main() {
19011840

19021841
// Modify the primary input of `file.a.copy`, but its output doesn't
19031842
// change so `file.a.copy.copy` shouldn't be rebuilt.
1904-
var serializedGraph = result.readerWriter.testing.readBytes(
1905-
makeAssetId('a|$assetGraphPath'),
1906-
);
19071843
await testBuilders(
19081844
builders,
19091845
{
19101846
'a|lib/file.a': 'a2',
19111847
'a|lib/file.b': 'b',
19121848
'a|lib/file.a.copy': 'b',
19131849
'a|lib/file.a.copy.copy': 'b',
1914-
'a|$assetGraphPath': serializedGraph,
19151850
},
19161851
outputs: {'a|lib/file.a.copy': 'b'},
19171852
resumeFrom: result,
@@ -1922,22 +1857,24 @@ void main() {
19221857
var builders = [applyToRoot(SiblingCopyBuilder())];
19231858

19241859
// Initial build.
1925-
final result = await testBuilders(
1860+
var result = await testBuilders(
19261861
builders,
19271862
{'a|web/a.txt': 'a', 'a|web/a.txt.sibling': 'sibling'},
19281863
outputs: {'a|web/a.txt.new': 'sibling'},
19291864
);
19301865

19311866
// Followup build with cached graph and a changed primary input, but the
19321867
// 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: {});
1868+
result = await testBuilders(
1869+
builders,
1870+
{
1871+
'a|web/a.txt': 'b',
1872+
'a|web/a.txt.sibling': 'sibling',
1873+
'a|web/a.txt.new': 'sibling',
1874+
},
1875+
outputs: {},
1876+
resumeFrom: result,
1877+
);
19411878

19421879
// And now try modifying the sibling to make sure that still works.
19431880
await testBuilders(
@@ -1946,11 +1883,9 @@ void main() {
19461883
'a|web/a.txt': 'b',
19471884
'a|web/a.txt.sibling': 'new!',
19481885
'a|web/a.txt.new': 'sibling',
1949-
'a|$assetGraphPath': result.readerWriter.testing.readBytes(
1950-
makeAssetId('a|$assetGraphPath'),
1951-
),
19521886
},
19531887
outputs: {'a|web/a.txt.new': 'new!'},
1888+
resumeFrom: result,
19541889
);
19551890
});
19561891
});
@@ -1986,13 +1921,9 @@ void main() {
19861921
'a|lib/a.source': 'true',
19871922
}, status: BuildStatus.failure);
19881923

1989-
var serializedGraph = result.readerWriter.testing.readBytes(
1990-
makeAssetId('a|$assetGraphPath'),
1991-
);
1992-
19931924
await testBuilders(
19941925
builders,
1995-
{'a|lib/a.source': 'false', 'a|$assetGraphPath': serializedGraph},
1926+
{'a|lib/a.source': 'false'},
19961927
outputs: {},
19971928
resumeFrom: result,
19981929
);
@@ -2070,30 +2001,22 @@ void main() {
20702001
),
20712002
),
20722003
];
2073-
final result = await testBuilders(builders, {
2004+
var result = await testBuilders(builders, {
20742005
'a|web/a.source': 'true',
20752006
}, status: BuildStatus.failure);
20762007

2077-
var serializedGraph = result.readerWriter.testing.readBytes(
2078-
makeAssetId('a|$assetGraphPath'),
2079-
);
2080-
2081-
await testBuilders(
2008+
result = await testBuilders(
20822009
builders,
2083-
{'a|web/a.source': 'false', 'a|$assetGraphPath': serializedGraph},
2010+
{'a|web/a.source': 'false'},
20842011
outputs: {'a|web/a.g1': '', 'a|web/a.g2': '', 'a|web/a.g3': ''},
20852012
resumeFrom: result,
20862013
);
20872014

2088-
serializedGraph = result.readerWriter.testing.readBytes(
2089-
makeAssetId('a|$assetGraphPath'),
2090-
);
2091-
20922015
// Make sure if we mark the original node as a failure again, that we
20932016
// also mark all its primary outputs as failures.
20942017
await testBuilders(
20952018
builders,
2096-
{'a|web/a.source': 'true', 'a|$assetGraphPath': serializedGraph},
2019+
{'a|web/a.source': 'true'},
20972020
outputs: {},
20982021
status: BuildStatus.failure,
20992022
resumeFrom: result,

0 commit comments

Comments
 (0)