-
Notifications
You must be signed in to change notification settings - Fork 26.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
video_player depends on flutter_test #83562
Comments
It was moved in flutter/plugins#3281 @Hixie @gaaclarke does pigeon require test libraries to be non-dev dependencies for some reason? |
Yes, some of the APIs generated by pigeon are test APIs that themselves depend on flutter_test. We could make pigeon generate two libraries (i.e. two pubspec.yaml files), but I'm not familiar enough with how pigeon's generated libraries are used to know if that makes sense (e.g. would you need to upload two packages to pub? How many of the libraries in a federated plugin would need to be duplicated?). |
Doesn't pigeon just generate sources, not packages/libraries? |
Yea, Pigeon just generates source code, not libraries. You just specify the paths of where you want to generate the source code. I don't see a reason why a plugin should have If you want to use Pigeon to generate test code you'd just have it generate in the |
https://github.com/flutter/plugins/blob/master/packages/video_player/video_player_platform_interface/lib/test.dart is an example of what I mean. |
Shouldn't that just be in the |
Isn't it part of the video_player_platform_interface public API? |
Ahh yea, that's interesting. It's part of the public API for the platform interface, but the only clients of it are tests in packages that depend on the platform interface. You are probably better off making a new library (which is outside of the purview of pigeon). |
So we'd have video_player_platform_interface, video_player_platform_interface_test, video_player, and video_player_web? |
If only test code should ever import that file, couldn't we just make |
If it's used by other packages, then it's not a dev dependency, it's a real dependency. dev_dependency doesn't mean "only used by tests", it means "not used by people who depend on this". |
Capturing a thought that I had while not at my computer to investigate further: why is this public at all? I.e., why are tests in other packages mocking the method channels at all, since they are an internal implementation detail of the method channel implementation? Is this issue just a side effect of us not having correctly updated tests to use platform interface mocks instead of channel mocking in the other component packages when federating retroactively (which I know is a thing that happened in at least some of our packages)? |
This seems to be the case. Usually the app-facing package is tested by setting |
When video_player was federated, the existing unit tests in the app-facing package--which were based on mocking out the method channel--were left as-is. Because of the use of Pigeon, and thus Pigeon-generated mocks, this creates a dependency from the test code in the app-facing package on test code that is published from the platform interface package, which causes unwanted dependencies in the platform interface. This updates the tests in the app-facing package to follow best practices for federated plugins, which is for the app-facing tests to directly mock/fake the platform interface, not depend on the method-channel-based implementation. This simplifies the tests, ensures that they aren't also testing code from another package, and allows for removing the test code from the public interface of the platform interface package (in a seperate follow-up PR). Part of flutter/flutter#83562
When video_player was federated, the existing unit tests in the app-facing package--which were based on mocking out the method channel--were left as-is. Because of the use of Pigeon, and thus Pigeon-generated mocks, this creates a dependency from the test code in the app-facing package on test code that is published from the platform interface package, which causes unwanted dependencies in the platform interface. This updates the tests in the app-facing package to follow best practices for federated plugins, which is for the app-facing tests to directly mock/fake the platform interface, not depend on the method-channel-based implementation. This simplifies the tests, ensures that they aren't also testing code from another package, and allows for removing the test code from the public interface of the platform interface package (in a seperate follow-up PR). In order to allow the tests to work, the controller's caching of the platform instance is changed to allow it to notice changes. Part of flutter/flutter#83562
This is a breaking change to video_player_platform_interface to remove Pigeon mocks from the public interface. These should never have been there, as tests in packages outside of the platform interface should be mocking the platform interface rather than the method channel, but the app-facing tests weren't rewritten when they should have been so they ended up published to support the legacy tests. This creates an unwanted non-dev dependency on `flutter_test`, in addition to promoting an anti-pattern. While making the breaking change, this also adopts `PlatformInterface`, removing `isMock` in favor of the standard mixin pattern provided by the base class. Part of flutter/flutter#83562
Allows the other video_player packages to use either 4.x or 5.x of `video_player_platform_interface`, since the only breaking change doesn't affect them (as it just removes test code that they no longer use). This allows clients of `video_player` to no longer have a transitive dependency on test packages, but doesn't create any version lock with any unendorsed implementations that might exist. Fixes flutter/flutter#83562
Allows the other video_player packages to use either 4.x or 5.x of `video_player_platform_interface`, since the only breaking change doesn't affect them (as it just removes test code that they no longer use). This allows clients of `video_player` to no longer have a transitive dependency on test packages, but doesn't create any version lock with any unendorsed implementations that might exist. Fixes flutter/flutter#83562
This is a breaking change to video_player_platform_interface to remove Pigeon mocks from the public interface. These should never have been there, as tests in packages outside of the platform interface should be mocking the platform interface rather than the method channel, but the app-facing tests weren't rewritten when they should have been so they ended up published to support the legacy tests. This creates an unwanted non-dev dependency on `flutter_test`, in addition to promoting an anti-pattern. While making the breaking change, this also adopts `PlatformInterface`, removing `isMock` in favor of the standard mixin pattern provided by the base class. Part of flutter/flutter#83562
Allows the other video_player packages to use either 4.x or 5.x of `video_player_platform_interface`, since the only breaking change doesn't affect them (as it just removes test code that they no longer use). This allows clients of `video_player` to no longer have a transitive dependency on test packages, but doesn't create any version lock with any unendorsed implementations that might exist. Fixes flutter/flutter#83562
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
Allows the other video_player packages to use either 4.x or 5.x of `video_player_platform_interface`, since the only breaking change doesn't affect them (as it just removes test code that they no longer use). This allows clients of `video_player` to no longer have a transitive dependency on test packages, but doesn't create any version lock with any unendorsed implementations that might exist. Fixes flutter/flutter#83562
Allows the other video_player packages to use either 4.x or 5.x of `video_player_platform_interface`, since the only breaking change doesn't affect them (as it just removes test code that they no longer use). This allows clients of `video_player` to no longer have a transitive dependency on test packages, but doesn't create any version lock with any unendorsed implementations that might exist. Fixes flutter/flutter#83562
I believe this should be a dev dependency?
I don't use flutter_test myself but now I'm unable to upgrade one of my dependencies because I do use video_player and the other dependency is (regrettably) incompatible with flutter_test.
The text was updated successfully, but these errors were encountered: