dart-lang / mockito

Mockito-inspired mock library for Dart
https://pub.dev/packages/mockito
Apache License 2.0
623 stars 160 forks source link

Use `posix` path style for relative imports #721

Closed Sese-Schneider closed 6 months ago

Sese-Schneider commented 7 months ago

Details

Fixes #711

Generated relative imports paths on windows used backslashes instead of forwards slashes. This broke the DartFormatter and the build_runner aborted.

Fix

I specifically added p.Context(style: p.Style.posix) to the .relative part of the path generation. This ensures the import paths contain only forward slashes.


Contribution guidelines:
- See our [contributor guide](https://github.com/dart-lang/.github/blob/main/CONTRIBUTING.md) for general expectations for PRs. - Larger or significant changes should be discussed in an issue before creating a PR. - Contributions to our repos should follow the [Dart style guide](https://dart.dev/guides/language/effective-dart) and use `dart format`. - Most changes should add an entry to the changelog and may need to [rev the pubspec package version](https://github.com/dart-lang/sdk/wiki/External-Package-Maintenance#making-a-change). - Changes to packages require [corresponding tests](https://github.com/dart-lang/.github/blob/main/CONTRIBUTING.md#Testing). Note that many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.
Sese-Schneider commented 7 months ago

Interesting sidenote: I don't know why this broke for me suddenly. We've been using mockito for over 2 years now and everything used to work fine. Furthermore we haven't updated the dart version in our codebase in the last few months. The issue seem to have appeared out of nowhere 🤷🏼‍♂️