mirror of
https://github.com/flutter/packages.git
synced 2025-06-25 18:12:57 +08:00
[web_benchmarks] Migrate custom test to custom_package_tests
(#4429)
Removes the bespoke CI task for `web_benchmarks`, and sets up a custom test script to drive it, causing it to run in the existing `custom_package_tests` CI task. For now it's Linux-only to preserve the existing behavior; anyone is welcome to enable it for other packages in the future after ensuring it works in those environments.
This commit is contained in:
10
.ci.yaml
10
.ci.yaml
@ -238,9 +238,11 @@ targets:
|
||||
cores: "32"
|
||||
# Pigeon tests need Andoid deps (thus the Linux_android base) and
|
||||
# clang-format.
|
||||
# web_benchmarks needs Chrome.
|
||||
dependencies: >-
|
||||
[
|
||||
{"dependency": "clang", "version": "git_revision:5d5aba78dbbee75508f01bcaa69aedb2ab79065a"}
|
||||
{"dependency": "clang", "version": "git_revision:5d5aba78dbbee75508f01bcaa69aedb2ab79065a"},
|
||||
{"dependency": "chrome_and_driver", "version": "version:114.0"}
|
||||
]
|
||||
channel: master
|
||||
|
||||
@ -251,11 +253,11 @@ targets:
|
||||
version_file: flutter_stable.version
|
||||
target_file: linux_custom_package_tests.yaml
|
||||
cores: "32"
|
||||
# Pigeon tests need Android deps (thus the Linux_android base) and
|
||||
# clang-format.
|
||||
# See comments on 'master' version above.
|
||||
dependencies: >-
|
||||
[
|
||||
{"dependency": "clang", "version": "git_revision:5d5aba78dbbee75508f01bcaa69aedb2ab79065a"}
|
||||
{"dependency": "clang", "version": "git_revision:5d5aba78dbbee75508f01bcaa69aedb2ab79065a"},
|
||||
{"dependency": "chrome_and_driver", "version": "version:114.0"}
|
||||
]
|
||||
channel: stable
|
||||
|
||||
|
13
.cirrus.yml
13
.cirrus.yml
@ -170,16 +170,3 @@ task:
|
||||
- else
|
||||
- echo "This user does not have permission to run Firebase Test Lab tests."
|
||||
- fi
|
||||
### Web tasks ###
|
||||
- name: web_benchmarks_test
|
||||
env:
|
||||
matrix:
|
||||
CHROMIUM_BUILD: "950363" # Chromium 98.0.4758.0
|
||||
CHROMIUM_BUILD: "1097615" # Chromium 111
|
||||
<< : *INSTALL_CHROME_LINUX
|
||||
script:
|
||||
- cd packages/web_benchmarks/testing/test_app
|
||||
- flutter packages get
|
||||
- cd ../..
|
||||
- flutter packages get
|
||||
- dart testing/web_benchmarks_test.dart
|
||||
|
76
packages/web_benchmarks/tool/run_tests.dart
Normal file
76
packages/web_benchmarks/tool/run_tests.dart
Normal file
@ -0,0 +1,76 @@
|
||||
// Copyright 2013 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.
|
||||
|
||||
// ignore_for_file: avoid_print
|
||||
|
||||
// Runs `dart test -p chrome` in the root of the cross_file package.
|
||||
//
|
||||
// Called from the custom-tests CI action.
|
||||
//
|
||||
// usage: dart run tool/run_tests.dart
|
||||
// (needs a `chrome` executable in $PATH, or a tweak to dart_test.yaml)
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'package:path/path.dart' as p;
|
||||
|
||||
Future<void> main(List<String> args) async {
|
||||
if (!Platform.isLinux) {
|
||||
// The test was migrated from a Linux-only task, so this preserves behavior.
|
||||
// If desired, it can be enabled for other platforms in the future.
|
||||
print('Skipping for non-Linux host');
|
||||
exit(0);
|
||||
}
|
||||
|
||||
final Directory packageDir =
|
||||
Directory(p.dirname(Platform.script.path)).parent;
|
||||
final String testingAppDirPath =
|
||||
p.join(packageDir.path, 'testing', 'test_app');
|
||||
|
||||
// Fetch the test app's dependencies.
|
||||
int status = await _runProcess(
|
||||
'flutter',
|
||||
<String>[
|
||||
'pub',
|
||||
'get',
|
||||
],
|
||||
workingDirectory: testingAppDirPath,
|
||||
);
|
||||
if (status != 0) {
|
||||
exit(status);
|
||||
}
|
||||
|
||||
// Run the tests.
|
||||
status = await _runProcess(
|
||||
'flutter',
|
||||
<String>[
|
||||
'test',
|
||||
'testing',
|
||||
],
|
||||
workingDirectory: packageDir.path,
|
||||
);
|
||||
|
||||
exit(status);
|
||||
}
|
||||
|
||||
Future<Process> _streamOutput(Future<Process> processFuture) async {
|
||||
final Process process = await processFuture;
|
||||
await Future.wait(<Future<void>>[
|
||||
stdout.addStream(process.stdout),
|
||||
stderr.addStream(process.stderr),
|
||||
]);
|
||||
return process;
|
||||
}
|
||||
|
||||
Future<int> _runProcess(
|
||||
String command,
|
||||
List<String> arguments, {
|
||||
String? workingDirectory,
|
||||
}) async {
|
||||
final Process process = await _streamOutput(Process.start(
|
||||
command,
|
||||
arguments,
|
||||
workingDirectory: workingDirectory,
|
||||
));
|
||||
return process.exitCode;
|
||||
}
|
Reference in New Issue
Block a user