* allow passing --file-reporter option to test running refs #69425 * Add trailing comma to help to meet style requirements * Add space between tests for clarity --------- Co-authored-by: daniel-v <dvarga@skawa.hu>
This commit is contained in:
parent
23df770860
commit
ebbc94bc2b
@ -208,6 +208,11 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
|
|||||||
'json': 'A machine-readable format. See: https://dart.dev/go/test-docs/json_reporter.md',
|
'json': 'A machine-readable format. See: https://dart.dev/go/test-docs/json_reporter.md',
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
..addOption('file-reporter',
|
||||||
|
help: 'Enable an additional reporter writing test results to a file.\n'
|
||||||
|
'Should be in the form <reporter>:<filepath>, '
|
||||||
|
'Example: "json:reports/tests.json".'
|
||||||
|
)
|
||||||
..addOption('timeout',
|
..addOption('timeout',
|
||||||
help: 'The default test timeout, specified either '
|
help: 'The default test timeout, specified either '
|
||||||
'in seconds (e.g. "60s"), '
|
'in seconds (e.g. "60s"), '
|
||||||
@ -463,6 +468,7 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
|
|||||||
web: stringArgDeprecated('platform') == 'chrome',
|
web: stringArgDeprecated('platform') == 'chrome',
|
||||||
randomSeed: stringArgDeprecated('test-randomize-ordering-seed'),
|
randomSeed: stringArgDeprecated('test-randomize-ordering-seed'),
|
||||||
reporter: stringArgDeprecated('reporter'),
|
reporter: stringArgDeprecated('reporter'),
|
||||||
|
fileReporter: stringArg('file-reporter'),
|
||||||
timeout: stringArgDeprecated('timeout'),
|
timeout: stringArgDeprecated('timeout'),
|
||||||
runSkipped: boolArgDeprecated('run-skipped'),
|
runSkipped: boolArgDeprecated('run-skipped'),
|
||||||
shardIndex: shardIndex,
|
shardIndex: shardIndex,
|
||||||
|
@ -45,6 +45,7 @@ abstract class FlutterTestRunner {
|
|||||||
bool web = false,
|
bool web = false,
|
||||||
String? randomSeed,
|
String? randomSeed,
|
||||||
String? reporter,
|
String? reporter,
|
||||||
|
String? fileReporter,
|
||||||
String? timeout,
|
String? timeout,
|
||||||
bool runSkipped = false,
|
bool runSkipped = false,
|
||||||
int? shardIndex,
|
int? shardIndex,
|
||||||
@ -82,6 +83,7 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner {
|
|||||||
bool web = false,
|
bool web = false,
|
||||||
String? randomSeed,
|
String? randomSeed,
|
||||||
String? reporter,
|
String? reporter,
|
||||||
|
String? fileReporter,
|
||||||
String? timeout,
|
String? timeout,
|
||||||
bool runSkipped = false,
|
bool runSkipped = false,
|
||||||
int? shardIndex,
|
int? shardIndex,
|
||||||
@ -103,6 +105,8 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner {
|
|||||||
...<String>['-r', 'json']
|
...<String>['-r', 'json']
|
||||||
else if (reporter != null)
|
else if (reporter != null)
|
||||||
...<String>['-r', reporter],
|
...<String>['-r', reporter],
|
||||||
|
if (fileReporter != null)
|
||||||
|
'--file-reporter=$fileReporter',
|
||||||
if (timeout != null)
|
if (timeout != null)
|
||||||
...<String>['--timeout', timeout],
|
...<String>['--timeout', timeout],
|
||||||
'--concurrency=$concurrency',
|
'--concurrency=$concurrency',
|
||||||
|
@ -804,6 +804,41 @@ dev_dependencies:
|
|||||||
ProcessManager: () => FakeProcessManager.any(),
|
ProcessManager: () => FakeProcessManager.any(),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
group('File Reporter', () {
|
||||||
|
testUsingContext('defaults to unset null value', () async {
|
||||||
|
final FakeFlutterTestRunner testRunner = FakeFlutterTestRunner(0);
|
||||||
|
|
||||||
|
final TestCommand testCommand = TestCommand(testRunner: testRunner);
|
||||||
|
final CommandRunner<void> commandRunner = createTestCommandRunner(testCommand);
|
||||||
|
|
||||||
|
await commandRunner.run(const <String>[
|
||||||
|
'test',
|
||||||
|
'--no-pub',
|
||||||
|
]);
|
||||||
|
expect(testRunner.lastFileReporterValue, null);
|
||||||
|
}, overrides: <Type, Generator>{
|
||||||
|
FileSystem: () => fs,
|
||||||
|
ProcessManager: () => FakeProcessManager.any(),
|
||||||
|
});
|
||||||
|
|
||||||
|
testUsingContext('when set --file-reporter value is passed on', () async {
|
||||||
|
final FakeFlutterTestRunner testRunner = FakeFlutterTestRunner(0);
|
||||||
|
|
||||||
|
final TestCommand testCommand = TestCommand(testRunner: testRunner);
|
||||||
|
final CommandRunner<void> commandRunner = createTestCommandRunner(testCommand);
|
||||||
|
|
||||||
|
await commandRunner.run(const <String>[
|
||||||
|
'test',
|
||||||
|
'--no-pub',
|
||||||
|
'--file-reporter=json:out.jsonl'
|
||||||
|
]);
|
||||||
|
expect(testRunner.lastFileReporterValue, 'json:out.jsonl');
|
||||||
|
}, overrides: <Type, Generator>{
|
||||||
|
FileSystem: () => fs,
|
||||||
|
ProcessManager: () => FakeProcessManager.any(),
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
class FakeFlutterTestRunner implements FlutterTestRunner {
|
class FakeFlutterTestRunner implements FlutterTestRunner {
|
||||||
@ -813,6 +848,7 @@ class FakeFlutterTestRunner implements FlutterTestRunner {
|
|||||||
Duration? leastRunTime;
|
Duration? leastRunTime;
|
||||||
bool? lastEnableObservatoryValue;
|
bool? lastEnableObservatoryValue;
|
||||||
late DebuggingOptions lastDebuggingOptionsValue;
|
late DebuggingOptions lastDebuggingOptionsValue;
|
||||||
|
String? lastFileReporterValue;
|
||||||
String? lastReporterOption;
|
String? lastReporterOption;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -839,6 +875,7 @@ class FakeFlutterTestRunner implements FlutterTestRunner {
|
|||||||
bool web = false,
|
bool web = false,
|
||||||
String? randomSeed,
|
String? randomSeed,
|
||||||
String? reporter,
|
String? reporter,
|
||||||
|
String? fileReporter,
|
||||||
String? timeout,
|
String? timeout,
|
||||||
bool runSkipped = false,
|
bool runSkipped = false,
|
||||||
int? shardIndex,
|
int? shardIndex,
|
||||||
@ -849,6 +886,7 @@ class FakeFlutterTestRunner implements FlutterTestRunner {
|
|||||||
}) async {
|
}) async {
|
||||||
lastEnableObservatoryValue = enableObservatory;
|
lastEnableObservatoryValue = enableObservatory;
|
||||||
lastDebuggingOptionsValue = debuggingOptions;
|
lastDebuggingOptionsValue = debuggingOptions;
|
||||||
|
lastFileReporterValue = fileReporter;
|
||||||
lastReporterOption = reporter;
|
lastReporterOption = reporter;
|
||||||
|
|
||||||
if (leastRunTime != null) {
|
if (leastRunTime != null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user