sdk icon indicating copy to clipboard operation
sdk copied to clipboard

pkg/frontend_server has 10 files opted out of null safety

Open jakemac53 opened this issue 3 years ago • 19 comments

Found 10 file excluded from sound null safety:

  • pkg/frontend_server/bin/frontend_server_starter.dart
  • pkg/frontend_server/lib/compute_kernel.dart
  • pkg/frontend_server/lib/frontend_server.dart
  • pkg/frontend_server/lib/src/javascript_bundle.dart
  • pkg/frontend_server/lib/src/strong_components.dart
  • pkg/frontend_server/test/frontend_server_flutter_suite.dart
  • pkg/frontend_server/test/frontend_server_flutter.dart
  • pkg/frontend_server/test/frontend_server_test.dart
  • pkg/frontend_server/test/src/javascript_bundle_test.dart
  • pkg/frontend_server/test/src/strong_components_test.dart

See https://github.com/dart-lang/sdk/issues/49169 for more context.

jakemac53 avatar Jun 08 '22 17:06 jakemac53

https://dart-review.googlesource.com/c/sdk/+/247601 migrates those that are not blocked by package:dev_compiler:

  • pkg/frontend_server/lib/compute_kernel.dart
  • pkg/frontend_server/lib/src/strong_components.dart
  • pkg/frontend_server/test/strong_components_test.dart

jakemac53 avatar Jun 08 '22 17:06 jakemac53

Rest is blocked on https://github.com/dart-lang/sdk/issues/46617

jakemac53 avatar Jun 08 '22 21:06 jakemac53

I finished the DDC migration and closed https://github.com/dart-lang/sdk/issues/46617. The frontend_server migration should be unblocked now.

nshahan avatar Jul 29 '22 22:07 nshahan

https://dart-review.googlesource.com/c/sdk/+/253301 Migrates all but one of the tests which relies heavily on mockito.

cc @srawlins would you possibly be able to take a look at the frontend_server_test.dart file and give some advice? I don't think we want to add build_runner as a dep to this package (and thus the sdk etc).

jakemac53 avatar Aug 01 '22 20:08 jakemac53

frontend_server_test.dart uses a fair amount of mockito API. 4 mock classes extend Mock:

_MockedBinaryPrinterFactory

This class is instantiated once, and one stub is created for the newBinaryPrinter. This class can probably just extend Fake instead of Mock, with an @override for newBinaryPrinter.

_MockedBinaryPrinter

This is an instantiated placeholder - no mockito API. Can be replaced with a Fake.

_MockedCompiler

Instantiated a few places, and the test uses when to stub behavior, and verify and verifyInOrder to verify calls. This is more core usage of mockito, and would require more work to replace, if we wanted to remove mockito. I'd rather not speculate, but I think the authors could look at each verify and verifyInOrder to see if it is important to verify these things. If it is, verify can more-or-less be replaced with overridden methods which store the given parameters in fields. verifyInOrder is definitely trickier. Again, I think looking at them case-by-case can lead to good tests w/o mockito.

_MockedIncrementalCompiler

This is instantiated in one test, with a few stubs, but they don't use any argument matchers. So this would be a pretty simple transition to a Fake with @overrides.

srawlins avatar Aug 01 '22 23:08 srawlins

FYI, it looks like this is in the critical path for migrating flutter/engine to sound null safety.

devoncarew avatar Sep 06 '22 19:09 devoncarew

looks like my CL for most of it (just not the tests) failed to submit and I didn't realize, I can pick that up today and try and get it landed.

jakemac53 avatar Sep 07 '22 14:09 jakemac53

hey @jakemac53 any news?

mit-mit avatar Sep 12 '22 18:09 mit-mit

Gah sorry, got sidetracked and forgot about it. Looking now.

jakemac53 avatar Sep 12 '22 20:09 jakemac53

Ok, I took a look but there have been a ton of upstream changes and merging them just really wasn't feasible.

Somebody will have to start from scratch on this one.

jakemac53 avatar Sep 12 '22 20:09 jakemac53

Generally, does the CFE team own this package or does the VM team? cc @johnniwinther and @a-siva. We'll want to find an owner to push this over the line from a conversion-to-null-safety perspective.

devoncarew avatar Sep 12 '22 20:09 devoncarew

It looks like the current null safety exclusions are:

bin/frontend_server_starter.dart:1:// @dart = 2.9
lib/frontend_server.dart:5:// @dart = 2.9
lib/src/javascript_bundle.dart:5:// @dart = 2.9
lib/src/resident_frontend_server.dart:5:// @dart = 2.9
lib/starter.dart:5:// @dart = 2.9
test/frontend_server_flutter.dart:5:// @dart = 2.9
test/frontend_server_flutter_suite.dart:5:// @dart = 2.9
test/frontend_server_test.dart:5:// @dart = 2.9
test/src/javascript_bundle_test.dart:5:// @dart = 2.9
test/src/resident_frontend_server_test.dart:5:// @dart = 2.9

(I didn't check to see if some of those are intended from the POV of testing pre-null safety)

devoncarew avatar Sep 12 '22 20:09 devoncarew

  • @jensjoha @annagrin For planning on who will tackle the migration.

nshahan avatar Sep 12 '22 20:09 nshahan

I'll look into migration the frontend server.

johnniwinther avatar Sep 12 '22 21:09 johnniwinther

One of the issues that I ran into with migrating the frontend server tests was the heavy use of mockito package, I am working on a CL to replace the use of mockito in these tests to make it possible to then migrate these files.

a-siva avatar Sep 13 '22 00:09 a-siva

The only file remaining is test/frontend_server_test.dart. @a-siva you are working on this, right?

johnniwinther avatar Sep 16 '22 11:09 johnniwinther

Yes

a-siva avatar Sep 16 '22 16:09 a-siva

Thanks for migrating the tests @jakemac53 !

mit-mit avatar Sep 19 '22 07:09 mit-mit

First step of removing mockito dependency from the tests is here https://dart-review.googlesource.com/c/sdk/+/260001/5

a-siva avatar Sep 20 '22 17:09 a-siva

Second step of making the file null safe https://dart-review.googlesource.com/c/sdk/+/260744

a-siva avatar Sep 22 '22 23:09 a-siva