Refactor flutter_plugins (#145870)
Refactor flutter_plugins suite in order to reduce testing logic in test.dart and allow for later implementing package:test onto the existing flutter_plugins tests Also update the test_test invocation of getFlutterPackagesVersion Part of https://github.com/flutter/flutter/issues/145482
This commit is contained in:
101
dev/bots/suite_runners/run_flutter_packages_tests.dart
Normal file
101
dev/bots/suite_runners/run_flutter_packages_tests.dart
Normal file
@@ -0,0 +1,101 @@
|
||||
// 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:io' show Directory, File;
|
||||
|
||||
import 'package:file/file.dart' as fs;
|
||||
import 'package:file/local.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
import '../run_command.dart';
|
||||
import '../test.dart';
|
||||
import '../utils.dart';
|
||||
|
||||
/// Executes the test suite for the flutter/packages repo.
|
||||
Future<void> flutterPackagesRunner(String flutterRoot) async {
|
||||
|
||||
Future<void> runAnalyze() async {
|
||||
printProgress('${green}Running analysis for flutter/packages$reset');
|
||||
final Directory checkout = Directory.systemTemp.createTempSync('flutter_packages.');
|
||||
await runCommand(
|
||||
'git',
|
||||
const <String>[
|
||||
'-c',
|
||||
'core.longPaths=true',
|
||||
'clone',
|
||||
'https://github.com/flutter/packages.git',
|
||||
'.',
|
||||
],
|
||||
workingDirectory: checkout.path,
|
||||
);
|
||||
final String packagesCommit = await getFlutterPackagesVersion(flutterRoot: flutterRoot);
|
||||
await runCommand(
|
||||
'git',
|
||||
<String>[
|
||||
'-c',
|
||||
'core.longPaths=true',
|
||||
'checkout',
|
||||
packagesCommit,
|
||||
],
|
||||
workingDirectory: checkout.path,
|
||||
);
|
||||
// Prep the repository tooling.
|
||||
// This test does not use tool_runner.sh because in this context the test
|
||||
// should always run on the entire packages repo, while tool_runner.sh
|
||||
// is designed for flutter/packages CI and only analyzes changed repository
|
||||
// files when run for anything but master.
|
||||
final String toolDir = path.join(checkout.path, 'script', 'tool');
|
||||
await runCommand(
|
||||
'dart',
|
||||
const <String>[
|
||||
'pub',
|
||||
'get',
|
||||
],
|
||||
workingDirectory: toolDir,
|
||||
);
|
||||
final String toolScript = path.join(toolDir, 'bin', 'flutter_plugin_tools.dart');
|
||||
await runCommand(
|
||||
'dart',
|
||||
<String>[
|
||||
'run',
|
||||
toolScript,
|
||||
'analyze',
|
||||
// Fetch the oldest possible dependencies, rather than the newest, to
|
||||
// insulate flutter/flutter from out-of-band failures when new versions
|
||||
// of dependencies are published. This compensates for the fact that
|
||||
// flutter/packages doesn't use pinned dependencies, and for the
|
||||
// purposes of this test using old dependencies is fine. See
|
||||
// https://github.com/flutter/flutter/issues/129633
|
||||
'--downgrade',
|
||||
'--custom-analysis=script/configs/custom_analysis.yaml',
|
||||
],
|
||||
workingDirectory: checkout.path,
|
||||
);
|
||||
}
|
||||
await selectSubshard(<String, ShardRunner>{
|
||||
'analyze': runAnalyze,
|
||||
});
|
||||
}
|
||||
|
||||
/// Returns the commit hash of the flutter/packages repository that's rolled in.
|
||||
///
|
||||
/// The flutter/packages repository is a downstream dependency, it is only used
|
||||
/// by flutter/flutter for testing purposes, to assure stable tests for a given
|
||||
/// flutter commit the flutter/packages commit hash to test against is coded in
|
||||
/// the bin/internal/flutter_packages.version file.
|
||||
///
|
||||
/// The `filesystem` parameter specified filesystem to read the packages version file from.
|
||||
/// The `packagesVersionFile` parameter allows specifying an alternative path for the
|
||||
/// packages version file, when null [flutterPackagesVersionFile] is used.
|
||||
Future<String> getFlutterPackagesVersion({
|
||||
fs.FileSystem fileSystem = const LocalFileSystem(),
|
||||
String? packagesVersionFile,
|
||||
required String flutterRoot,
|
||||
}) async {
|
||||
final String flutterPackagesVersionFile = path.join(flutterRoot, 'bin', 'internal', 'flutter_packages.version');
|
||||
|
||||
final File versionFile = fileSystem.file(packagesVersionFile ?? flutterPackagesVersionFile);
|
||||
final String versionFileContents = await versionFile.readAsString();
|
||||
return versionFileContents.trim();
|
||||
}
|
||||
@@ -65,6 +65,7 @@ import 'package:process/process.dart';
|
||||
|
||||
import 'run_command.dart';
|
||||
import 'suite_runners/run_add_to_app_life_cycle_tests.dart';
|
||||
import 'suite_runners/run_flutter_packages_tests.dart';
|
||||
import 'suite_runners/run_skp_generator_tests.dart';
|
||||
import 'suite_runners/run_web_long_running_tests.dart';
|
||||
import 'tool_subsharding.dart';
|
||||
@@ -88,7 +89,6 @@ final String dart = path.join(flutterRoot, 'bin', 'cache', 'dart-sdk', 'bin', 'd
|
||||
final String pubCache = path.join(flutterRoot, '.pub-cache');
|
||||
final String engineVersionFile = path.join(flutterRoot, 'bin', 'internal', 'engine.version');
|
||||
final String engineRealmFile = path.join(flutterRoot, 'bin', 'internal', 'engine.realm');
|
||||
final String flutterPackagesVersionFile = path.join(flutterRoot, 'bin', 'internal', 'flutter_packages.version');
|
||||
|
||||
String get platformFolderName {
|
||||
if (Platform.isWindows) {
|
||||
@@ -248,7 +248,7 @@ Future<void> main(List<String> args) async {
|
||||
'web_skwasm_tests': _runWebSkwasmUnitTests,
|
||||
// All web integration tests
|
||||
'web_long_running_tests': () => webLongRunningTestsRunner(flutterRoot),
|
||||
'flutter_plugins': _runFlutterPackagesTests,
|
||||
'flutter_plugins': () => flutterPackagesRunner(flutterRoot),
|
||||
'skp_generator': skpGeneratorTestsRunner,
|
||||
'realm_checker': _runRealmCheckerTest,
|
||||
'customer_testing': _runCustomerTesting,
|
||||
@@ -1196,90 +1196,6 @@ Future<void> _runWebUnitTests(String webRenderer, bool useWasm) async {
|
||||
await selectSubshard(subshards);
|
||||
}
|
||||
|
||||
/// Returns the commit hash of the flutter/packages repository that's rolled in.
|
||||
///
|
||||
/// The flutter/packages repository is a downstream dependency, it is only used
|
||||
/// by flutter/flutter for testing purposes, to assure stable tests for a given
|
||||
/// flutter commit the flutter/packages commit hash to test against is coded in
|
||||
/// the bin/internal/flutter_packages.version file.
|
||||
///
|
||||
/// The `filesystem` parameter specified filesystem to read the packages version file from.
|
||||
/// The `packagesVersionFile` parameter allows specifying an alternative path for the
|
||||
/// packages version file, when null [flutterPackagesVersionFile] is used.
|
||||
Future<String> getFlutterPackagesVersion({
|
||||
fs.FileSystem fileSystem = const LocalFileSystem(),
|
||||
String? packagesVersionFile,
|
||||
}) async {
|
||||
final File versionFile = fileSystem.file(packagesVersionFile ?? flutterPackagesVersionFile);
|
||||
final String versionFileContents = await versionFile.readAsString();
|
||||
return versionFileContents.trim();
|
||||
}
|
||||
|
||||
/// Executes the test suite for the flutter/packages repo.
|
||||
Future<void> _runFlutterPackagesTests() async {
|
||||
Future<void> runAnalyze() async {
|
||||
printProgress('${green}Running analysis for flutter/packages$reset');
|
||||
final Directory checkout = Directory.systemTemp.createTempSync('flutter_packages.');
|
||||
await runCommand(
|
||||
'git',
|
||||
<String>[
|
||||
'-c',
|
||||
'core.longPaths=true',
|
||||
'clone',
|
||||
'https://github.com/flutter/packages.git',
|
||||
'.',
|
||||
],
|
||||
workingDirectory: checkout.path,
|
||||
);
|
||||
final String packagesCommit = await getFlutterPackagesVersion();
|
||||
await runCommand(
|
||||
'git',
|
||||
<String>[
|
||||
'-c',
|
||||
'core.longPaths=true',
|
||||
'checkout',
|
||||
packagesCommit,
|
||||
],
|
||||
workingDirectory: checkout.path,
|
||||
);
|
||||
// Prep the repository tooling.
|
||||
// This test does not use tool_runner.sh because in this context the test
|
||||
// should always run on the entire packages repo, while tool_runner.sh
|
||||
// is designed for flutter/packages CI and only analyzes changed repository
|
||||
// files when run for anything but master.
|
||||
final String toolDir = path.join(checkout.path, 'script', 'tool');
|
||||
await runCommand(
|
||||
'dart',
|
||||
<String>[
|
||||
'pub',
|
||||
'get',
|
||||
],
|
||||
workingDirectory: toolDir,
|
||||
);
|
||||
final String toolScript = path.join(toolDir, 'bin', 'flutter_plugin_tools.dart');
|
||||
await runCommand(
|
||||
'dart',
|
||||
<String>[
|
||||
'run',
|
||||
toolScript,
|
||||
'analyze',
|
||||
// Fetch the oldest possible dependencies, rather than the newest, to
|
||||
// insulate flutter/flutter from out-of-band failures when new versions
|
||||
// of dependencies are published. This compensates for the fact that
|
||||
// flutter/packages doesn't use pinned dependencies, and for the
|
||||
// purposes of this test using old dependencies is fine. See
|
||||
// https://github.com/flutter/flutter/issues/129633
|
||||
'--downgrade',
|
||||
'--custom-analysis=script/configs/custom_analysis.yaml',
|
||||
],
|
||||
workingDirectory: checkout.path,
|
||||
);
|
||||
}
|
||||
await selectSubshard(<String, ShardRunner>{
|
||||
'analyze': runAnalyze,
|
||||
});
|
||||
}
|
||||
|
||||
// Runs customer_testing.
|
||||
Future<void> _runCustomerTesting() async {
|
||||
printProgress('${green}Running customer testing$reset');
|
||||
|
||||
@@ -9,6 +9,7 @@ import 'package:file/memory.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../suite_runners/run_flutter_packages_tests.dart';
|
||||
import '../test.dart';
|
||||
import 'common.dart';
|
||||
|
||||
@@ -92,13 +93,13 @@ void main() {
|
||||
|
||||
test('commit hash', () async {
|
||||
packagesVersionFile.writeAsStringSync(kSampleHash);
|
||||
final String actualHash = await getFlutterPackagesVersion(fileSystem: memoryFileSystem, packagesVersionFile: packagesVersionFile.path);
|
||||
final String actualHash = await getFlutterPackagesVersion(flutterRoot: flutterRoot, fileSystem: memoryFileSystem, packagesVersionFile: packagesVersionFile.path);
|
||||
expect(actualHash, kSampleHash);
|
||||
});
|
||||
|
||||
test('commit hash with newlines', () async {
|
||||
packagesVersionFile.writeAsStringSync('\n$kSampleHash\n');
|
||||
final String actualHash = await getFlutterPackagesVersion(fileSystem: memoryFileSystem, packagesVersionFile: packagesVersionFile.path);
|
||||
final String actualHash = await getFlutterPackagesVersion(flutterRoot: flutterRoot, fileSystem: memoryFileSystem, packagesVersionFile: packagesVersionFile.path);
|
||||
expect(actualHash, kSampleHash);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user