mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Fix that flutter test
does not understand concurrency
(#125942)
Close https://github.com/flutter/flutter/issues/125940 I will add tests if this PR looks roughly OK :) The fix mainly mimics https://github.com/flutter/flutter/pull/115160 - just remove the default argument. p.s. I ran into this bug when wanting to set concurrency in my dart_test.yaml for one set of my tests which I need to be executed without parallalization.
This commit is contained in:
parent
6b756ab5ff
commit
742a1b49e9
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import '../asset.dart';
|
||||
@ -146,7 +144,6 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
|
||||
)
|
||||
..addOption('concurrency',
|
||||
abbr: 'j',
|
||||
defaultsTo: math.max<int>(1, globals.platform.numberOfProcessors - 2).toString(),
|
||||
help: 'The number of concurrent test processes to run. This will be ignored '
|
||||
'when running integration tests.',
|
||||
valueHelp: 'jobs',
|
||||
@ -353,8 +350,9 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
|
||||
);
|
||||
}
|
||||
|
||||
int? jobs = int.tryParse(stringArg('concurrency')!);
|
||||
if (jobs == null || jobs <= 0 || !jobs.isFinite) {
|
||||
final String? concurrencyString = stringArg('concurrency');
|
||||
int? jobs = concurrencyString == null ? null : int.tryParse(concurrencyString);
|
||||
if (jobs != null && (jobs <= 0 || !jobs.isFinite)) {
|
||||
throwToolExit(
|
||||
'Could not parse -j/--concurrency argument. It must be an integer greater than zero.'
|
||||
);
|
||||
|
@ -109,7 +109,8 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner {
|
||||
'--file-reporter=$fileReporter',
|
||||
if (timeout != null)
|
||||
...<String>['--timeout', timeout],
|
||||
'--concurrency=$concurrency',
|
||||
if (concurrency != null)
|
||||
'--concurrency=$concurrency',
|
||||
for (final String name in names)
|
||||
...<String>['--name', name],
|
||||
for (final String plainName in plainNames)
|
||||
|
@ -158,7 +158,7 @@ dev_dependencies:
|
||||
});
|
||||
|
||||
testUsingContext(
|
||||
'Confirmation that the reporter and timeout args are not set by default',
|
||||
'Confirmation that the reporter, timeout, and concurrency args are not set by default',
|
||||
() async {
|
||||
final FakePackageTest fakePackageTest = FakePackageTest();
|
||||
|
||||
@ -175,6 +175,7 @@ dev_dependencies:
|
||||
expect(fakePackageTest.lastArgs, isNot(contains('compact')));
|
||||
expect(fakePackageTest.lastArgs, isNot(contains('--timeout')));
|
||||
expect(fakePackageTest.lastArgs, isNot(contains('30s')));
|
||||
expect(fakePackageTest.lastArgs, isNot(contains('--concurrency')));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fs,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
|
Loading…
Reference in New Issue
Block a user