[web] Fail if Skia Gold is required but unavailable (flutter/engine#29792)

This commit is contained in:
Mouad Debbar
2021-11-23 01:38:03 +00:00
committed by GitHub
parent b6f5e8e868
commit eadc6df16d
3 changed files with 32 additions and 4 deletions

View File

@@ -29,6 +29,12 @@ class RunCommand extends Command<bool> with ArgUtils<bool> {
defaultsTo: false,
help: 'Lists all available build steps.',
);
argParser.addFlag(
'require-skia-gold',
defaultsTo: false,
help: 'Whether we require Skia Gold to be available or not. When this '
'flag is true, the tests will fail if Skia Gold is not available.',
);
}
@override
@@ -36,6 +42,10 @@ class RunCommand extends Command<bool> with ArgUtils<bool> {
bool get isListSteps => boolArg('list');
/// When running screenshot tests, require Skia Gold to be available and
/// reachable.
bool get requireSkiaGold => boolArg('require-skia-gold');
@override
String get description => 'Runs a build step.';
@@ -52,6 +62,7 @@ class RunCommand extends Command<bool> with ArgUtils<bool> {
browserName: browserName,
isDebug: false,
doUpdateScreenshotGoldens: false,
requireSkiaGold: requireSkiaGold,
overridePathToCanvasKit: null,
),
};

View File

@@ -38,6 +38,7 @@ class RunTestsStep implements PipelineStep {
required this.browserName,
required this.isDebug,
required this.doUpdateScreenshotGoldens,
required this.requireSkiaGold,
this.testFiles,
required this.overridePathToCanvasKit,
}) : _browserEnvironment = getBrowserEnvironment(browserName);
@@ -48,6 +49,9 @@ class RunTestsStep implements PipelineStep {
final bool doUpdateScreenshotGoldens;
final String? overridePathToCanvasKit;
/// Require Skia Gold to be available and reachable.
final bool requireSkiaGold;
final BrowserEnvironment _browserEnvironment;
/// Global list of shards that failed.
@@ -184,12 +188,13 @@ class RunTestsStep implements PipelineStep {
browserName: browserName,
);
if (!await _checkSkiaClient(skiaClient)) {
print('WARNING: Unable to use Skia Client in this environment.');
return null;
if (await _checkSkiaClient(skiaClient)) {
return skiaClient;
}
return skiaClient;
if (requireSkiaGold) {
throw ToolExit('Skia Gold is required but is unavailable.');
}
}
/// Checks whether the Skia Client is usable in this environment.

View File

@@ -51,6 +51,13 @@ class TestCommand extends Command<bool> with ArgUtils<bool> {
'won\'t be consistent with CIs when this flag is set. flutter '
'command should be set in the PATH for this flag to be useful.'
'This flag can also be used to test local Flutter changes.')
..addFlag(
'require-skia-gold',
defaultsTo: false,
help:
'Whether we require Skia Gold to be available or not. When this '
'flag is true, the tests will fail if Skia Gold is not available.',
)
..addFlag(
'update-screenshot-goldens',
defaultsTo: false,
@@ -117,6 +124,10 @@ class TestCommand extends Command<bool> with ArgUtils<bool> {
/// The name of the browser to run tests in.
String get browserName => stringArg('browser');
/// When running screenshot tests, require Skia Gold to be available and
/// reachable.
bool get requireSkiaGold => boolArg('require-skia-gold');
/// When running screenshot tests writes them to the file system into
/// ".dart_tool/goldens".
bool get doUpdateScreenshotGoldens => boolArg('update-screenshot-goldens');
@@ -144,6 +155,7 @@ class TestCommand extends Command<bool> with ArgUtils<bool> {
testFiles: testFiles,
isDebug: isDebug,
doUpdateScreenshotGoldens: doUpdateScreenshotGoldens,
requireSkiaGold: requireSkiaGold,
overridePathToCanvasKit: overridePathToCanvasKit,
),
]);