From b7bb9db36c8175298c7276b5f6e549ad5ca7cf9a Mon Sep 17 00:00:00 2001 From: stuartmorgan Date: Fri, 30 Sep 2022 17:55:50 -0400 Subject: [PATCH] [tool] Improve changed-package run mode logging (#6521) --- .../tool/lib/src/common/package_command.dart | 9 ++-- .../test/common/package_command_test.dart | 51 ++++++++++++++++--- 2 files changed, 50 insertions(+), 10 deletions(-) diff --git a/script/tool/lib/src/common/package_command.dart b/script/tool/lib/src/common/package_command.dart index 1d82c4e936b6..0e83d03e9846 100644 --- a/script/tool/lib/src/common/package_command.dart +++ b/script/tool/lib/src/common/package_command.dart @@ -338,11 +338,14 @@ abstract class PackageCommand extends Command { if (changedFileFinder != null) { final String baseSha = await changedFileFinder.getBaseSha(); - print( - 'Running for all packages that have diffs relative to "$baseSha"\n'); final List changedFiles = await changedFileFinder.getChangedFiles(); - if (!_changesRequireFullTest(changedFiles)) { + if (_changesRequireFullTest(changedFiles)) { + print('Running for all packages, since a file has changed that could ' + 'affect the entire repository.'); + } else { + print( + 'Running for all packages that have diffs relative to "$baseSha"\n'); packages = _getChangedPackageNames(changedFiles); } } else if (getBoolArg(_runOnDirtyPackagesArg)) { diff --git a/script/tool/test/common/package_command_test.dart b/script/tool/test/common/package_command_test.dart index be21b86bff79..aa0a20253955 100644 --- a/script/tool/test/common/package_command_test.dart +++ b/script/tool/test/common/package_command_test.dart @@ -408,11 +408,18 @@ packages/plugin1/CHANGELOG createFakePlugin('plugin1', packagesDir); final RepositoryPackage plugin2 = createFakePlugin('plugin2', packagesDir); - await runCapturingPrint(runner, + + final List output = await runCapturingPrint(runner, ['sample', '--base-sha=main', '--run-on-changed-packages']); expect(command.plugins, unorderedEquals([plugin1.path, plugin2.path])); + expect( + output, + containsAllInOrder([ + contains('Running for all packages, since a file has changed ' + 'that could affect the entire repository.') + ])); }); test('all plugins should be tested if .ci.yaml changes', () async { @@ -426,11 +433,17 @@ packages/plugin1/CHANGELOG createFakePlugin('plugin1', packagesDir); final RepositoryPackage plugin2 = createFakePlugin('plugin2', packagesDir); - await runCapturingPrint(runner, + final List output = await runCapturingPrint(runner, ['sample', '--base-sha=main', '--run-on-changed-packages']); expect(command.plugins, unorderedEquals([plugin1.path, plugin2.path])); + expect( + output, + containsAllInOrder([ + contains('Running for all packages, since a file has changed ' + 'that could affect the entire repository.') + ])); }); test('all plugins should be tested if anything in .ci/ changes', @@ -445,14 +458,20 @@ packages/plugin1/CHANGELOG createFakePlugin('plugin1', packagesDir); final RepositoryPackage plugin2 = createFakePlugin('plugin2', packagesDir); - await runCapturingPrint(runner, + final List output = await runCapturingPrint(runner, ['sample', '--base-sha=main', '--run-on-changed-packages']); expect(command.plugins, unorderedEquals([plugin1.path, plugin2.path])); + expect( + output, + containsAllInOrder([ + contains('Running for all packages, since a file has changed ' + 'that could affect the entire repository.') + ])); }); - test('all plugins should be tested if anything in script changes.', + test('all plugins should be tested if anything in script/ changes.', () async { processRunner.mockProcessesForExecutable['git-diff'] = [ MockProcess(stdout: ''' @@ -464,11 +483,17 @@ packages/plugin1/CHANGELOG createFakePlugin('plugin1', packagesDir); final RepositoryPackage plugin2 = createFakePlugin('plugin2', packagesDir); - await runCapturingPrint(runner, + final List output = await runCapturingPrint(runner, ['sample', '--base-sha=main', '--run-on-changed-packages']); expect(command.plugins, unorderedEquals([plugin1.path, plugin2.path])); + expect( + output, + containsAllInOrder([ + contains('Running for all packages, since a file has changed ' + 'that could affect the entire repository.') + ])); }); test('all plugins should be tested if the root analysis options change.', @@ -483,11 +508,17 @@ packages/plugin1/CHANGELOG createFakePlugin('plugin1', packagesDir); final RepositoryPackage plugin2 = createFakePlugin('plugin2', packagesDir); - await runCapturingPrint(runner, + final List output = await runCapturingPrint(runner, ['sample', '--base-sha=main', '--run-on-changed-packages']); expect(command.plugins, unorderedEquals([plugin1.path, plugin2.path])); + expect( + output, + containsAllInOrder([ + contains('Running for all packages, since a file has changed ' + 'that could affect the entire repository.') + ])); }); test('all plugins should be tested if formatting options change.', @@ -502,11 +533,17 @@ packages/plugin1/CHANGELOG createFakePlugin('plugin1', packagesDir); final RepositoryPackage plugin2 = createFakePlugin('plugin2', packagesDir); - await runCapturingPrint(runner, + final List output = await runCapturingPrint(runner, ['sample', '--base-sha=main', '--run-on-changed-packages']); expect(command.plugins, unorderedEquals([plugin1.path, plugin2.path])); + expect( + output, + containsAllInOrder([ + contains('Running for all packages, since a file has changed ' + 'that could affect the entire repository.') + ])); }); test('Only changed plugin should be tested.', () async {