Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 0477e05

Browse files
authored
[web] Fail if Skia Gold is required but unavailable (#29792)
1 parent 3845cee commit 0477e05

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

lib/web_ui/dev/run.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,23 @@ class RunCommand extends Command<bool> with ArgUtils<bool> {
2929
defaultsTo: false,
3030
help: 'Lists all available build steps.',
3131
);
32+
argParser.addFlag(
33+
'require-skia-gold',
34+
defaultsTo: false,
35+
help: 'Whether we require Skia Gold to be available or not. When this '
36+
'flag is true, the tests will fail if Skia Gold is not available.',
37+
);
3238
}
3339

3440
@override
3541
String get name => 'run';
3642

3743
bool get isListSteps => boolArg('list');
3844

45+
/// When running screenshot tests, require Skia Gold to be available and
46+
/// reachable.
47+
bool get requireSkiaGold => boolArg('require-skia-gold');
48+
3949
@override
4050
String get description => 'Runs a build step.';
4151

@@ -52,6 +62,7 @@ class RunCommand extends Command<bool> with ArgUtils<bool> {
5262
browserName: browserName,
5363
isDebug: false,
5464
doUpdateScreenshotGoldens: false,
65+
requireSkiaGold: requireSkiaGold,
5566
overridePathToCanvasKit: null,
5667
),
5768
};

lib/web_ui/dev/steps/run_tests_step.dart

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class RunTestsStep implements PipelineStep {
3838
required this.browserName,
3939
required this.isDebug,
4040
required this.doUpdateScreenshotGoldens,
41+
required this.requireSkiaGold,
4142
this.testFiles,
4243
required this.overridePathToCanvasKit,
4344
}) : _browserEnvironment = getBrowserEnvironment(browserName);
@@ -48,6 +49,9 @@ class RunTestsStep implements PipelineStep {
4849
final bool doUpdateScreenshotGoldens;
4950
final String? overridePathToCanvasKit;
5051

52+
/// Require Skia Gold to be available and reachable.
53+
final bool requireSkiaGold;
54+
5155
final BrowserEnvironment _browserEnvironment;
5256

5357
/// Global list of shards that failed.
@@ -184,12 +188,13 @@ class RunTestsStep implements PipelineStep {
184188
browserName: browserName,
185189
);
186190

187-
if (!await _checkSkiaClient(skiaClient)) {
188-
print('WARNING: Unable to use Skia Client in this environment.');
189-
return null;
191+
if (await _checkSkiaClient(skiaClient)) {
192+
return skiaClient;
190193
}
191194

192-
return skiaClient;
195+
if (requireSkiaGold) {
196+
throw ToolExit('Skia Gold is required but is unavailable.');
197+
}
193198
}
194199

195200
/// Checks whether the Skia Client is usable in this environment.

lib/web_ui/dev/test_runner.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ class TestCommand extends Command<bool> with ArgUtils<bool> {
5151
'won\'t be consistent with CIs when this flag is set. flutter '
5252
'command should be set in the PATH for this flag to be useful.'
5353
'This flag can also be used to test local Flutter changes.')
54+
..addFlag(
55+
'require-skia-gold',
56+
defaultsTo: false,
57+
help:
58+
'Whether we require Skia Gold to be available or not. When this '
59+
'flag is true, the tests will fail if Skia Gold is not available.',
60+
)
5461
..addFlag(
5562
'update-screenshot-goldens',
5663
defaultsTo: false,
@@ -117,6 +124,10 @@ class TestCommand extends Command<bool> with ArgUtils<bool> {
117124
/// The name of the browser to run tests in.
118125
String get browserName => stringArg('browser');
119126

127+
/// When running screenshot tests, require Skia Gold to be available and
128+
/// reachable.
129+
bool get requireSkiaGold => boolArg('require-skia-gold');
130+
120131
/// When running screenshot tests writes them to the file system into
121132
/// ".dart_tool/goldens".
122133
bool get doUpdateScreenshotGoldens => boolArg('update-screenshot-goldens');
@@ -144,6 +155,7 @@ class TestCommand extends Command<bool> with ArgUtils<bool> {
144155
testFiles: testFiles,
145156
isDebug: isDebug,
146157
doUpdateScreenshotGoldens: doUpdateScreenshotGoldens,
158+
requireSkiaGold: requireSkiaGold,
147159
overridePathToCanvasKit: overridePathToCanvasKit,
148160
),
149161
]);

0 commit comments

Comments
 (0)