Skip to content

Commit

Permalink
[tool] Check for test and flutter_test in non-dev dependencies (f…
Browse files Browse the repository at this point in the history
…lutter#6472)

*Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.*

Additional checks as a followup to flutter#6446

*List which issues are fixed by this PR. You must list at least one issue.*

Related to flutter/flutter#145992

*If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
  • Loading branch information
ekuleshov authored Apr 10, 2024
1 parent 6f0ed15 commit e98839a
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 11 deletions.
3 changes: 2 additions & 1 deletion packages/css_colors/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## NEXT
## 1.1.5

* Updates minimum supported SDK version to Flutter 3.13/Dart 3.1.
* Moves flutter_test and test dependencies to dev_dependencies.

## 1.1.4

Expand Down
4 changes: 3 additions & 1 deletion packages/css_colors/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: css_colors
description: Defines constant dart:ui Color objects for CSS colors (for use in Flutter code).
repository: https://github.com/flutter/packages/tree/main/packages/css_colors
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+css_colors%22
version: 1.1.4
version: 1.1.5

environment:
sdk: ^3.1.0
Expand All @@ -11,6 +11,8 @@ environment:
dependencies:
flutter:
sdk: flutter

dev_dependencies:
flutter_test:
sdk: flutter

Expand Down
4 changes: 4 additions & 0 deletions packages/web_benchmarks/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.2.2

* Moves flutter_test and test dependencies to dev_dependencies.

## 1.2.1

* Removes a few deprecated API usages.
Expand Down
10 changes: 6 additions & 4 deletions packages/web_benchmarks/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: web_benchmarks
description: A benchmark harness for performance-testing Flutter apps in Chrome.
repository: https://github.com/flutter/packages/tree/main/packages/web_benchmarks
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+web_benchmarks%22
version: 1.2.1
version: 1.2.2

environment:
sdk: ^3.3.0
Expand All @@ -12,18 +12,20 @@ dependencies:
collection: ^1.18.0
flutter:
sdk: flutter
flutter_test:
sdk: flutter
logging: ^1.0.2
meta: ^1.7.0
path: ^1.8.0
process: ">=4.2.4 <6.0.0"
shelf: ^1.2.0
shelf_static: ^1.1.0
test: ^1.19.5
web: ^0.5.0
webkit_inspection_protocol: ^1.0.0

dev_dependencies:
flutter_test:
sdk: flutter
test: ^1.19.5

topics:
- benchmarking
- performance
2 changes: 1 addition & 1 deletion script/tool/lib/src/pubspec_check_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ class PubspecCheckCommand extends PackageLoopingCommand {
}

// Ensure that dev-only dependencies aren't in `dependencies`.
const List<String> devOnlyDependencies = <String>['integration_test'];
const Set<String> devOnlyDependencies = <String>{'integration_test', 'test', 'flutter_test'};
// Non-published packages like pidgeon subpackages are allowed to violate
// the dev only dependencies rule.
if (pubspec.publishTo != 'none') {
Expand Down
17 changes: 13 additions & 4 deletions script/tool/test/pubspec_check_command_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1735,15 +1735,19 @@ ${_topicsSection()}
);
});

test('fails when integration_test is used in non dev dependency',
test('fails when integration_test, flutter_test or test are used in non dev dependency',
() async {
final RepositoryPackage package =
createFakePackage('a_package', packagesDir, examples: <String>[]);

package.pubspecFile.writeAsStringSync('''
${_headerSection('a_package')}
${_environmentSection()}
${_dependenciesSection(<String>['integration_test: \n sdk: flutter'])}
${_dependenciesSection(<String>[
'integration_test: \n sdk: flutter',
'flutter_test: \n sdk: flutter',
'test: 1.0.0'
])}
${_devDependenciesSection()}
${_topicsSection()}
''');
Expand All @@ -1761,22 +1765,27 @@ ${_topicsSection()}
containsAllInOrder(<Matcher>[
contains(
'The following unexpected non-local dependencies were found:\n'
' test\n'
' integration_test\n'
' flutter_test\n'
'Please see https://github.com/flutter/flutter/wiki/Contributing-to-Plugins-and-Packages#Dependencies '
'for more information and next steps.'),
]),
);
});

test('passes when integration_test is used in non published package',
test('passes when integration_test or flutter_test are used in non published package',
() async {
final RepositoryPackage package =
createFakePackage('a_package', packagesDir, examples: <String>[]);

package.pubspecFile.writeAsStringSync('''
${_headerSection('a_package', publishable: false)}
${_environmentSection()}
${_dependenciesSection(<String>['integration_test: \n sdk: flutter'])}
${_dependenciesSection(<String>[
'integration_test: \n sdk: flutter',
'flutter_test: \n sdk: flutter'
])}
${_devDependenciesSection()}
${_topicsSection()}
''');
Expand Down

0 comments on commit e98839a

Please sign in to comment.