From e10d74b4d5ceea963c5f194df16098920c18c517 Mon Sep 17 00:00:00 2001 From: yaakovschectman <109111084+yaakovschectman@users.noreply.github.com> Date: Thu, 17 Aug 2023 13:26:17 -0400 Subject: [PATCH] Revert "[Windows] Allow overwriting the cache's Dart SDK archive license file" (#132773) Reverts flutter/flutter#132669 Introduced failure on `windows/mac/linux framework_library_tests`. ``` 05:41 +7318 ~22 -1: /b/s/w/ir/x/w/flutter/packages/flutter/test/material/menu_bar_theme_test.dart: (tearDownAll) [E] Expected: leak free Actual: Which: contains leaks: # The text is generated by leak_tracker. # For leak troubleshooting tips open: # https://github.com/dart-lang/leak_tracker/blob/main/doc/TROUBLESHOOT.md notDisposed: total: 3 objects: ValueNotifier<_OverlayEntryWidgetState?>: test: Constructor parameters override theme parameters identityHashCode: 407433615 FocusScopeNode: test: Constructor parameters override theme parameters identityHashCode: 513181650 FocusScopeNode: test: Constructor parameters override theme parameters identityHashCode: 704743556 package:matcher expect package:flutter_test/src/widget_tester.dart 458:18 expect package:leak_tracker_flutter_testing/src/leak_tracking_flutter_testing.dart 81:5 _tearDownTestingWithLeakTracking ===== asynchronous gap =========================== dart:async _CustomZone.registerBinaryCallback package:leak_tracker_flutter_testing/src/leak_tracking_flutter_testing.dart 59:9 configureLeakTrackingTearDown. ``` --- bin/internal/update_dart_sdk.ps1 | 14 +-- .../batch_entrypoint_test.dart | 108 ------------------ 2 files changed, 3 insertions(+), 119 deletions(-) delete mode 100644 packages/flutter_tools/test/integration.shard/batch_entrypoint_test.dart diff --git a/bin/internal/update_dart_sdk.ps1 b/bin/internal/update_dart_sdk.ps1 index 2d0d0fc732..6af62a54f7 100644 --- a/bin/internal/update_dart_sdk.ps1 +++ b/bin/internal/update_dart_sdk.ps1 @@ -18,7 +18,6 @@ $flutterRoot = (Get-Item $progName).parent.parent.FullName $cachePath = "$flutterRoot\bin\cache" $dartSdkPath = "$cachePath\dart-sdk" -$dartSdkLicense = "$cachePath\LICENSE.dart_sdk_archive.md" $engineStamp = "$cachePath\engine-dart-sdk.stamp" $engineVersion = (Get-Content "$flutterRoot\bin\internal\engine.version") $engineRealm = (Get-Content "$flutterRoot\bin\internal\engine.realm") @@ -50,18 +49,11 @@ if ($engineRealm) { $dartZipName = "dart-sdk-windows-x64.zip" $dartSdkUrl = "$dartSdkBaseUrl/flutter_infra_release/flutter/$engineVersion/$dartZipName" -if ((Test-Path $dartSdkPath) -or (Test-Path $dartSdkLicense)) { +if (Test-Path $dartSdkPath) { # Move old SDK to a new location instead of deleting it in case it is still in use (e.g. by IntelliJ). $oldDartSdkSuffix = 1 while (Test-Path "$cachePath\$oldDartSdkPrefix$oldDartSdkSuffix") { $oldDartSdkSuffix++ } - - if (Test-Path $dartSdkPath) { - Rename-Item $dartSdkPath "$oldDartSdkPrefix$oldDartSdkSuffix" - } - - if (Test-Path $dartSdkLicense) { - Rename-Item $dartSdkLicense "$oldDartSdkPrefix$oldDartSdkSuffix.LICENSE.md" - } + Rename-Item $dartSdkPath "$oldDartSdkPrefix$oldDartSdkSuffix" } New-Item $dartSdkPath -force -type directory | Out-Null $dartSdkZip = "$cachePath\$dartZipName" @@ -106,5 +98,5 @@ If (Get-Command 7z -errorAction SilentlyContinue) { Remove-Item $dartSdkZip $engineVersion | Out-File $engineStamp -Encoding ASCII -# Try to delete all old SDKs and license files. +# Try to delete all old SDKs. Get-ChildItem -Path $cachePath | Where {$_.BaseName.StartsWith($oldDartSdkPrefix)} | Remove-Item -Recurse -ErrorAction SilentlyContinue diff --git a/packages/flutter_tools/test/integration.shard/batch_entrypoint_test.dart b/packages/flutter_tools/test/integration.shard/batch_entrypoint_test.dart deleted file mode 100644 index e360aa9a8f..0000000000 --- a/packages/flutter_tools/test/integration.shard/batch_entrypoint_test.dart +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright 2014 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:async'; -import 'dart:convert'; - -import 'package:file/file.dart'; -import 'package:flutter_tools/src/base/io.dart'; - -import '../src/common.dart'; -import 'test_utils.dart'; - -final String flutterRootPath = getFlutterRoot(); -final Directory flutterRoot = fileSystem.directory(flutterRootPath); - -Future main() async { - // Regression test for https://github.com/flutter/flutter/issues/132592 - test('flutter/bin/dart updates the Dart SDK without hanging', () async { - // Run the Dart entrypoint once to ensure the Dart SDK is downloaded. - await runDartBatch(); - - expect(dartSdkStamp.existsSync(), true); - - // Remove the Dart SDK stamp and run the Dart entrypoint again to trigger - // the Dart SDK update. - dartSdkStamp.deleteSync(); - final Future runFuture = runDartBatch(); - final Timer timer = Timer(const Duration(minutes: 5), () { - // This print is useful for people debugging this test. Normally we would - // avoid printing in a test but this is an exception because it's useful - // ambient information. - // ignore: avoid_print - print( - 'The Dart batch entrypoint did not complete after 5 minutes. ' - 'Historically this is a sign that 7-Zip zip extraction is waiting for ' - 'the user to confirm they would like to overwrite files. ' - "This likely means the test isn't a flake and will fail. " - 'See: https://github.com/flutter/flutter/issues/132592' - ); - }); - - final String output = await runFuture; - timer.cancel(); - - // Check the Dart SDK was re-downloaded and extracted. - // If 7-Zip is installed, unexpected overwrites causes this to hang. - // If 7-Zip is not installed, unexpected overwrites results in error messages. - // See: https://github.com/flutter/flutter/issues/132592 - expect(dartSdkStamp.existsSync(), true); - expect(output, contains('Downloading Dart SDK from Flutter engine ...')); - expect(output, contains('Expanding downloaded archive...')); - expect(output, isNot(contains('Use the -Force parameter' /* Luke */))); - }, - skip: !platform.isWindows); // [intended] Only Windows uses the batch entrypoint -} - -Future runDartBatch() async { - String output = ''; - final Process process = await processManager.start( - [ - dartBatch.path - ], - ); - final Future stdoutFuture = process.stdout - .transform(utf8.decoder) - .forEach((String str) { - output += str; - }); - final Future stderrFuture = process.stderr - .transform(utf8.decoder) - .forEach((String str) { - output += str; - }); - - // Wait for the output to complete - await Future.wait(>[stdoutFuture, stderrFuture]); - // Ensure child exited successfully - expect( - await process.exitCode, - 0, - reason: 'child process exited with code ${await process.exitCode}, and ' - 'output:\n$output', - ); - - // Check the Dart tool prints the expected output. - expect(output, contains('A command-line utility for Dart development.')); - expect(output, contains('Usage: dart [arguments]')); - - return output; -} - -// The executable batch entrypoint for the Dart binary. -File get dartBatch { - return flutterRoot - .childDirectory('bin') - .childFile('dart.bat') - .absolute; -} - -// The Dart SDK's stamp file. -File get dartSdkStamp { - return flutterRoot - .childDirectory('bin') - .childDirectory('cache') - .childFile('engine-dart-sdk.stamp') - .absolute; -}