Skip to content

[web_benchmarks] Migrate custom test to custom_package_tests #4429

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -253,11 +255,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

Expand Down
13 changes: 0 additions & 13 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,16 +180,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 changes: 76 additions & 0 deletions packages/web_benchmarks/tool/run_tests.dart
Original file line number Diff line number Diff line change
@@ -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;
}