Apply style guide regarding createTempSync pattern (#81090)

This commit is contained in:
Ian Hickson 2021-04-27 14:59:03 -07:00 committed by GitHub
parent a7eb2c8a1a
commit 6beafa7b16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 33 additions and 50 deletions

View File

@ -41,7 +41,7 @@ Future<String> evalTestAppInChrome({
}) })
.add(createStaticHandler(appDirectory)); .add(createStaticHandler(appDirectory));
shelf_io.serveRequests(server, cascade.handler); shelf_io.serveRequests(server, cascade.handler);
final io.Directory userDataDirectory = io.Directory.systemTemp.createTempSync('chrome_user_data_'); final io.Directory userDataDirectory = io.Directory.systemTemp.createTempSync('flutter_chrome_user_data.');
chrome = await Chrome.launch(ChromeOptions( chrome = await Chrome.launch(ChromeOptions(
headless: true, headless: true,
debugPort: browserDebugPort, debugPort: browserDebugPort,
@ -88,7 +88,7 @@ class AppServer {
}); });
}); });
shelf_io.serveRequests(server, cascade.handler); shelf_io.serveRequests(server, cascade.handler);
final io.Directory userDataDirectory = io.Directory.systemTemp.createTempSync('chrome_user_data_'); final io.Directory userDataDirectory = io.Directory.systemTemp.createTempSync('flutter_chrome_user_data.');
final Completer<String> chromeErrorCompleter = Completer<String>(); final Completer<String> chromeErrorCompleter = Completer<String>();
chrome = await Chrome.launch(ChromeOptions( chrome = await Chrome.launch(ChromeOptions(
headless: headless, headless: headless,

View File

@ -38,7 +38,7 @@ class NewGalleryChromeRunTest {
/// Runs the test. /// Runs the test.
Future<TaskResult> run() async { Future<TaskResult> run() async {
final Directory galleryParentDir = final Directory galleryParentDir =
Directory.systemTemp.createTempSync('temp'); Directory.systemTemp.createTempSync('flutter_gallery_v2_chrome_run.');
final Directory galleryDir = final Directory galleryDir =
Directory(path.join(galleryParentDir.path, 'gallery')); Directory(path.join(galleryParentDir.path, 'gallery'));

View File

@ -25,7 +25,7 @@ class NewGalleryWebCompileTest {
/// Runs the test. /// Runs the test.
Future<TaskResult> run() async { Future<TaskResult> run() async {
final Directory galleryParentDir = final Directory galleryParentDir =
Directory.systemTemp.createTempSync('temp'); Directory.systemTemp.createTempSync('flutter_gallery_v2_web_compile.');
final Directory galleryDir = final Directory galleryDir =
Directory(path.join(galleryParentDir.path, 'gallery')); Directory(path.join(galleryParentDir.path, 'gallery'));

View File

@ -19,7 +19,7 @@ Future<void> main() async {
String watchDeviceID; String watchDeviceID;
String phoneDeviceID; String phoneDeviceID;
final Directory tempDir = Directory.systemTemp final Directory tempDir = Directory.systemTemp
.createTempSync('ios_app_with_extensions_test'); .createTempSync('flutter_ios_app_with_extensions_test.');
final Directory projectDir = final Directory projectDir =
Directory(path.join(tempDir.path, 'app_with_extensions')); Directory(path.join(tempDir.path, 'app_with_extensions'));
try { try {

View File

@ -320,7 +320,7 @@ Future<void> main() async {
section('Run platform unit tests'); section('Run platform unit tests');
final String resultBundleTemp = Directory.systemTemp.createTempSync('module_test_ios_xcresult.').path; final String resultBundleTemp = Directory.systemTemp.createTempSync('flutter_module_test_ios_xcresult.').path;
await testWithNewIOSSimulator('TestAdd2AppSim', (String deviceId) async { await testWithNewIOSSimulator('TestAdd2AppSim', (String deviceId) async {
simulatorDeviceId = deviceId; simulatorDeviceId = deviceId;
final String resultBundlePath = path.join(resultBundleTemp, 'result'); final String resultBundlePath = path.join(resultBundleTemp, 'result');

View File

@ -44,7 +44,7 @@ Future<void> main() async {
final String codeSignStyle = environment['FLUTTER_XCODE_CODE_SIGN_STYLE']; final String codeSignStyle = environment['FLUTTER_XCODE_CODE_SIGN_STYLE'];
final String provisioningProfile = environment['FLUTTER_XCODE_PROVISIONING_PROFILE_SPECIFIER']; final String provisioningProfile = environment['FLUTTER_XCODE_PROVISIONING_PROFILE_SPECIFIER'];
final String resultBundleTemp = Directory.systemTemp.createTempSync('native_ui_tests_ios32_xcresult.').path; final String resultBundleTemp = Directory.systemTemp.createTempSync('flutter_native_ui_tests_ios32_xcresult.').path;
final String resultBundlePath = path.join(resultBundleTemp, 'result'); final String resultBundlePath = path.join(resultBundleTemp, 'result');
final int testResultExit = await exec( final int testResultExit = await exec(
'xcodebuild', 'xcodebuild',

View File

@ -14,7 +14,7 @@ Future<void> main() async {
deviceOperatingSystem = DeviceOperatingSystem.android; deviceOperatingSystem = DeviceOperatingSystem.android;
final Directory galleryParentDir = final Directory galleryParentDir =
Directory.systemTemp.createTempSync('new_gallery_test'); Directory.systemTemp.createTempSync('flutter_new_gallery_test.');
final Directory galleryDir = final Directory galleryDir =
Directory(path.join(galleryParentDir.path, 'gallery')); Directory(path.join(galleryParentDir.path, 'gallery'));

View File

@ -13,7 +13,7 @@ import 'package:path/path.dart' as path;
Future<void> main() async { Future<void> main() async {
deviceOperatingSystem = DeviceOperatingSystem.android; deviceOperatingSystem = DeviceOperatingSystem.android;
final Directory galleryParentDir = Directory.systemTemp.createTempSync('new_gallery_test'); final Directory galleryParentDir = Directory.systemTemp.createTempSync('flutter_new_gallery_test.');
final Directory galleryDir = Directory(path.join(galleryParentDir.path, 'gallery')); final Directory galleryDir = Directory(path.join(galleryParentDir.path, 'gallery'));
try { try {

View File

@ -13,7 +13,7 @@ import 'package:path/path.dart' as path;
Future<void> main() async { Future<void> main() async {
deviceOperatingSystem = DeviceOperatingSystem.ios; deviceOperatingSystem = DeviceOperatingSystem.ios;
final Directory galleryParentDir = Directory.systemTemp.createTempSync('new_gallery_test'); final Directory galleryParentDir = Directory.systemTemp.createTempSync('flutter_new_gallery_test.');
final Directory galleryDir = Directory(path.join(galleryParentDir.path, 'gallery')); final Directory galleryDir = Directory(path.join(galleryParentDir.path, 'gallery'));
try { try {

View File

@ -121,7 +121,7 @@ Future<TaskResult> runWebBenchmark({ @required bool useCanvasKit }) async {
shelf_io.serveRequests(server, cascade.handler); shelf_io.serveRequests(server, cascade.handler);
final String dartToolDirectory = path.join('$macrobenchmarksDirectory/.dart_tool'); final String dartToolDirectory = path.join('$macrobenchmarksDirectory/.dart_tool');
final String userDataDir = io.Directory(dartToolDirectory).createTempSync('chrome_user_data_').path; final String userDataDir = io.Directory(dartToolDirectory).createTempSync('flutter_chrome_user_data.').path;
// TODO(yjbanov): temporarily disables headful Chrome until we get // TODO(yjbanov): temporarily disables headful Chrome until we get
// devicelab hardware that is able to run it. Our current // devicelab hardware that is able to run it. Our current

View File

@ -20,9 +20,7 @@ void main() {
() async { () async {
const Platform platform = LocalPlatform(); const Platform platform = LocalPlatform();
const FileSystem fileSystem = LocalFileSystem(); const FileSystem fileSystem = LocalFileSystem();
final Directory tempDir = fileSystem.systemTempDirectory.createTempSync( final Directory tempDir = fileSystem.systemTempDirectory.createTempSync('flutter_conductor_integration_test.');
'conductor_integration_test',
);
const ProcessManager processManager = LocalProcessManager(); const ProcessManager processManager = LocalProcessManager();
final TestStdio stdio = TestStdio(verbose: true); final TestStdio stdio = TestStdio(verbose: true);
final Checkouts checkouts = Checkouts( final Checkouts checkouts = Checkouts(

View File

@ -30,7 +30,7 @@ void main() {
fileSystem = const LocalFileSystem(); fileSystem = const LocalFileSystem();
processManager = const LocalProcessManager(); processManager = const LocalProcessManager();
stdio = TestStdio(verbose: true); stdio = TestStdio(verbose: true);
tempDir = fileSystem.systemTempDirectory.createTempSync('flutter_conductor_checkouts'); tempDir = fileSystem.systemTempDirectory.createTempSync('flutter_conductor_checkouts.');
checkouts = Checkouts( checkouts = Checkouts(
fileSystem: fileSystem, fileSystem: fileSystem,
parentDirectory: tempDir, parentDirectory: tempDir,

View File

@ -218,9 +218,8 @@ class LocalFileSystem extends local_fs.LocalFileSystem {
@override @override
Directory get systemTempDirectory { Directory get systemTempDirectory {
if (_systemTemp == null) { if (_systemTemp == null) {
_systemTemp = super.systemTempDirectory.createTempSync( _systemTemp = super.systemTempDirectory.createTempSync('flutter_tools.')
'flutter_tools.', ..createSync(recursive: true);
)..createSync(recursive: true);
// Make sure that the temporary directory is cleaned up if the tool is // Make sure that the temporary directory is cleaned up if the tool is
// killed by a signal. // killed by a signal.
for (final ProcessSignal signal in _fatalSignals) { for (final ProcessSignal signal in _fatalSignals) {

View File

@ -419,9 +419,7 @@ class AndroidMavenArtifacts extends ArtifactSet {
if (globals.androidSdk == null) { if (globals.androidSdk == null) {
return; return;
} }
final Directory tempDir = cache.getRoot().createTempSync( final Directory tempDir = cache.getRoot().createTempSync('flutter_gradle_wrapper.');
'flutter_gradle_wrapper.',
);
globals.gradleUtils.injectGradleWrapperIfNeeded(tempDir); globals.gradleUtils.injectGradleWrapperIfNeeded(tempDir);
final Status status = logger.startProgress('Downloading Android Maven dependencies...'); final Status status = logger.startProgress('Downloading Android Maven dependencies...');

View File

@ -156,7 +156,7 @@ class FlutterTesterDevice extends Device {
} }
final Directory assetDirectory = _fileSystem.systemTempDirectory final Directory assetDirectory = _fileSystem.systemTempDirectory
.createTempSync('flutter-tester'); .createTempSync('flutter_tester.');
final String applicationKernelFilePath = getKernelPathForTransformerOptions( final String applicationKernelFilePath = getKernelPathForTransformerOptions(
_fileSystem.path.join(assetDirectory.path, 'flutter-tester-app.dill'), _fileSystem.path.join(assetDirectory.path, 'flutter-tester-app.dill'),
trackWidgetCreation: buildInfo.trackWidgetCreation, trackWidgetCreation: buildInfo.trackWidgetCreation,

View File

@ -139,9 +139,7 @@ void main() {
}); });
setUp(() { setUp(() {
tempDir = fileSystem.systemTempDirectory.createTempSync( tempDir = fileSystem.systemTempDirectory.createTempSync('flutter_analyze_once_test_1.').absolute;
'flutter_analyze_once_test_1.',
).absolute;
projectPath = fileSystem.path.join(tempDir.path, 'flutter_project'); projectPath = fileSystem.path.join(tempDir.path, 'flutter_project');
fileSystem.file(fileSystem.path.join(projectPath, 'pubspec.yaml')) fileSystem.file(fileSystem.path.join(projectPath, 'pubspec.yaml'))
..createSync(recursive: true) ..createSync(recursive: true)
@ -387,8 +385,7 @@ StringBuffer bar = StringBuffer('baz');
}); });
testUsingContext('analyze once with default options has info issue finally exit code 1.', () async { testUsingContext('analyze once with default options has info issue finally exit code 1.', () async {
final Directory tempDir = fileSystem.systemTempDirectory.createTempSync( final Directory tempDir = fileSystem.systemTempDirectory.createTempSync('flutter_analyze_once_default_options_info_issue_exit_code_1.');
'flutter_analyze_once_default_options_info_issue_exit_code_1.');
_createDotPackages(tempDir.path); _createDotPackages(tempDir.path);
const String infoSourceCode = ''' const String infoSourceCode = '''
@ -422,8 +419,7 @@ int analyze() {}
}); });
testUsingContext('analyze once with no-fatal-infos has info issue finally exit code 0.', () async { testUsingContext('analyze once with no-fatal-infos has info issue finally exit code 0.', () async {
final Directory tempDir = fileSystem.systemTempDirectory.createTempSync( final Directory tempDir = fileSystem.systemTempDirectory.createTempSync('flutter_analyze_once_no_fatal_infos_info_issue_exit_code_0.');
'flutter_analyze_once_no_fatal_infos_info_issue_exit_code_0.');
_createDotPackages(tempDir.path); _createDotPackages(tempDir.path);
const String infoSourceCode = ''' const String infoSourceCode = '''
@ -457,8 +453,7 @@ int analyze() {}
}); });
testUsingContext('analyze once only fatal-warnings has info issue finally exit code 0.', () async { testUsingContext('analyze once only fatal-warnings has info issue finally exit code 0.', () async {
final Directory tempDir = fileSystem.systemTempDirectory.createTempSync( final Directory tempDir = fileSystem.systemTempDirectory.createTempSync('flutter_analyze_once_only_fatal_warnings_info_issue_exit_code_0.');
'flutter_analyze_once_only_fatal_warnings_info_issue_exit_code_0.');
_createDotPackages(tempDir.path); _createDotPackages(tempDir.path);
const String infoSourceCode = ''' const String infoSourceCode = '''
@ -492,8 +487,7 @@ int analyze() {}
}); });
testUsingContext('analyze once only fatal-infos has warning issue finally exit code 1.', () async { testUsingContext('analyze once only fatal-infos has warning issue finally exit code 1.', () async {
final Directory tempDir = fileSystem.systemTempDirectory.createTempSync( final Directory tempDir = fileSystem.systemTempDirectory.createTempSync('flutter_analyze_once_only_fatal_infos_warning_issue_exit_code_1.');
'flutter_analyze_once_only_fatal_infos_warning_issue_exit_code_1.');
_createDotPackages(tempDir.path); _createDotPackages(tempDir.path);
const String warningSourceCode = ''' const String warningSourceCode = '''

View File

@ -286,9 +286,7 @@ void main() {
Directory tempDir; Directory tempDir;
setUp(() { setUp(() {
tempDir = globals.fs.systemTempDirectory.createTempSync( tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_analytics_bots_test.');
'flutter_tools_analytics_bots_test.',
);
}); });
tearDown(() { tearDown(() {

View File

@ -134,7 +134,7 @@ void main() {
}; };
for (final MapEntry<String, String> entry in testCases.entries) { for (final MapEntry<String, String> entry in testCases.entries) {
final Directory sampleAppAndroid = fileSystem.systemTempDirectory.createTempSync('android'); final Directory sampleAppAndroid = fileSystem.systemTempDirectory.createTempSync('flutter_android.');
sampleAppAndroid sampleAppAndroid
.childFile('build.gradle') .childFile('build.gradle')
.writeAsStringSync(''' .writeAsStringSync('''

View File

@ -28,7 +28,7 @@ void main() {
logger = BufferLogger.test(); logger = BufferLogger.test();
platform = FakePlatform(environment: <String, String>{}); platform = FakePlatform(environment: <String, String>{});
final Directory tempDir = globals.fs.systemTempDirectory.createTempSync('devtools_launcher_test'); final Directory tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_devtools_launcher_test.');
persistentToolState = PersistentToolState.test( persistentToolState = PersistentToolState.test(
directory: tempDir, directory: tempDir,
logger: logger, logger: logger,

View File

@ -341,7 +341,7 @@ flutter:
assert(name != null); assert(name != null);
assert(dependencies != null); assert(dependencies != null);
final Directory pluginDirectory = fs.systemTempDirectory.createTempSync('plugin.'); final Directory pluginDirectory = fs.systemTempDirectory.createTempSync('flutter_plugin.');
pluginDirectory pluginDirectory
.childFile('pubspec.yaml') .childFile('pubspec.yaml')
.writeAsStringSync(''' .writeAsStringSync('''
@ -874,7 +874,7 @@ dependencies:
testUsingContext("Registrant for web doesn't escape slashes in imports", () async { testUsingContext("Registrant for web doesn't escape slashes in imports", () async {
when(flutterProject.isModule).thenReturn(true); when(flutterProject.isModule).thenReturn(true);
final Directory webPluginWithNestedFile = final Directory webPluginWithNestedFile =
fs.systemTempDirectory.createTempSync('web_plugin_with_nested'); fs.systemTempDirectory.createTempSync('flutter_web_plugin_with_nested.');
webPluginWithNestedFile.childFile('pubspec.yaml').writeAsStringSync(''' webPluginWithNestedFile.childFile('pubspec.yaml').writeAsStringSync('''
flutter: flutter:
plugin: plugin:
@ -1329,7 +1329,7 @@ flutter:
Directory projectDir; Directory projectDir;
Directory tempDir; Directory tempDir;
setUp(() { setUp(() {
tempDir = globals.fs.systemTempDirectory.createTempSync('plugin_test.'); tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_plugin_test.');
projectDir = tempDir.childDirectory('flutter_project'); projectDir = tempDir.childDirectory('flutter_project');
}); });

View File

@ -151,8 +151,8 @@ void main() {
'--non-interactive', '--non-interactive',
'--enable-dart-profiling', '--enable-dart-profiling',
'--packages=.packages', '--packages=.packages',
'--flutter-assets-dir=/.tmp_rand0/flutter-testerrand0', '--flutter-assets-dir=/.tmp_rand0/flutter_tester.rand0',
'/.tmp_rand0/flutter-testerrand0/flutter-tester-app.dill', '/.tmp_rand0/flutter_tester.rand0/flutter-tester-app.dill',
], ],
completer: completer, completer: completer,
stdout: stdout:

View File

@ -122,7 +122,7 @@ void main() {
testWithoutContext('--analyze-size allows overriding the directory for code size files', () async { testWithoutContext('--analyze-size allows overriding the directory for code size files', () async {
final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter'); final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter');
final Directory tempDir = fileSystem.systemTempDirectory.createTempSync('size_test'); final Directory tempDir = fileSystem.systemTempDirectory.createTempSync('flutter_size_test.');
final ProcessResult result = await processManager.run(<String>[ final ProcessResult result = await processManager.run(<String>[
flutterBin, flutterBin,

View File

@ -87,9 +87,7 @@ void testUsingContext(
} }
}); });
Config buildConfig(FileSystem fs) { Config buildConfig(FileSystem fs) {
configDir ??= globals.fs.systemTempDirectory.createTempSync( configDir ??= globals.fs.systemTempDirectory.createTempSync('flutter_config_dir_test.');
'flutter_config_dir_test.',
);
return Config.test( return Config.test(
name: Config.kFlutterSettings, name: Config.kFlutterSettings,
directory: configDir, directory: configDir,
@ -97,9 +95,7 @@ void testUsingContext(
); );
} }
PersistentToolState buildPersistentToolState(FileSystem fs) { PersistentToolState buildPersistentToolState(FileSystem fs) {
configDir ??= globals.fs.systemTempDirectory.createTempSync( configDir ??= globals.fs.systemTempDirectory.createTempSync('flutter_config_dir_test.');
'flutter_config_dir_test.',
);
return PersistentToolState.test( return PersistentToolState.test(
directory: configDir, directory: configDir,
logger: globals.logger, logger: globals.logger,