Unverified Commit daaa32bc authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Add CustomDimensions.commandRunIsTest (#124135)

parent 0cfcdeec
...@@ -498,6 +498,7 @@ class RunCommand extends RunCommandBase { ...@@ -498,6 +498,7 @@ class RunCommand extends RunCommandBase {
commandRunAndroidEmbeddingVersion: androidEmbeddingVersion, commandRunAndroidEmbeddingVersion: androidEmbeddingVersion,
commandRunEnableImpeller: enableImpeller.asBool, commandRunEnableImpeller: enableImpeller.asBool,
commandRunIOSInterfaceType: iOSInterfaceType, commandRunIOSInterfaceType: iOSInterfaceType,
commandRunIsTest: targetFile.endsWith('_test.dart'),
); );
} }
......
...@@ -68,6 +68,7 @@ class CustomDimensions { ...@@ -68,6 +68,7 @@ class CustomDimensions {
this.hotEventReloadVMTimeInMs, this.hotEventReloadVMTimeInMs,
this.commandRunEnableImpeller, this.commandRunEnableImpeller,
this.commandRunIOSInterfaceType, this.commandRunIOSInterfaceType,
this.commandRunIsTest,
}); });
final String? sessionHostOsDetails; // cd1 final String? sessionHostOsDetails; // cd1
...@@ -127,6 +128,7 @@ class CustomDimensions { ...@@ -127,6 +128,7 @@ class CustomDimensions {
final int? hotEventReloadVMTimeInMs; // cd 55 final int? hotEventReloadVMTimeInMs; // cd 55
final bool? commandRunEnableImpeller; // cd 56 final bool? commandRunEnableImpeller; // cd 56
final String? commandRunIOSInterfaceType; // cd 57 final String? commandRunIOSInterfaceType; // cd 57
final bool? commandRunIsTest; // cd 58
/// Convert to a map that will be used to upload to the analytics backend. /// Convert to a map that will be used to upload to the analytics backend.
Map<String, String> toMap() => <String, String>{ Map<String, String> toMap() => <String, String>{
...@@ -187,6 +189,7 @@ class CustomDimensions { ...@@ -187,6 +189,7 @@ class CustomDimensions {
if (hotEventReloadVMTimeInMs != null) cdKey(CustomDimensionsEnum.hotEventReloadVMTimeInMs): hotEventReloadVMTimeInMs.toString(), if (hotEventReloadVMTimeInMs != null) cdKey(CustomDimensionsEnum.hotEventReloadVMTimeInMs): hotEventReloadVMTimeInMs.toString(),
if (commandRunEnableImpeller != null) cdKey(CustomDimensionsEnum.commandRunEnableImpeller): commandRunEnableImpeller.toString(), if (commandRunEnableImpeller != null) cdKey(CustomDimensionsEnum.commandRunEnableImpeller): commandRunEnableImpeller.toString(),
if (commandRunIOSInterfaceType != null) cdKey(CustomDimensionsEnum.commandRunIOSInterfaceType): commandRunIOSInterfaceType.toString(), if (commandRunIOSInterfaceType != null) cdKey(CustomDimensionsEnum.commandRunIOSInterfaceType): commandRunIOSInterfaceType.toString(),
if (commandRunIsTest != null) cdKey(CustomDimensionsEnum.commandRunIsTest): commandRunIsTest.toString(),
}; };
/// Merge the values of two [CustomDimensions] into one. If a value is defined /// Merge the values of two [CustomDimensions] into one. If a value is defined
...@@ -254,6 +257,7 @@ class CustomDimensions { ...@@ -254,6 +257,7 @@ class CustomDimensions {
hotEventReloadVMTimeInMs: other.hotEventReloadVMTimeInMs ?? hotEventReloadVMTimeInMs, hotEventReloadVMTimeInMs: other.hotEventReloadVMTimeInMs ?? hotEventReloadVMTimeInMs,
commandRunEnableImpeller: other.commandRunEnableImpeller ?? commandRunEnableImpeller, commandRunEnableImpeller: other.commandRunEnableImpeller ?? commandRunEnableImpeller,
commandRunIOSInterfaceType: other.commandRunIOSInterfaceType ?? commandRunIOSInterfaceType, commandRunIOSInterfaceType: other.commandRunIOSInterfaceType ?? commandRunIOSInterfaceType,
commandRunIsTest: other.commandRunIsTest ?? commandRunIsTest,
); );
} }
...@@ -315,6 +319,7 @@ class CustomDimensions { ...@@ -315,6 +319,7 @@ class CustomDimensions {
hotEventReloadVMTimeInMs: _extractInt(map, CustomDimensionsEnum.hotEventReloadVMTimeInMs), hotEventReloadVMTimeInMs: _extractInt(map, CustomDimensionsEnum.hotEventReloadVMTimeInMs),
commandRunEnableImpeller: _extractBool(map, CustomDimensionsEnum.commandRunEnableImpeller), commandRunEnableImpeller: _extractBool(map, CustomDimensionsEnum.commandRunEnableImpeller),
commandRunIOSInterfaceType: _extractString(map, CustomDimensionsEnum.commandRunIOSInterfaceType), commandRunIOSInterfaceType: _extractString(map, CustomDimensionsEnum.commandRunIOSInterfaceType),
commandRunIsTest: _extractBool(map, CustomDimensionsEnum.commandRunIsTest),
); );
static bool? _extractBool(Map<String, String> map, CustomDimensionsEnum field) => static bool? _extractBool(Map<String, String> map, CustomDimensionsEnum field) =>
...@@ -402,6 +407,7 @@ enum CustomDimensionsEnum { ...@@ -402,6 +407,7 @@ enum CustomDimensionsEnum {
hotEventReloadVMTimeInMs, // cd55 hotEventReloadVMTimeInMs, // cd55
commandRunEnableImpeller, // cd56 commandRunEnableImpeller, // cd56
commandRunIOSInterfaceType, // cd57 commandRunIOSInterfaceType, // cd57
commandRunIsTest, // cd58
} }
String cdKey(CustomDimensionsEnum cd) => 'cd${cd.index + 1}'; String cdKey(CustomDimensionsEnum cd) => 'cd${cd.index + 1}';
...@@ -475,6 +475,7 @@ void main() { ...@@ -475,6 +475,7 @@ void main() {
'cd3': 'false', 'cd4': 'ios', 'cd22': 'iOS 13', 'cd3': 'false', 'cd4': 'ios', 'cd22': 'iOS 13',
'cd23': 'debug', 'cd18': 'false', 'cd15': 'swift', 'cd31': 'true', 'cd23': 'debug', 'cd18': 'false', 'cd15': 'swift', 'cd31': 'true',
'cd57': 'usb', 'cd57': 'usb',
'cd58': 'false',
}) })
))); )));
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
...@@ -488,6 +489,41 @@ void main() { ...@@ -488,6 +489,41 @@ void main() {
Usage: () => usage, Usage: () => usage,
}); });
testUsingContext('correctly reports tests to usage', () async {
fs.currentDirectory.childDirectory('test').childFile('widget_test.dart').createSync(recursive: true);
fs.currentDirectory.childDirectory('ios').childFile('AppDelegate.swift').createSync(recursive: true);
final RunCommand command = RunCommand();
final FakeDevice mockDevice = FakeDevice(sdkNameAndVersion: 'iOS 13')
..startAppSuccess = false;
testDeviceManager.devices = <Device>[mockDevice];
await expectToolExitLater(createTestCommandRunner(command).run(<String>[
'run',
'--no-pub',
'--no-hot',
'test/widget_test.dart',
]), isNull);
expect(usage.commands, contains(
TestUsageCommand('run', parameters: CustomDimensions.fromMap(<String, String>{
'cd3': 'false', 'cd4': 'ios', 'cd22': 'iOS 13',
'cd23': 'debug', 'cd18': 'false', 'cd15': 'swift', 'cd31': 'true',
'cd57': 'usb',
'cd58': 'true',
})),
));
}, overrides: <Type, Generator>{
AnsiTerminal: () => fakeTerminal,
Artifacts: () => artifacts,
Cache: () => Cache.test(processManager: FakeProcessManager.any()),
DeviceManager: () => testDeviceManager,
FileSystem: () => fs,
ProcessManager: () => FakeProcessManager.any(),
Stdio: () => FakeStdio(),
Usage: () => usage,
});
group('--machine', () { group('--machine', () {
testUsingContext('enables multidex by default', () async { testUsingContext('enables multidex by default', () async {
final DaemonCapturingRunCommand command = DaemonCapturingRunCommand(); final DaemonCapturingRunCommand command = DaemonCapturingRunCommand();
...@@ -745,6 +781,7 @@ void main() { ...@@ -745,6 +781,7 @@ void main() {
commandRunModeName: 'debug', commandRunModeName: 'debug',
commandRunProjectModule: false, commandRunProjectModule: false,
commandRunProjectHostLanguage: '', commandRunProjectHostLanguage: '',
commandRunIsTest: false,
)); ));
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
DeviceManager: () => testDeviceManager, DeviceManager: () => testDeviceManager,
...@@ -785,6 +822,7 @@ void main() { ...@@ -785,6 +822,7 @@ void main() {
commandRunProjectModule: false, commandRunProjectModule: false,
commandRunProjectHostLanguage: '', commandRunProjectHostLanguage: '',
commandRunIOSInterfaceType: 'usb', commandRunIOSInterfaceType: 'usb',
commandRunIsTest: false,
)); ));
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
DeviceManager: () => testDeviceManager, DeviceManager: () => testDeviceManager,
...@@ -828,6 +866,7 @@ void main() { ...@@ -828,6 +866,7 @@ void main() {
commandRunProjectModule: false, commandRunProjectModule: false,
commandRunProjectHostLanguage: '', commandRunProjectHostLanguage: '',
commandRunIOSInterfaceType: 'wireless', commandRunIOSInterfaceType: 'wireless',
commandRunIsTest: false,
)); ));
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
DeviceManager: () => testDeviceManager, DeviceManager: () => testDeviceManager,
...@@ -871,6 +910,7 @@ void main() { ...@@ -871,6 +910,7 @@ void main() {
commandRunProjectModule: false, commandRunProjectModule: false,
commandRunProjectHostLanguage: '', commandRunProjectHostLanguage: '',
commandRunIOSInterfaceType: 'wireless', commandRunIOSInterfaceType: 'wireless',
commandRunIsTest: false,
)); ));
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
DeviceManager: () => testDeviceManager, DeviceManager: () => testDeviceManager,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment