Skip to content

Commit d7454d5

Browse files
authored
removing default values for [reporter] and [timeout] in flutter test (#115160)
* removing default values for [reporter] and [timeout]] * passing reporter arg to see tests pass * added test to confirm TestCommand is not passing defaults * add'l helper message for [reporter] arg * default behavior for github actions + fixed tests * removing github conditional for reporter + related test * removing unused import
1 parent 243a830 commit d7454d5

File tree

4 files changed

+30
-72
lines changed

4 files changed

+30
-72
lines changed

packages/flutter_tools/lib/src/commands/test.dart

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
199199
)
200200
..addOption('reporter',
201201
abbr: 'r',
202-
help: 'Set how to print test results.',
202+
help: 'Set how to print test results. If unset, value will default to either compact or expanded.',
203203
allowed: <String>['compact', 'expanded', 'github', 'json'],
204204
allowedHelp: <String, String>{
205205
'compact': 'A single line that updates dynamically (The default reporter).',
@@ -213,7 +213,6 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
213213
'in seconds (e.g. "60s"), '
214214
'as a multiplier of the default timeout (e.g. "2x"), '
215215
'or as the string "none" to disable the timeout entirely.',
216-
defaultsTo: '30s',
217216
);
218217
addDdsOptions(verboseHelp: verboseHelp);
219218
usesFatalWarningsOption(verboseHelp: verboseHelp);
@@ -254,18 +253,6 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
254253
@override
255254
String get category => FlutterCommandCategory.project;
256255

257-
// Lookup the default reporter if one was not specified.
258-
String _getReporter() {
259-
final String? reporter = stringArgDeprecated('reporter');
260-
if (reporter != null) {
261-
return reporter;
262-
}
263-
if (globals.platform.environment['GITHUB_ACTIONS']?.toLowerCase() == 'true') {
264-
return 'github';
265-
}
266-
return 'compact';
267-
}
268-
269256
@override
270257
Future<FlutterCommandResult> verifyThenRunCommand(String? commandPath) {
271258
_testFiles = argResults!.rest.map<String>(globals.fs.path.absolute).toList();
@@ -473,7 +460,7 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
473460
flutterProject: flutterProject,
474461
web: stringArgDeprecated('platform') == 'chrome',
475462
randomSeed: stringArgDeprecated('test-randomize-ordering-seed'),
476-
reporter: _getReporter(),
463+
reporter: stringArgDeprecated('reporter'),
477464
timeout: stringArgDeprecated('timeout'),
478465
runSkipped: boolArgDeprecated('run-skipped'),
479466
shardIndex: shardIndex,

packages/flutter_tools/lib/src/test/runner.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner {
102102
'--pause-after-load',
103103
if (machine)
104104
...<String>['-r', 'json']
105-
else
106-
...<String>['-r', reporter ?? 'compact'],
105+
else if (reporter != null)
106+
...<String>['-r', reporter],
107107
if (timeout != null)
108108
...<String>['--timeout', timeout],
109109
'--concurrency=$concurrency',

packages/flutter_tools/test/commands.shard/hermetic/test_test.dart

Lines changed: 24 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import 'package:file/memory.dart';
1010
import 'package:flutter_tools/src/base/common.dart';
1111
import 'package:flutter_tools/src/base/file_system.dart';
1212
import 'package:flutter_tools/src/base/logger.dart';
13-
import 'package:flutter_tools/src/base/platform.dart';
1413
import 'package:flutter_tools/src/cache.dart';
1514
import 'package:flutter_tools/src/commands/test.dart';
1615
import 'package:flutter_tools/src/device.dart';
@@ -156,6 +155,30 @@ dev_dependencies:
156155
Cache: () => Cache.test(processManager: FakeProcessManager.any()),
157156
});
158157

158+
testUsingContext(
159+
'Confirmation that the reporter and timeout args are not set by default',
160+
() async {
161+
final FakePackageTest fakePackageTest = FakePackageTest();
162+
163+
final TestCommand testCommand = TestCommand(testWrapper: fakePackageTest);
164+
final CommandRunner<void> commandRunner =
165+
createTestCommandRunner(testCommand);
166+
167+
await commandRunner.run(const <String>[
168+
'test',
169+
'--no-pub',
170+
]);
171+
172+
expect(fakePackageTest.lastArgs, isNot(contains('-r')));
173+
expect(fakePackageTest.lastArgs, isNot(contains('compact')));
174+
expect(fakePackageTest.lastArgs, isNot(contains('--timeout')));
175+
expect(fakePackageTest.lastArgs, isNot(contains('30s')));
176+
}, overrides: <Type, Generator>{
177+
FileSystem: () => fs,
178+
ProcessManager: () => FakeProcessManager.any(),
179+
Cache: () => Cache.test(processManager: FakeProcessManager.any()),
180+
});
181+
159182
group('shard-index and total-shards', () {
160183
testUsingContext('with the params they are Piped to package:test',
161184
() async {
@@ -661,60 +684,6 @@ dev_dependencies:
661684
]),
662685
});
663686

664-
testUsingContext('Tests on github actions default to github reporter', () async {
665-
final FakeFlutterTestRunner testRunner = FakeFlutterTestRunner(0);
666-
667-
final TestCommand testCommand = TestCommand(testRunner: testRunner);
668-
final CommandRunner<void> commandRunner = createTestCommandRunner(testCommand);
669-
670-
await commandRunner.run(const <String>[
671-
'test',
672-
'--no-pub',
673-
]);
674-
675-
expect(
676-
testRunner.lastReporterOption,
677-
'github',
678-
);
679-
}, overrides: <Type, Generator>{
680-
FileSystem: () => fs,
681-
ProcessManager: () => FakeProcessManager.any(),
682-
Platform: () => FakePlatform(
683-
environment: <String, String>{
684-
'GITHUB_ACTIONS': 'true',
685-
},
686-
),
687-
DeviceManager: () => _FakeDeviceManager(<Device>[
688-
FakeDevice('ephemeral', 'ephemeral', type: PlatformType.android),
689-
]),
690-
});
691-
692-
testUsingContext('Tests default to compact reporter if not specified and not on Github actions', () async {
693-
final FakeFlutterTestRunner testRunner = FakeFlutterTestRunner(0);
694-
695-
final TestCommand testCommand = TestCommand(testRunner: testRunner);
696-
final CommandRunner<void> commandRunner = createTestCommandRunner(testCommand);
697-
698-
await commandRunner.run(const <String>[
699-
'test',
700-
'--no-pub',
701-
]);
702-
703-
expect(
704-
testRunner.lastReporterOption,
705-
'compact',
706-
);
707-
}, overrides: <Type, Generator>{
708-
FileSystem: () => fs,
709-
ProcessManager: () => FakeProcessManager.any(),
710-
Platform: () => FakePlatform(
711-
environment: <String, String>{}
712-
),
713-
DeviceManager: () => _FakeDeviceManager(<Device>[
714-
FakeDevice('ephemeral', 'ephemeral', type: PlatformType.android),
715-
]),
716-
});
717-
718687
testUsingContext('Integration tests given flavor', () async {
719688
final FakeFlutterTestRunner testRunner = FakeFlutterTestRunner(0);
720689

packages/flutter_tools/test/integration.shard/test_test.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ Future<ProcessResult> _runFlutterTest(
313313
'--no-color',
314314
'--no-version-check',
315315
'--no-pub',
316+
'--reporter',
317+
'compact',
316318
...extraArguments,
317319
testPath,
318320
];

0 commit comments

Comments
 (0)