@@ -1285,53 +1285,223 @@ void main() {
12851285 });
12861286
12871287 group ('--batch-release flag' , () {
1288- test ('filters packages based on ci_config.yaml' , () async {
1289- // Mock packages.
1290- final RepositoryPackage plugin1 = createFakePlugin (
1291- 'plugin1' ,
1292- packagesDir,
1293- version: '1.0.0' ,
1294- batchRelease: true ,
1295- );
1288+ test (
1289+ 'filters packages based on the existence of ci_config.yaml' ,
1290+ () async {
1291+ // Mock pub.dev responses.
1292+ mockHttpResponses['plugin1' ] = < String , dynamic > {
1293+ 'name' : 'plugin1' ,
1294+ 'versions' : < String > ['0.0.1' ],
1295+ };
1296+ mockHttpResponses['plugin2' ] = < String , dynamic > {
1297+ 'name' : 'plugin2' ,
1298+ 'versions' : < String > ['0.0.1' ],
1299+ };
1300+
1301+ // Mock packages.
1302+ final RepositoryPackage plugin1 = createFakePlugin (
1303+ 'plugin1' ,
1304+ packagesDir,
1305+ version: '0.0.2' ,
1306+ batchRelease: true ,
1307+ );
1308+
1309+ final RepositoryPackage plugin2 = createFakePlugin (
1310+ 'plugin2' ,
1311+ packagesDir,
1312+ version: '0.0.2' ,
1313+ );
1314+
1315+ expect (plugin1.ciConfigFile.existsSync (), true );
1316+ expect (plugin2.ciConfigFile.existsSync (), false );
1317+
1318+ // Mock git diff to show both packages have changed.
1319+ processRunner
1320+ .mockProcessesForExecutable['git-diff' ] = < FakeProcessInfo > [
1321+ FakeProcessInfo (
1322+ MockProcess (
1323+ stdout:
1324+ '${plugin1 .pubspecFile .path }\n ${plugin2 .pubspecFile .path }' ,
1325+ ),
1326+ ),
1327+ ];
12961328
1297- final RepositoryPackage plugin2 = createFakePlugin (
1298- 'plugin2' ,
1299- packagesDir,
1300- version: '1.0.0' ,
1301- batchRelease: false ,
1302- );
1329+ mockStdin.readLineOutput = 'y' ;
13031330
1304- // Mock git diff to show both packages have changed.
1305- processRunner.mockProcessesForExecutable['git-diff' ] = < FakeProcessInfo > [
1306- FakeProcessInfo (MockProcess (
1307- stdout:
1308- '${plugin1 .pubspecFile .path }\n ${plugin2 .pubspecFile .path }' ))
1309- ];
1310-
1311- // Mock pub.dev responses.
1312- mockHttpResponses['plugin1' ] = < String , dynamic > {
1313- 'name' : 'plugin1' ,
1314- 'versions' : < String > ['0.0.1' ],
1315- };
1316- mockHttpResponses['plugin2' ] = < String , dynamic > {
1317- 'name' : 'plugin2' ,
1318- 'versions' : < String > ['0.0.1' ],
1319- };
1331+ final List <String > output = await runCapturingPrint (
1332+ commandRunner,
1333+ < String > [
1334+ 'publish' ,
1335+ '--all-changed' ,
1336+ '--base-sha=HEAD~' ,
1337+ '--batch-release' ,
1338+ ],
1339+ );
1340+ // Package1 is published in batch realease, pacakge2 is not.
1341+ expect (
1342+ output,
1343+ containsAllInOrder (< Matcher > [
1344+ contains ('Running `pub publish ` in ${plugin1 .path }...' ),
1345+ contains ('Published plugin1 successfully!' ),
1346+ ]),
1347+ );
1348+
1349+ expect (
1350+ output,
1351+ isNot (
1352+ contains (
1353+ contains ('Running `pub publish ` in ${plugin2 .path }...!' ),
1354+ ),
1355+ ),
1356+ );
1357+ expect (
1358+ output,
1359+ isNot (contains (contains ('Published plugin2 successfully!' ))),
1360+ );
1361+ },
1362+ );
13201363
1321- final List <String > output = await runCapturingPrint (
1322- commandRunner, < String > [
1323- 'publish' ,
1324- '--all-changed' ,
1325- '--base-sha=HEAD~' ,
1326- '--batch-release' ,
1327- '--skip-confirmation'
1328- ]);
1364+ test (
1365+ 'filters packages based on the batch release flag value in ci_config.yaml' ,
1366+ () async {
1367+ // Mock pub.dev responses.
1368+ mockHttpResponses['plugin1' ] = < String , dynamic > {
1369+ 'name' : 'plugin1' ,
1370+ 'versions' : < String > ['0.0.1' ],
1371+ };
1372+ mockHttpResponses['plugin2' ] = < String , dynamic > {
1373+ 'name' : 'plugin2' ,
1374+ 'versions' : < String > ['0.0.1' ],
1375+ };
1376+
1377+ // Mock packages.
1378+ final RepositoryPackage plugin1 = createFakePlugin (
1379+ 'plugin1' ,
1380+ packagesDir,
1381+ version: '0.0.2' ,
1382+ batchRelease: true ,
1383+ );
1384+
1385+ final RepositoryPackage plugin2 = createFakePlugin (
1386+ 'plugin2' ,
1387+ packagesDir,
1388+ version: '0.0.2' ,
1389+ batchRelease: false ,
1390+ );
1391+
1392+ // Mock git diff to show both packages have changed.
1393+ processRunner
1394+ .mockProcessesForExecutable['git-diff' ] = < FakeProcessInfo > [
1395+ FakeProcessInfo (
1396+ MockProcess (
1397+ stdout:
1398+ '${plugin1 .pubspecFile .path }\n ${plugin2 .pubspecFile .path }' ,
1399+ ),
1400+ ),
1401+ ];
13291402
1330- expect (output, contains ('Publishing plugin1 version 1.0.0' ));
1331- expect (output, isNot (contains ('Publishing plugin2 version 1.0.0' )));
1332- });
1403+ mockStdin.readLineOutput = 'y' ;
13331404
1405+ final List <String > output = await runCapturingPrint (
1406+ commandRunner,
1407+ < String > [
1408+ 'publish' ,
1409+ '--all-changed' ,
1410+ '--base-sha=HEAD~' ,
1411+ '--batch-release' ,
1412+ ],
1413+ );
1414+ // Package1 is published in batch realease, pacakge2 is not.
1415+ expect (
1416+ output,
1417+ containsAllInOrder (< Matcher > [
1418+ contains ('Running `pub publish ` in ${plugin1 .path }...' ),
1419+ contains ('Published plugin1 successfully!' ),
1420+ ]),
1421+ );
1422+
1423+ expect (
1424+ output,
1425+ isNot (
1426+ contains (
1427+ contains ('Running `pub publish ` in ${plugin2 .path }...!' ),
1428+ ),
1429+ ),
1430+ );
1431+ expect (
1432+ output,
1433+ isNot (contains (contains ('Published plugin2 successfully!' ))),
1434+ );
1435+ },
1436+ );
13341437
1438+ test (
1439+ 'when --batch-release flag value is false, batch release packages are filtered out' ,
1440+ () async {
1441+ // Mock pub.dev responses.
1442+ mockHttpResponses['plugin1' ] = < String , dynamic > {
1443+ 'name' : 'plugin1' ,
1444+ 'versions' : < String > ['0.0.1' ],
1445+ };
1446+ mockHttpResponses['plugin2' ] = < String , dynamic > {
1447+ 'name' : 'plugin2' ,
1448+ 'versions' : < String > ['0.0.1' ],
1449+ };
1450+
1451+ // Mock packages.
1452+ final RepositoryPackage plugin1 = createFakePlugin (
1453+ 'plugin1' ,
1454+ packagesDir,
1455+ version: '0.0.2' ,
1456+ );
1457+
1458+ final RepositoryPackage plugin2 = createFakePlugin (
1459+ 'plugin2' ,
1460+ packagesDir,
1461+ version: '0.0.2' ,
1462+ batchRelease: true ,
1463+ );
1464+
1465+ // Mock git diff to show both packages have changed.
1466+ processRunner
1467+ .mockProcessesForExecutable['git-diff' ] = < FakeProcessInfo > [
1468+ FakeProcessInfo (
1469+ MockProcess (
1470+ stdout:
1471+ '${plugin1 .pubspecFile .path }\n ${plugin2 .pubspecFile .path }' ,
1472+ ),
1473+ ),
1474+ ];
1475+
1476+ mockStdin.readLineOutput = 'y' ;
1477+
1478+ final List <String > output = await runCapturingPrint (
1479+ commandRunner,
1480+ < String > ['publish' , '--all-changed' , '--base-sha=HEAD~' ],
1481+ );
1482+ // Package1 is published in batch realease, pacakge2 is not.
1483+ expect (
1484+ output,
1485+ containsAllInOrder (< Matcher > [
1486+ contains ('Running `pub publish ` in ${plugin1 .path }...' ),
1487+ contains ('Published plugin1 successfully!' ),
1488+ ]),
1489+ );
1490+
1491+ expect (
1492+ output,
1493+ isNot (
1494+ contains (
1495+ contains ('Running `pub publish ` in ${plugin2 .path }...!' ),
1496+ ),
1497+ ),
1498+ );
1499+ expect (
1500+ output,
1501+ isNot (contains (contains ('Published plugin2 successfully!' ))),
1502+ );
1503+ },
1504+ );
13351505 });
13361506
13371507 test ('Do not release flutter_plugin_tools' , () async {
0 commit comments