From aff9cccafbe47913f1473e47b902585dc3079a8b Mon Sep 17 00:00:00 2001 From: Ian Hickson Date: Wed, 23 Mar 2022 07:05:11 -0700 Subject: [PATCH] [rfw] Run tests for package:rfw on stable as well. (#888) --- .cirrus.yml | 37 +++---------------- packages/rfw/README.md | 4 ++ packages/rfw/test/argument_decoders_test.dart | 9 ++++- packages/rfw/test/material_widgets_test.dart | 9 ++++- .../rfw/test_coverage/bin/test_coverage.dart | 27 +++++--------- 5 files changed, 35 insertions(+), 51 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 799b7f7f17e9..b4d9b78df190 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -103,16 +103,8 @@ task: CHANNEL: "master" CHANNEL: "stable" script: - # Exclude: - # - flutter_image; its tests need a test server, so are run via - # local_tests.sh. - # - rfw on stable; it includes golden tests whose results differ - # between branch - - if [[ "$CHANNEL" == "master" ]]; then - - ./script/tool_runner.sh test --exclude=flutter_image - - else - - ./script/tool_runner.sh test --exclude=flutter_image,rfw - - fi + # We exclude flutter_image because its tests need a test server, so are run via local_tests.sh. + - ./script/tool_runner.sh test --exclude=flutter_image depends_on: - format+analyze - name: android-build+platform-tests @@ -123,18 +115,8 @@ task: script: # extension_google_sign_in_as_googleapis_auth is currently not building, see # https://github.com/flutter/flutter/issues/89301 - # rfw is excluded until the next Flutter stable release because it depends - # on features that have never shipped to stable. (The rfw package has - # never worked on stable so this is not going to break anyone.) - # When updating this, also look at the ios tests below. - # When updating this, also update the `rfw/run_tests.sh` file. - - if [[ "$CHANNEL" == "master" ]]; then - - ./script/tool_runner.sh build-examples --apk --exclude=extension_google_sign_in_as_googleapis_auth - - ./script/tool_runner.sh native-test --android --no-integration - - else - - ./script/tool_runner.sh build-examples --apk --exclude=extension_google_sign_in_as_googleapis_auth,rfw - - ./script/tool_runner.sh native-test --android --no-integration --exclude=rfw - - fi + - ./script/tool_runner.sh build-examples --apk --exclude=extension_google_sign_in_as_googleapis_auth + - ./script/tool_runner.sh native-test --android --no-integration depends_on: - format+analyze - name: web_benchmarks_test @@ -164,16 +146,7 @@ task: CHANNEL: "master" CHANNEL: "stable" build_script: - # Exclude rfw until the next Flutter stable release because it depends - # on features that have never shipped to stable. (The rfw package has - # never worked on stable so this is not going to break anyone.) - # When updating this, also look at the android tests above. - # When updating this, also update the `rfw/run_tests.sh` file. - - if [[ "$CHANNEL" == "master" ]]; then - - ./script/tool_runner.sh build-examples --ios - - else - - ./script/tool_runner.sh build-examples --ios --exclude=rfw - - fi + - ./script/tool_runner.sh build-examples --ios - name: local_tests env: PATH: $PATH:/usr/local/bin diff --git a/packages/rfw/README.md b/packages/rfw/README.md index c9b713fe5833..6f88df8c9d08 100644 --- a/packages/rfw/README.md +++ b/packages/rfw/README.md @@ -266,3 +266,7 @@ When contributing code, ensure that `flutter test --coverage; lcov update `test_coverage/bin/test_coverage.dart` with the appropriate expectations to prevent future coverage regressions. (That program is run by `run_tests.sh`.) + +Golden tests are only run against the Flutter master channel and only +run on Linux, since minor rendering differences are expected on +different platforms and on different versions of Flutter. \ No newline at end of file diff --git a/packages/rfw/test/argument_decoders_test.dart b/packages/rfw/test/argument_decoders_test.dart index dfe0abb2a066..b54d6b09977b 100644 --- a/packages/rfw/test/argument_decoders_test.dart +++ b/packages/rfw/test/argument_decoders_test.dart @@ -4,11 +4,18 @@ // This file is hand-formatted. +import 'dart:io' show Platform; + import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:rfw/formats.dart' show parseLibraryFile; import 'package:rfw/rfw.dart'; +// See Contributing section of README.md file. +final bool runGoldens = Platform.isLinux && + (!Platform.environment.containsKey('CHANNEL') || + Platform.environment['CHANNEL'] == 'master'); + void main() { testWidgets('String example', (WidgetTester tester) async { Duration? duration; @@ -494,5 +501,5 @@ void main() { find.byType(RemoteWidget), matchesGoldenFile('goldens/argument_decoders_test.gridview.custom.png'), ); - }); + }, skip: !runGoldens); } diff --git a/packages/rfw/test/material_widgets_test.dart b/packages/rfw/test/material_widgets_test.dart index 9ce6bd0ba4b5..eef21e4fc668 100644 --- a/packages/rfw/test/material_widgets_test.dart +++ b/packages/rfw/test/material_widgets_test.dart @@ -2,11 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'dart:io' show Platform; + import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:rfw/formats.dart' show parseLibraryFile; import 'package:rfw/rfw.dart'; +// See Contributing section of README.md file. +final bool runGoldens = Platform.isLinux && + (!Platform.environment.containsKey('CHANNEL') || + Platform.environment['CHANNEL'] == 'master'); + void main() { testWidgets('Material widgets', (WidgetTester tester) async { final Runtime runtime = Runtime() @@ -140,5 +147,5 @@ void main() { find.byType(RemoteWidget), matchesGoldenFile('goldens/material_test.drawer.png'), ); - }); + }, skip: !runGoldens); } diff --git a/packages/rfw/test_coverage/bin/test_coverage.dart b/packages/rfw/test_coverage/bin/test_coverage.dart index f1dcee539de7..f0c4cdfabbc4 100644 --- a/packages/rfw/test_coverage/bin/test_coverage.dart +++ b/packages/rfw/test_coverage/bin/test_coverage.dart @@ -15,39 +15,32 @@ const String lastUpdate = '2021-08-30'; Future main(List arguments) async { // This script is mentioned in the README.md file. - if (Platform.environment['CHANNEL'] == 'stable') { - // For now these are disabled because this package has never been supported - // on the stable channel and requires newer language features that have not - // yet shipped to a stable build. It will be possible to test this with the - // first stable to ship after October 2021. - print( - 'Skipping tests on stable channel.\n' - 'These tests can be unskipped once we ship a stable after October 2021.', - ); - exit(0); - } - final Directory coverageDirectory = Directory('coverage'); if (coverageDirectory.existsSync()) { coverageDirectory.deleteSync(recursive: true); } - // We run with --update-goldens because the goal here is not to verify the tests - // pass but to verify the coverage, and the goldens are not always going to pass - // when run on different platforms (e.g. on Cirrus we run this on a mac but the - // goldens expect a linux box). final ProcessResult result = Process.runSync( 'flutter', - ['test', '--coverage', '--update-goldens'], + ['test', '--coverage'], ); if (result.exitCode != 0) { print(result.stdout); print(result.stderr); print('Tests failed.'); + // leave coverage directory around to aid debugging exit(1); } + if (Platform.environment['CHANNEL'] != 'master') { + print( + 'Tests passed. (Coverage verification skipped; not on master channel.)', + ); + coverageDirectory.deleteSync(recursive: true); + exit(0); + } + final List records = await lcov.Parser.parse( 'coverage/lcov.info', );