Skip to content

Commit d395c23

Browse files
committed
Run tests for package:rfw on stable as well.
For non-master-channel builds, the run_tests.sh script runs but doesn't bother checking the actual coverage, since I expect Dart's coverage logic to diverge in master and so we'd have to have per-channel covered line counts, and that way lies madness. No version change: Only affects how tests are run, not a public-facing change. No CHANGELOG change: Only affects how tests are run, not a public-facing change.
1 parent 39435b8 commit d395c23

File tree

5 files changed

+35
-51
lines changed

5 files changed

+35
-51
lines changed

.cirrus.yml

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,8 @@ task:
7878
CHANNEL: "master"
7979
CHANNEL: "stable"
8080
script:
81-
# Exclude:
82-
# - flutter_image; its tests need a test server, so are run via
83-
# local_tests.sh.
84-
# - rfw on stable; it includes golden tests whose results differ
85-
# between branch
86-
- if [[ "$CHANNEL" == "master" ]]; then
87-
- ./script/tool_runner.sh test --exclude=flutter_image
88-
- else
89-
- ./script/tool_runner.sh test --exclude=flutter_image,rfw
90-
- fi
81+
# We exclude flutter_image because its tests need a test server, so are run via local_tests.sh.
82+
- ./script/tool_runner.sh test --exclude=flutter_image
9183
depends_on:
9284
- format+analyze
9385
- name: android-build+platform-tests
@@ -98,18 +90,8 @@ task:
9890
script:
9991
# extension_google_sign_in_as_googleapis_auth is currently not building, see
10092
# https://github.com/flutter/flutter/issues/89301
101-
# rfw is excluded until the next Flutter stable release because it depends
102-
# on features that have never shipped to stable. (The rfw package has
103-
# never worked on stable so this is not going to break anyone.)
104-
# When updating this, also look at the ios tests below.
105-
# When updating this, also update the `rfw/run_tests.sh` file.
106-
- if [[ "$CHANNEL" == "master" ]]; then
107-
- ./script/tool_runner.sh build-examples --apk --exclude=extension_google_sign_in_as_googleapis_auth
108-
- ./script/tool_runner.sh native-test --android --no-integration
109-
- else
110-
- ./script/tool_runner.sh build-examples --apk --exclude=extension_google_sign_in_as_googleapis_auth,rfw
111-
- ./script/tool_runner.sh native-test --android --no-integration --exclude=rfw
112-
- fi
93+
- ./script/tool_runner.sh build-examples --apk --exclude=extension_google_sign_in_as_googleapis_auth
94+
- ./script/tool_runner.sh native-test --android --no-integration
11395
depends_on:
11496
- format+analyze
11597
- name: web_benchmarks_test
@@ -140,16 +122,7 @@ task:
140122
CHANNEL: "stable"
141123
<< : *FLUTTER_UPGRADE_TEMPLATE
142124
build_script:
143-
# Exclude rfw until the next Flutter stable release because it depends
144-
# on features that have never shipped to stable. (The rfw package has
145-
# never worked on stable so this is not going to break anyone.)
146-
# When updating this, also look at the android tests above.
147-
# When updating this, also update the `rfw/run_tests.sh` file.
148-
- if [[ "$CHANNEL" == "master" ]]; then
149-
- ./script/tool_runner.sh build-examples --ios
150-
- else
151-
- ./script/tool_runner.sh build-examples --ios --exclude=rfw
152-
- fi
125+
- ./script/tool_runner.sh build-examples --ios
153126

154127
task:
155128
name: local_tests

