Unverified Commit b4c79239 authored by Alexander Aprelev's avatar Alexander Aprelev Committed by GitHub

Cleanup accidental use of global fs in test. (#48358)

This is follow-up to https://github.com/flutter/flutter/commit/ee7a37f1d3f12ca815d755a557f16765942897a4.
parent 1c79347e
...@@ -11,7 +11,6 @@ import 'package:flutter_tools/src/base/io.dart'; ...@@ -11,7 +11,6 @@ import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/ios/xcodeproj.dart'; import 'package:flutter_tools/src/ios/xcodeproj.dart';
import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:mockito/mockito.dart'; import 'package:mockito/mockito.dart';
import 'package:platform/platform.dart'; import 'package:platform/platform.dart';
...@@ -420,7 +419,7 @@ Information about project "Runner": ...@@ -420,7 +419,7 @@ Information about project "Runner":
mockArtifacts = MockLocalEngineArtifacts(); mockArtifacts = MockLocalEngineArtifacts();
mockProcessManager = MockProcessManager(); mockProcessManager = MockProcessManager();
macOS = fakePlatform('macos'); macOS = fakePlatform('macos');
globals.fs.file(xcodebuild).createSync(recursive: true); fs.file(xcodebuild).createSync(recursive: true);
}); });
void testUsingOsxContext(String description, dynamic testMethod()) { void testUsingOsxContext(String description, dynamic testMethod()) {
...@@ -435,7 +434,7 @@ Information about project "Runner": ...@@ -435,7 +434,7 @@ Information about project "Runner":
testUsingOsxContext('sets ARCHS=armv7 when armv7 local engine is set', () async { testUsingOsxContext('sets ARCHS=armv7 when armv7 local engine is set', () async {
when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, when(mockArtifacts.getArtifactPath(Artifact.flutterFramework,
platform: TargetPlatform.ios, mode: anyNamed('mode'))).thenReturn('engine'); platform: TargetPlatform.ios, mode: anyNamed('mode'))).thenReturn('engine');
when(mockArtifacts.engineOutPath).thenReturn(globals.fs.path.join('out', 'ios_profile_arm')); when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile_arm'));
const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null); const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null);
final FlutterProject project = FlutterProject.fromPath('path/to/project'); final FlutterProject project = FlutterProject.fromPath('path/to/project');
...@@ -444,13 +443,13 @@ Information about project "Runner": ...@@ -444,13 +443,13 @@ Information about project "Runner":
buildInfo: buildInfo, buildInfo: buildInfo,
); );
final File config = globals.fs.file('path/to/project/ios/Flutter/Generated.xcconfig'); final File config = fs.file('path/to/project/ios/Flutter/Generated.xcconfig');
expect(config.existsSync(), isTrue); expect(config.existsSync(), isTrue);
final String contents = config.readAsStringSync(); final String contents = config.readAsStringSync();
expect(contents.contains('ARCHS=armv7'), isTrue); expect(contents.contains('ARCHS=armv7'), isTrue);
final File buildPhaseScript = globals.fs.file('path/to/project/ios/Flutter/flutter_export_environment.sh'); final File buildPhaseScript = fs.file('path/to/project/ios/Flutter/flutter_export_environment.sh');
expect(buildPhaseScript.existsSync(), isTrue); expect(buildPhaseScript.existsSync(), isTrue);
final String buildPhaseScriptContents = buildPhaseScript.readAsStringSync(); final String buildPhaseScriptContents = buildPhaseScript.readAsStringSync();
...@@ -460,7 +459,7 @@ Information about project "Runner": ...@@ -460,7 +459,7 @@ Information about project "Runner":
testUsingOsxContext('sets TRACK_WIDGET_CREATION=true when trackWidgetCreation is true', () async { testUsingOsxContext('sets TRACK_WIDGET_CREATION=true when trackWidgetCreation is true', () async {
when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, when(mockArtifacts.getArtifactPath(Artifact.flutterFramework,
platform: TargetPlatform.ios, mode: anyNamed('mode'))).thenReturn('engine'); platform: TargetPlatform.ios, mode: anyNamed('mode'))).thenReturn('engine');
when(mockArtifacts.engineOutPath).thenReturn(globals.fs.path.join('out', 'ios_profile_arm')); when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile_arm'));
const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null, trackWidgetCreation: true); const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null, trackWidgetCreation: true);
final FlutterProject project = FlutterProject.fromPath('path/to/project'); final FlutterProject project = FlutterProject.fromPath('path/to/project');
await updateGeneratedXcodeProperties( await updateGeneratedXcodeProperties(
...@@ -468,13 +467,13 @@ Information about project "Runner": ...@@ -468,13 +467,13 @@ Information about project "Runner":
buildInfo: buildInfo, buildInfo: buildInfo,
); );
final File config = globals.fs.file('path/to/project/ios/Flutter/Generated.xcconfig'); final File config = fs.file('path/to/project/ios/Flutter/Generated.xcconfig');
expect(config.existsSync(), isTrue); expect(config.existsSync(), isTrue);
final String contents = config.readAsStringSync(); final String contents = config.readAsStringSync();
expect(contents.contains('TRACK_WIDGET_CREATION=true'), isTrue); expect(contents.contains('TRACK_WIDGET_CREATION=true'), isTrue);
final File buildPhaseScript = globals.fs.file('path/to/project/ios/Flutter/flutter_export_environment.sh'); final File buildPhaseScript = fs.file('path/to/project/ios/Flutter/flutter_export_environment.sh');
expect(buildPhaseScript.existsSync(), isTrue); expect(buildPhaseScript.existsSync(), isTrue);
final String buildPhaseScriptContents = buildPhaseScript.readAsStringSync(); final String buildPhaseScriptContents = buildPhaseScript.readAsStringSync();
...@@ -484,7 +483,7 @@ Information about project "Runner": ...@@ -484,7 +483,7 @@ Information about project "Runner":
testUsingOsxContext('does not set TRACK_WIDGET_CREATION when trackWidgetCreation is false', () async { testUsingOsxContext('does not set TRACK_WIDGET_CREATION when trackWidgetCreation is false', () async {
when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, when(mockArtifacts.getArtifactPath(Artifact.flutterFramework,
platform: TargetPlatform.ios, mode: anyNamed('mode'))).thenReturn('engine'); platform: TargetPlatform.ios, mode: anyNamed('mode'))).thenReturn('engine');
when(mockArtifacts.engineOutPath).thenReturn(globals.fs.path.join('out', 'ios_profile_arm')); when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile_arm'));
const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null); const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null);
final FlutterProject project = FlutterProject.fromPath('path/to/project'); final FlutterProject project = FlutterProject.fromPath('path/to/project');
await updateGeneratedXcodeProperties( await updateGeneratedXcodeProperties(
...@@ -492,13 +491,13 @@ Information about project "Runner": ...@@ -492,13 +491,13 @@ Information about project "Runner":
buildInfo: buildInfo, buildInfo: buildInfo,
); );
final File config = globals.fs.file('path/to/project/ios/Flutter/Generated.xcconfig'); final File config = fs.file('path/to/project/ios/Flutter/Generated.xcconfig');
expect(config.existsSync(), isTrue); expect(config.existsSync(), isTrue);
final String contents = config.readAsStringSync(); final String contents = config.readAsStringSync();
expect(contents.contains('TRACK_WIDGET_CREATION=true'), isFalse); expect(contents.contains('TRACK_WIDGET_CREATION=true'), isFalse);
final File buildPhaseScript = globals.fs.file('path/to/project/ios/Flutter/flutter_export_environment.sh'); final File buildPhaseScript = fs.file('path/to/project/ios/Flutter/flutter_export_environment.sh');
expect(buildPhaseScript.existsSync(), isTrue); expect(buildPhaseScript.existsSync(), isTrue);
final String buildPhaseScriptContents = buildPhaseScript.readAsStringSync(); final String buildPhaseScriptContents = buildPhaseScript.readAsStringSync();
...@@ -508,7 +507,7 @@ Information about project "Runner": ...@@ -508,7 +507,7 @@ Information about project "Runner":
testUsingOsxContext('sets ARCHS=armv7 when armv7 local engine is set', () async { testUsingOsxContext('sets ARCHS=armv7 when armv7 local engine is set', () async {
when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, when(mockArtifacts.getArtifactPath(Artifact.flutterFramework,
platform: TargetPlatform.ios, mode: anyNamed('mode'))).thenReturn('engine'); platform: TargetPlatform.ios, mode: anyNamed('mode'))).thenReturn('engine');
when(mockArtifacts.engineOutPath).thenReturn(globals.fs.path.join('out', 'ios_profile')); when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile'));
const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null); const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null);
final FlutterProject project = FlutterProject.fromPath('path/to/project'); final FlutterProject project = FlutterProject.fromPath('path/to/project');
...@@ -517,7 +516,7 @@ Information about project "Runner": ...@@ -517,7 +516,7 @@ Information about project "Runner":
buildInfo: buildInfo, buildInfo: buildInfo,
); );
final File config = globals.fs.file('path/to/project/ios/Flutter/Generated.xcconfig'); final File config = fs.file('path/to/project/ios/Flutter/Generated.xcconfig');
expect(config.existsSync(), isTrue); expect(config.existsSync(), isTrue);
final String contents = config.readAsStringSync(); final String contents = config.readAsStringSync();
...@@ -541,9 +540,9 @@ Information about project "Runner": ...@@ -541,9 +540,9 @@ Information about project "Runner":
}) async { }) async {
when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, when(mockArtifacts.getArtifactPath(Artifact.flutterFramework,
platform: TargetPlatform.ios, mode: anyNamed('mode'))).thenReturn('engine'); platform: TargetPlatform.ios, mode: anyNamed('mode'))).thenReturn('engine');
when(mockArtifacts.engineOutPath).thenReturn(globals.fs.path.join('out', 'ios')); when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios'));
final File manifestFile = globals.fs.file('path/to/project/pubspec.yaml'); final File manifestFile = fs.file('path/to/project/pubspec.yaml');
manifestFile.createSync(recursive: true); manifestFile.createSync(recursive: true);
manifestFile.writeAsStringSync(manifestString); manifestFile.writeAsStringSync(manifestString);
...@@ -555,7 +554,7 @@ Information about project "Runner": ...@@ -555,7 +554,7 @@ Information about project "Runner":
buildInfo: buildInfo, buildInfo: buildInfo,
); );
final File localPropertiesFile = globals.fs.file('path/to/project/ios/Flutter/Generated.xcconfig'); final File localPropertiesFile = fs.file('path/to/project/ios/Flutter/Generated.xcconfig');
expect(propertyFor('FLUTTER_BUILD_NAME', localPropertiesFile), expectedBuildName); expect(propertyFor('FLUTTER_BUILD_NAME', localPropertiesFile), expectedBuildName);
expect(propertyFor('FLUTTER_BUILD_NUMBER', localPropertiesFile), expectedBuildNumber); expect(propertyFor('FLUTTER_BUILD_NUMBER', localPropertiesFile), expectedBuildNumber);
expect(propertyFor('FLUTTER_BUILD_NUMBER', localPropertiesFile), isNotNull); expect(propertyFor('FLUTTER_BUILD_NUMBER', localPropertiesFile), isNotNull);
......
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