Skip to content
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

Merge package:mockito #2293

Open
wants to merge 632 commits into
base: master
Choose a base branch
from
Open

Merge package:mockito #2293

wants to merge 632 commits into from

Conversation

mosuem
Copy link
Member

@mosuem mosuem commented Oct 17, 2024

  • Move and fix workflow files, labeler.yaml, and badges in the README.md
  • Rev the version of the package, so that pub.dev points to the correct site
  • Add a line to the changelog:
* Move to `dart-lang/test` monorepo.
  • Add the package to the top-level readme of the monorepo:
| [mockito](pkgs/mockito/) | A mock framework inspired by Mockito with APIs for Fakes, Mocks, behavior verification, and stubbing. | [![pub package](https://img.shields.io/pub/v/mockito.svg)](https://pub.dev/packages/mockito) |
> [!IMPORTANT]  
> This repo has moved to https://github.com/dart-lang/test/tree/master/pkgs/mockito
  • Publish using the autopublish workflow
  • Push tags to GitHub using git tag --list 'mockito*' | xargs git push origin
  • Close open PRs in dart-lang/mockito with the following message:
Closing as the [dart-lang/mockito](https://github.com/dart-lang/mockito) repository is merged into the [dart-lang/test](https://github.com/dart-lang/test) monorepo. Please re-open this PR there!
  • Transfer issues by running dart run pkgs/repo_manage/bin/report.dart transfer-issues --source-repo dart-lang/mockito --target-repo dart-lang/test --add-label package:mockito --apply-changes
  • Archive https://github.com/dart-lang/mockito/
  • Import to g3

  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.
Contribution guidelines:

Note that many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.

srawlins and others added 30 commits May 25, 2021 11:25
Also add another test for fallback generators

Also bump to 5.0.9

PiperOrigin-RevId: 375738620
* Fix typo in README
* Fix typo in NULL_SAFETY_README regarding fallback generators.
* Add text in various argument matchers clarifying positional vs named arguments.
* Add links in each argument matcher (`any`, `anyNamed`, `argThat`, `captureAny`, etc) back to their respective sections in the README.

An alternative to the last item would be to inline the examples. I'd love to do this, but only via automated build... not sure how to do that yet.

PiperOrigin-RevId: 375955488
…ld of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.
It is just DartType, specifically because we want to make FunctionType just a DartType.

PiperOrigin-RevId: 376206358
A fallback generator must have _approximately_ the same signature, but parameter types must all be nullable.

Fixes dart-lang/mockito#417

PiperOrigin-RevId: 376213042
…g`, `hashCode`, or `operator==`.

Calling `super.noSuchMethod` in any of these situations triggers the "missing stub" checks, and also conflicts with mockito behavior which relies on being able to use the [Mock] implementations.

PiperOrigin-RevId: 376895132
…ch the

signature of an overriding method which adds optional parameters.

Fixes dart-lang/mockito#371

PiperOrigin-RevId: 377388828
… "custom mock" annotation with implicit type arguments.

Given a method which references
type variables defined on their enclosing class (for example, `T` in
`class Foo<T>`), mockito will now correctly reference `T` in generated code.

Fixes dart-lang/mockito#422

PiperOrigin-RevId: 377571931
This uses the commands we're deprecating, and I don't think it's being used anymore after we migrated to Github Actions?
* Allow two mocks of the same class (with different type arguments) to be
  specified with different fallback generators.
* Allow fallback generators on super types of a mocked class.

This change strongly suggested a code restructuring, moving the bulk of the code-building into a new "MockClassInfo" class, extracted from MockLibraryInfo.

I've incorporated this change; most of the fields on MockLibraryInfo is moved to MockClassInfo; only a few fields remain, which are fields important to be shared across class-building code.

PiperOrigin-RevId: 378307281
dart-lang/mockito@cc1b0c8

Fix spelling and grammar typos in README.md

PiperOrigin-RevId: 382620480
dart-lang/mockito@825e213

Follow Dart file conventions | Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

PiperOrigin-RevId: 382634050
PiperOrigin-RevId: 382755039
Generated code may import 'src' files.

PiperOrigin-RevId: 382756565
The inference_failure_on_instance_creation error will trigger on code like

```
returnValueForMissingStub: Future.value()
```

because, even though no value has been given to `value()`, that does not
affect the Future's type (it still defaults to `void`). Explicitly using
`Future<void>.value()` satisfies the check.

PiperOrigin-RevId: 382770034
Without this support, mockito tried to create a FakeFunction which implemented Function, which is not allowed.

Fixes dart-lang/mockito#442

PiperOrigin-RevId: 384852004
…e<T>`.

Before this fix, we would only return `[]` which had an implicit dynamic: `<dynamic>[]`. The proper return value should explicitly include the expected type argument.

Existing test cases cover the desired behavior.

Also replace `var` with `final` in surrounding code.

Fixes dart-lang/mockito#445

PiperOrigin-RevId: 384965296
PiperOrigin-RevId: 385356711
If the generated code needs to represent a type, `T`, and that type is declared
in library `L`, then we now prefer to import a library which _exports_ `L` (if
one exists), over importing `L` directly.

To find such a library, we look at the type, `U` which references `T`. Perhaps
`U` is a class to mocked, and `U` has a method with a return type `T`, or `U` is
a supertype of a class to be mocked, which has a method with a parameter type
`T`, etc. We examine all of the import libraries, `IL`, of the library in which
`U` is declared, and all of the libraries which are exported by the libraries
`IL`.

If the type `T` is declared in a library which is exported as a conditional
export, this strategy avoids complications with the conditional export.
Additionally, as a heuristic, it generally leads to public libraries which
export private implementation, avoiding importing the private implementation
directly.

Fixes dart-lang/mockito#443

PiperOrigin-RevId: 385425794
PiperOrigin-RevId: 385440655
We might generate setters without getters.

PiperOrigin-RevId: 385802287
* Properly reference types in overridden `toString` implementations.
  Fixes dart-lang/mockito#438
* Override `toString` in a Fake implementation when the class-to-be-faked has
  a superclass which overrides `toString` with additional parameters.
  Fixes dart-lang/mockito#371

PiperOrigin-RevId: 385852381
…rarchy.

Previously, mixins were being applied in the wrong order. By using analyzer's InheritanceManager3, instead of my homespun inheritance-walking algorithm, we
solve this problem, and perhaps other unreported issues.

Fixes dart-lang/mockito#456

PiperOrigin-RevId: 387741287
Without this fix, the generator could generate multiple classes with the same name.

Fixes dart-lang/mockito#441

PiperOrigin-RevId: 388959500
* comment fix, long string fix
* bump version and add to CHANGELOG

PiperOrigin-RevId: 390005036
srawlins and others added 13 commits June 25, 2024 08:58
PiperOrigin-RevId: 646496713
…le change.

This lint rule currently measures from the end of the condition, but needs to measure from the start of the if-statement. E.g.

if ("long condition and other long condition" != "another long condition" &&
     "more tests".isNotEmpty) return null;
This is currently allowed, but should not be, as per Effective Dart.

This will be fixed in a Dart SDK CL.

PiperOrigin-RevId: 647347218
…-lang/mockito#761)

Bumps the github-actions group with 2 updates in the / directory: [actions/checkout](https://github.com/actions/checkout) and [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart).


Updates `actions/checkout` from 4.1.1 to 4.1.7
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@b4ffde6...692973e)

Updates `dart-lang/setup-dart` from 1.6.2 to 1.6.5
- [Release notes](https://github.com/dart-lang/setup-dart/releases)
- [Changelog](https://github.com/dart-lang/setup-dart/blob/main/CHANGELOG.md)
- [Commits](dart-lang/setup-dart@fedb126...0a8a0fc)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
- dependency-name: dart-lang/setup-dart
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Mostly fixes dart-lang/mockito#697.

I'm still not quite satisfied with the documentation for
`provideDummyBuilder` since the `DummyBuilder` `typedef` remains
undocumented, but I can't write documentation for that because I
don't understand its arguments.
Also remove some unused elements.

PiperOrigin-RevId: 673093545
This will be required in an upcoming version of the Dart formatter.

PiperOrigin-RevId: 673452282
PiperOrigin-RevId: 674448702
PiperOrigin-RevId: 681769728
PiperOrigin-RevId: 684477097
@mosuem mosuem requested a review from a team as a code owner October 17, 2024 14:06
Copy link

PR Health

Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

@mosuem mosuem requested review from srawlins, devoncarew and natebosch and removed request for a team October 17, 2024 14:20
@mosuem mosuem mentioned this pull request Oct 17, 2024
13 tasks
@mosuem
Copy link
Member Author

mosuem commented Oct 21, 2024

@srawlins, the analyze job is failing, which seems to already have been the case in the other repository. Is this a bug which needs to be investigated, or is this a known behavior?

@srawlins
Copy link
Member

I don't see the pubspec, but I imagine the deps just need to be bumped. Or mockito in google3 might be using unpublished elements from analyzer.

@mosuem
Copy link
Member Author

mosuem commented Oct 29, 2024

I don't see the pubspec, but I imagine the deps just need to be bumped. Or mockito in google3 might be using unpublished elements from analyzer.

It seems like stable Dart does not yet support some features. I would advise to move this package with the failing CI, and fix the issue in a follow up. IIUC, fixing would require depending on a dev version of Dart, or removing the use of these features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.