packages/rfw/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,3 +266,7 @@ When contributing code, ensure that `flutter test --coverage; lcov
266266
update `test_coverage/bin/test_coverage.dart` with the appropriate
267267
expectations to prevent future coverage regressions. (That program is
268268
run by `run_tests.sh`.)
269+
270+
Golden tests are only run against the Flutter master channel and only
271+
run on Linux, since minor rendering differences are expected on
272+
different platforms and on different versions of Flutter.

packages/rfw/test/argument_decoders_test.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,18 @@
44

55
// This file is hand-formatted.
66

7+
import 'dart:io' show Platform;
8+
79
import 'package:flutter/material.dart';
810
import 'package:flutter_test/flutter_test.dart';
911
import 'package:rfw/formats.dart' show parseLibraryFile;
1012
import 'package:rfw/rfw.dart';
1113

14+
// See Contributing section of README.md file.
15+
final bool runGoldens = Platform.isLinux &&
16+
(!Platform.environment.containsKey('CHANNEL') ||
17+
Platform.environment['CHANNEL'] == 'master');
18+
1219
void main() {
1320
testWidgets('String example', (WidgetTester tester) async {
1421
Duration? duration;
@@ -494,5 +501,5 @@ void main() {
494501
find.byType(RemoteWidget),
495502
matchesGoldenFile('goldens/argument_decoders_test.gridview.custom.png'),
496503
);
497-
});
504+
}, skip: !runGoldens);
498505
}

packages/rfw/test/material_widgets_test.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,18 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
import 'dart:io' show Platform;
6+
57
import 'package:flutter/material.dart';
68
import 'package:flutter_test/flutter_test.dart';
79
import 'package:rfw/formats.dart' show parseLibraryFile;
810
import 'package:rfw/rfw.dart';
911

12+
// See Contributing section of README.md file.
13+
final bool runGoldens = Platform.isLinux &&
14+
(!Platform.environment.containsKey('CHANNEL') ||
15+
Platform.environment['CHANNEL'] == 'master');
16+
1017
void main() {
1118
testWidgets('Material widgets', (WidgetTester tester) async {
1219
final Runtime runtime = Runtime()
@@ -140,5 +147,5 @@ void main() {
140147
find.byType(RemoteWidget),
141148
matchesGoldenFile('goldens/material_test.drawer.png'),
142149
);
143-
});
150+
}, skip: !runGoldens);
144151
}

packages/rfw/test_coverage/bin/test_coverage.dart

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,39 +15,32 @@ const String lastUpdate = '2021-08-30';
1515
Future<void> main(List<String> arguments) async {
1616
// This script is mentioned in the README.md file.
1717

18-
if (Platform.environment['CHANNEL'] == 'stable') {
19-
// For now these are disabled because this package has never been supported
20-
// on the stable channel and requires newer language features that have not
21-
// yet shipped to a stable build. It will be possible to test this with the
22-
// first stable to ship after October 2021.
23-
print(
24-
'Skipping tests on stable channel.\n'
25-
'These tests can be unskipped once we ship a stable after October 2021.',
26-
);
27-
exit(0);
28-
}
29-
3018
final Directory coverageDirectory = Directory('coverage');
3119

3220
if (coverageDirectory.existsSync()) {
3321
coverageDirectory.deleteSync(recursive: true);
3422
}
3523

36-
// We run with --update-goldens because the goal here is not to verify the tests
37-
// pass but to verify the coverage, and the goldens are not always going to pass
38-
// when run on different platforms (e.g. on Cirrus we run this on a mac but the
39-
// goldens expect a linux box).
4024
final ProcessResult result = Process.runSync(
4125
'flutter',
42-
<String>['test', '--coverage', '--update-goldens'],
26+
<String>['test', '--coverage'],
4327
);
4428
if (result.exitCode != 0) {
4529
print(result.stdout);
4630
print(result.stderr);
4731
print('Tests failed.');
32+
// leave coverage directory around to aid debugging
4833
exit(1);
4934
}
5035

36+
if (Platform.environment['CHANNEL'] != 'master') {
37+
print(
38+
'Tests passed. (Coverage verification skipped; not on master channel.)',
39+
);
40+
coverageDirectory.deleteSync(recursive: true);
41+
exit(0);
42+
}
43+
5144
final List<lcov.Record> records = await lcov.Parser.parse(
5245
'coverage/lcov.info',
5346
);

0 commit comments

Comments
 (0)