mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Avoid using platform ProcessInfo.maxRss
in test. (#158526)
Closes https://github.com/flutter/flutter/issues/157629. Avoids failures in the style: ```txt 00:37 +4597 ~3 -1: /Users/matanl/Developer/flutter/packages/flutter_tools/test/commands.shard/permeable/build_appbundle_test.dart: analytics logs success [E] Expected: contains Event:<{"eventName":"flutter_command_result","eventData":{"commandPath":"create","result":"success","commandHasTerminal":false,"maxRss":147013632}}> Actual: [ Event:{"eventName":"command_usage_values","eventData":{"workflow":"create","commandHasTerminal":false,"createProjectType":"app","createAndroidLanguage":"kotlin","createIosLanguage":"swift"}}, Event:{"eventName":"flutter_command_result","eventData":{"commandPath":"create","result":"success","commandHasTerminal":false,"maxRss":143261696}}, Event:{"eventName":"timing","eventData":{"workflow":"flutter","variableName":"create","elapsedMilliseconds":527,"label":"success"}}, Event:{"eventName":"command_usage_values","eventData":{"workflow":"appbundle","commandHasTerminal":false,"buildAppBundleTargetPlatform":"android-arm,android-arm64,android-x64","buildAppBundleBuildMode":"release"}}, Event:{"eventName":"flutter_command_result","eventData":{"commandPath":"appbundle","result":"success","commandHasTerminal":false,"maxRss":147013632}}, Event:{"eventName":"timing","eventData":{"workflow":"flutter","variableName":"appbundle","elapsedMilliseconds":10,"label":"success"}} ] Which: does not contain Event:<{"eventName":"flutter_command_result","eventData":{"commandPath":"create","result":"success","commandHasTerminal":false,"maxRss":147013632}}> ``` I am guessing <https://api.flutter.dev/flutter/dart-io/ProcessInfo/maxRss.html> is not guaranteed to be stable while running, and as a result is not. This stabilizes the value for a test that I believe does not care about getting the "real" value anyway.
This commit is contained in:
parent
364901da54
commit
ed553d10cf
@ -7,6 +7,7 @@ import 'package:file/memory.dart';
|
||||
import 'package:flutter_tools/src/android/android_builder.dart';
|
||||
import 'package:flutter_tools/src/android/android_sdk.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/commands/build_appbundle.dart';
|
||||
@ -27,6 +28,7 @@ void main() {
|
||||
group('analytics', () {
|
||||
late Directory tempDir;
|
||||
late FakeAnalytics fakeAnalytics;
|
||||
late FakeProcessInfo processInfo;
|
||||
|
||||
setUp(() {
|
||||
tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.');
|
||||
@ -34,6 +36,7 @@ void main() {
|
||||
fs: MemoryFileSystem.test(),
|
||||
fakeFlutterVersion: FakeFlutterVersion(),
|
||||
);
|
||||
processInfo = FakeProcessInfo();
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
@ -135,7 +138,7 @@ void main() {
|
||||
commandPath: 'create',
|
||||
result: 'success',
|
||||
commandHasTerminal: false,
|
||||
maxRss: globals.processInfo.maxRss,
|
||||
maxRss: processInfo.maxRss,
|
||||
),
|
||||
),
|
||||
);
|
||||
@ -143,6 +146,7 @@ void main() {
|
||||
overrides: <Type, Generator>{
|
||||
AndroidBuilder: () => FakeAndroidBuilder(),
|
||||
Analytics: () => fakeAnalytics,
|
||||
ProcessInfo: () => processInfo,
|
||||
});
|
||||
});
|
||||
|
||||
@ -291,3 +295,8 @@ class FakeAndroidSdk extends Fake implements AndroidSdk {
|
||||
@override
|
||||
final Directory directory;
|
||||
}
|
||||
|
||||
class FakeProcessInfo extends Fake implements ProcessInfo {
|
||||
@override
|
||||
int maxRss = 123456789;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user