diff --git a/packages/flutter_tools/lib/src/commands/test.dart b/packages/flutter_tools/lib/src/commands/test.dart index d9148d8345..1d3be6d8cf 100644 --- a/packages/flutter_tools/lib/src/commands/test.dart +++ b/packages/flutter_tools/lib/src/commands/test.dart @@ -199,7 +199,7 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts { ) ..addOption('reporter', abbr: 'r', - help: 'Set how to print test results.', + help: 'Set how to print test results. If unset, value will default to either compact or expanded.', allowed: ['compact', 'expanded', 'github', 'json'], allowedHelp: { 'compact': 'A single line that updates dynamically (The default reporter).', @@ -213,7 +213,6 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts { 'in seconds (e.g. "60s"), ' 'as a multiplier of the default timeout (e.g. "2x"), ' 'or as the string "none" to disable the timeout entirely.', - defaultsTo: '30s', ); addDdsOptions(verboseHelp: verboseHelp); usesFatalWarningsOption(verboseHelp: verboseHelp); @@ -254,18 +253,6 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts { @override String get category => FlutterCommandCategory.project; - // Lookup the default reporter if one was not specified. - String _getReporter() { - final String? reporter = stringArgDeprecated('reporter'); - if (reporter != null) { - return reporter; - } - if (globals.platform.environment['GITHUB_ACTIONS']?.toLowerCase() == 'true') { - return 'github'; - } - return 'compact'; - } - @override Future verifyThenRunCommand(String? commandPath) { _testFiles = argResults!.rest.map(globals.fs.path.absolute).toList(); @@ -473,7 +460,7 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts { flutterProject: flutterProject, web: stringArgDeprecated('platform') == 'chrome', randomSeed: stringArgDeprecated('test-randomize-ordering-seed'), - reporter: _getReporter(), + reporter: stringArgDeprecated('reporter'), timeout: stringArgDeprecated('timeout'), runSkipped: boolArgDeprecated('run-skipped'), shardIndex: shardIndex, diff --git a/packages/flutter_tools/lib/src/test/runner.dart b/packages/flutter_tools/lib/src/test/runner.dart index 0bd675f040..878b9f2104 100644 --- a/packages/flutter_tools/lib/src/test/runner.dart +++ b/packages/flutter_tools/lib/src/test/runner.dart @@ -102,8 +102,8 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner { '--pause-after-load', if (machine) ...['-r', 'json'] - else - ...['-r', reporter ?? 'compact'], + else if (reporter != null) + ...['-r', reporter], if (timeout != null) ...['--timeout', timeout], '--concurrency=$concurrency', diff --git a/packages/flutter_tools/test/commands.shard/hermetic/test_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/test_test.dart index d4f3919403..4eba15ec00 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/test_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/test_test.dart @@ -10,7 +10,6 @@ import 'package:file/memory.dart'; import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/logger.dart'; -import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/commands/test.dart'; import 'package:flutter_tools/src/device.dart'; @@ -156,6 +155,30 @@ dev_dependencies: Cache: () => Cache.test(processManager: FakeProcessManager.any()), }); + testUsingContext( + 'Confirmation that the reporter and timeout args are not set by default', + () async { + final FakePackageTest fakePackageTest = FakePackageTest(); + + final TestCommand testCommand = TestCommand(testWrapper: fakePackageTest); + final CommandRunner commandRunner = + createTestCommandRunner(testCommand); + + await commandRunner.run(const [ + 'test', + '--no-pub', + ]); + + expect(fakePackageTest.lastArgs, isNot(contains('-r'))); + expect(fakePackageTest.lastArgs, isNot(contains('compact'))); + expect(fakePackageTest.lastArgs, isNot(contains('--timeout'))); + expect(fakePackageTest.lastArgs, isNot(contains('30s'))); + }, overrides: { + FileSystem: () => fs, + ProcessManager: () => FakeProcessManager.any(), + Cache: () => Cache.test(processManager: FakeProcessManager.any()), + }); + group('shard-index and total-shards', () { testUsingContext('with the params they are Piped to package:test', () async { @@ -661,60 +684,6 @@ dev_dependencies: ]), }); - testUsingContext('Tests on github actions default to github reporter', () async { - final FakeFlutterTestRunner testRunner = FakeFlutterTestRunner(0); - - final TestCommand testCommand = TestCommand(testRunner: testRunner); - final CommandRunner commandRunner = createTestCommandRunner(testCommand); - - await commandRunner.run(const [ - 'test', - '--no-pub', - ]); - - expect( - testRunner.lastReporterOption, - 'github', - ); - }, overrides: { - FileSystem: () => fs, - ProcessManager: () => FakeProcessManager.any(), - Platform: () => FakePlatform( - environment: { - 'GITHUB_ACTIONS': 'true', - }, - ), - DeviceManager: () => _FakeDeviceManager([ - FakeDevice('ephemeral', 'ephemeral', type: PlatformType.android), - ]), - }); - - testUsingContext('Tests default to compact reporter if not specified and not on Github actions', () async { - final FakeFlutterTestRunner testRunner = FakeFlutterTestRunner(0); - - final TestCommand testCommand = TestCommand(testRunner: testRunner); - final CommandRunner commandRunner = createTestCommandRunner(testCommand); - - await commandRunner.run(const [ - 'test', - '--no-pub', - ]); - - expect( - testRunner.lastReporterOption, - 'compact', - ); - }, overrides: { - FileSystem: () => fs, - ProcessManager: () => FakeProcessManager.any(), - Platform: () => FakePlatform( - environment: {} - ), - DeviceManager: () => _FakeDeviceManager([ - FakeDevice('ephemeral', 'ephemeral', type: PlatformType.android), - ]), - }); - testUsingContext('Integration tests given flavor', () async { final FakeFlutterTestRunner testRunner = FakeFlutterTestRunner(0); diff --git a/packages/flutter_tools/test/integration.shard/test_test.dart b/packages/flutter_tools/test/integration.shard/test_test.dart index a37b430214..0239969467 100644 --- a/packages/flutter_tools/test/integration.shard/test_test.dart +++ b/packages/flutter_tools/test/integration.shard/test_test.dart @@ -313,6 +313,8 @@ Future _runFlutterTest( '--no-color', '--no-version-check', '--no-pub', + '--reporter', + 'compact', ...extraArguments, testPath, ];