Unverified Commit 94a30ddc authored by Kenzie Schmoll's avatar Kenzie Schmoll Committed by GitHub

Add text to --analyze-size command output to launch DevTools with size data (#72295)

* Add text to --analyze-size command output to launch DevTools with size data.
parent c1d3de60
......@@ -540,6 +540,14 @@ Future<void> _performCodeSizeAnalysis(
globals.printStatus(
'A summary of your ${kind.toUpperCase()} analysis can be found at: ${outputFile.path}',
);
// DevTools expects a file path relative to the .flutter-devtools/ dir.
final String relativeAppSizePath = outputFile.path.split('.flutter-devtools/').last.trim();
globals.printStatus(
'\nTo analyze your app size in Dart DevTools, run the following command:\n'
'flutter pub global activate devtools; flutter pub global run devtools '
'--appSizeBase=$relativeAppSizePath'
);
}
/// Builds AAR and POM files.
......
......@@ -294,6 +294,14 @@ abstract class _BuildIOSSubCommand extends BuildSubCommand {
globals.printStatus(
'A summary of your iOS bundle analysis can be found at: ${outputFile.path}',
);
// DevTools expects a file path relative to the .flutter-devtools/ dir.
final String relativeAppSizePath = outputFile.path.split('.flutter-devtools/').last.trim();
globals.printStatus(
'\nTo analyze your app size in Dart DevTools, run the following command:\n'
'flutter pub global activate devtools; flutter pub global run devtools '
'--appSizeBase=$relativeAppSizePath'
);
}
if (result.output != null) {
......
......@@ -84,6 +84,14 @@ Future<void> buildLinux(
globals.printStatus(
'A summary of your Linux bundle analysis can be found at: ${outputFile.path}',
);
// DevTools expects a file path relative to the .flutter-devtools/ dir.
final String relativeAppSizePath = outputFile.path.split('.flutter-devtools/').last.trim();
globals.printStatus(
'\nTo analyze your app size in Dart DevTools, run the following command:\n'
'flutter pub global activate devtools; flutter pub global run devtools '
'--appSizeBase=$relativeAppSizePath'
);
}
}
......
......@@ -140,6 +140,14 @@ Future<void> buildMacOS({
globals.printStatus(
'A summary of your macOS bundle analysis can be found at: ${outputFile.path}',
);
// DevTools expects a file path relative to the .flutter-devtools/ dir.
final String relativeAppSizePath = outputFile.path.split('.flutter-devtools/').last.trim();
globals.printStatus(
'\nTo analyze your app size in Dart DevTools, run the following command:\n'
'flutter pub global activate devtools; flutter pub global run devtools '
'--appSizeBase=$relativeAppSizePath'
);
}
globals.flutterUsage.sendTiming('build', 'xcode-macos', Duration(milliseconds: sw.elapsedMilliseconds));
}
......@@ -86,6 +86,14 @@ Future<void> buildWindows(WindowsProject windowsProject, BuildInfo buildInfo, {
globals.printStatus(
'A summary of your Windows bundle analysis can be found at: ${outputFile.path}',
);
// DevTools expects a file path relative to the .flutter-devtools/ dir.
final String relativeAppSizePath = outputFile.path.split('.flutter-devtools/').last.trim();
globals.printStatus(
'\nTo analyze your app size in Dart DevTools, run the following command:\n'
'flutter pub global activate devtools; flutter pub global run devtools '
'--appSizeBase=$relativeAppSizePath'
);
}
}
......
......@@ -249,6 +249,7 @@ void main() {
);
expect(testLogger.statusText, contains('A summary of your iOS bundle analysis can be found at'));
expect(testLogger.statusText, contains('flutter pub global activate devtools; flutter pub global run devtools --appSizeBase='));
expect(buffer.toString(), contains('event {category: code-size-analysis, action: ios, label: null, value: null, cd33: '));
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
......
......@@ -459,6 +459,7 @@ set(BINARY_NAME "fizz_bar")
);
expect(testLogger.statusText, contains('A summary of your Linux bundle analysis can be found at'));
expect(testLogger.statusText, contains('flutter pub global activate devtools; flutter pub global run devtools --appSizeBase='));
expect(buffer.toString(), contains('event {category: code-size-analysis, action: linux, label: null, value: null, cd33:'));
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
......
......@@ -345,6 +345,7 @@ void main() {
);
expect(testLogger.statusText, contains('A summary of your macOS bundle analysis can be found at'));
expect(testLogger.statusText, contains('flutter pub global activate devtools; flutter pub global run devtools --appSizeBase='));
expect(buffer.toString(), contains('event {category: code-size-analysis, action: macos, label: null, value: null, cd33:'));
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
......
......@@ -407,6 +407,7 @@ C:\foo\windows\runner\main.cpp(17,1): error C2065: 'Baz': undeclared identifier
);
expect(testLogger.statusText, contains('A summary of your Windows bundle analysis can be found at'));
expect(testLogger.statusText, contains('flutter pub global activate devtools; flutter pub global run devtools --appSizeBase='));
expect(buffer.toString(), contains('event {category: code-size-analysis, action: windows, label: null, value: null, cd33:'));
}, overrides: <Type, Generator>{
FeatureFlags: () => TestFeatureFlags(isWindowsEnabled: true),
......
......@@ -10,10 +10,11 @@ import 'test_utils.dart';
const String apkDebugMessage = 'A summary of your APK analysis can be found at: ';
const String iosDebugMessage = 'A summary of your iOS bundle analysis can be found at: ';
const String runDevToolsMessage = 'flutter pub global activate devtools; flutter pub global run devtools ';
void main() {
testWithoutContext('--analyze-size flag produces expected output on hello_world for Android', () async {
final String woringDirectory = fileSystem.path.join(getFlutterRoot(), 'examples', 'hello_world');
final String workingDirectory = fileSystem.path.join(getFlutterRoot(), 'examples', 'hello_world');
final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter');
final ProcessResult result = await processManager.run(<String>[
flutterBin,
......@@ -22,7 +23,7 @@ void main() {
'apk',
'--analyze-size',
'--target-platform=android-arm64'
], workingDirectory: fileSystem.path.join(getFlutterRoot(), 'examples', 'hello_world'));
], workingDirectory: workingDirectory);
print(result.stdout);
print(result.stderr);
......@@ -33,13 +34,21 @@ void main() {
.firstWhere((String line) => line.contains(apkDebugMessage));
final String outputFilePath = line.split(apkDebugMessage).last.trim();
expect(fileSystem.file(fileSystem.path.join(woringDirectory, outputFilePath)), exists);
expect(fileSystem.file(fileSystem.path.join(workingDirectory, outputFilePath)), exists);
expect(outputFilePath, contains('.flutter-devtools'));
final String devToolsCommand = result.stdout.toString()
.split('\n')
.firstWhere((String line) => line.contains(runDevToolsMessage));
final String commandArguments = devToolsCommand.split(runDevToolsMessage).last.trim();
final String relativeAppSizePath = outputFilePath.split('.flutter-devtools/').last.trim();
expect(commandArguments.contains('--appSizeBase=$relativeAppSizePath'), isTrue);
expect(result.exitCode, 0);
});
testWithoutContext('--analyze-size flag produces expected output on hello_world for iOS', () async {
final String woringDirectory = fileSystem.path.join(getFlutterRoot(), 'examples', 'hello_world');
final String workingDirectory = fileSystem.path.join(getFlutterRoot(), 'examples', 'hello_world');
final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter');
final ProcessResult result = await processManager.run(<String>[
flutterBin,
......@@ -48,7 +57,7 @@ void main() {
'ios',
'--analyze-size',
'--no-codesign',
], workingDirectory: woringDirectory);
], workingDirectory: workingDirectory);
print(result.stdout);
print(result.stderr);
......@@ -59,7 +68,15 @@ void main() {
.firstWhere((String line) => line.contains(iosDebugMessage));
final String outputFilePath = line.split(iosDebugMessage).last.trim();
expect(fileSystem.file(fileSystem.path.join(woringDirectory, outputFilePath)), exists);
expect(fileSystem.file(fileSystem.path.join(workingDirectory, outputFilePath)), exists);
final String devToolsCommand = result.stdout.toString()
.split('\n')
.firstWhere((String line) => line.contains(runDevToolsMessage));
final String commandArguments = devToolsCommand.split(runDevToolsMessage).last.trim();
final String relativeAppSizePath = outputFilePath.split('.flutter-devtools/').last.trim();
expect(commandArguments.contains('--appSizeBase=$relativeAppSizePath'), isTrue);
expect(result.exitCode, 0);
}, skip: true); // Extremely flaky due to https://github.com/flutter/flutter/issues/68144
......
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