Skip to content

AF-2971 Dart 2 compatibility #137

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

Merged
merged 7 commits into from
Nov 8, 2018
Merged

AF-2971 Dart 2 compatibility #137

merged 7 commits into from
Nov 8, 2018

Conversation

robbecker-wf
Copy link
Member

@robbecker-wf robbecker-wf commented Oct 24, 2018

Overview

Updates are needed to use this library under Dart 2

Changes

  • updated analysis options and renamed to the proper name
  • updated dependencies and dart sdk ranges in pubspec.yaml
  • unit tests fixed for dart 2.
  • fixed some type errors in the examples
  • CI now enforces dartfmt under dart 2

Testing

  • CI passes under dart 1 and dart 2

@robbecker-wf robbecker-wf requested a review from a team as a code owner October 24, 2018 03:28
@robbecker-wf robbecker-wf requested a review from a team October 24, 2018 03:28
@aviary3-wk
Copy link

Security Insights

No security relevant content was detected by automated scans.

Action Items

  • Review PR for security impact; comment "security review required" if needed or unsure
  • Verify aviary.yaml coverage of security relevant code

Questions or Comments? Reach out on HipChat: InfoSec Forum.

- adjust a type error
- work around sync-async issues
- shorten dockerfile run since everything happens in Travis CI
@@ -32,8 +32,7 @@ class SampleSpan implements Span {
this.references,
DateTime startTime,
Map<String, dynamic> tags,
})
: this.startTime = startTime ?? new DateTime.now(),
}) : this.startTime = startTime ?? new DateTime.now(),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dart 2 formatter change

@@ -594,7 +594,7 @@ abstract class LifecycleModule extends SimpleModule with Disposable {
]);
}

Future pendingTransition;
Future<Null> pendingTransition;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to match the type signature of _suspend

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is internal and not a public api change

@@ -661,7 +661,7 @@ abstract class LifecycleModule extends SimpleModule with Disposable {
allowedStates: [LifecycleState.suspended, LifecycleState.suspending]);
}

Future pendingTransition;
Future<Null> pendingTransition;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to match the type signature of _resume

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also internal only. no public api change.

@@ -280,6 +282,8 @@ void expectInLifecycleState(LifecycleModule module, LifecycleState state) {
}

Future<Null> gotoState(LifecycleModule module, LifecycleState state) async {
// wait for next event loop. fixes sync-async in Dart 2
await new Future.value(null);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Workiva/app-frameworks want to take a look at these closely to determine if we're going to have a sync-async problem with lifecycle module or if it's just the tests and mocks?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, goto state is only used internally in tests, so I'm not too concerned about this one.

@codecov-io
Copy link

Codecov Report

Merging #137 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #137   +/-   ##
=======================================
  Coverage   96.82%   96.82%           
=======================================
  Files           4        4           
  Lines         346      346           
=======================================
  Hits          335      335           
  Misses         11       11
Impacted Files Coverage Δ
lib/src/lifecycle_module.dart 96.65% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3536c82...502dc3f. Read the comment docs.

@robbecker-wf robbecker-wf changed the title WIP dart 2 Dart 2 compatibility Oct 28, 2018
@rmconsole6-wk rmconsole6-wk changed the title Dart 2 compatibility AF-2971 WIP dart 2 Oct 28, 2018
@robbecker-wf robbecker-wf changed the title AF-2971 WIP dart 2 AF-2971 Dart 2 compatibility Oct 28, 2018
@@ -1,43 +1,6 @@
FROM google/dart:1.24.3 as build

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just let Travis CI run all the tests.

@@ -149,6 +149,7 @@ class TestLifecycleModule extends LifecycleModule {
@override
@protected
Future<Null> onWillUnloadChildModule(LifecycleModule module) async {
await new Future.value(null);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This spot is a little more concerning because this may mean that it's possible for other consumers that are overriding one of these lifecycle methods may get a change in how lifecycle events are ordered due to sync-async. I think we can go ahead with this PR as is, but be aware that there may be a recommended migration step of putting a line like this in each overriden module lifecycle method.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this await here .. the order that events are added to the tracking list of events is different than what the tests expect the order to be. This looks like:

00:05 +216 -1: [VM] test/lifecycle_module_test.dart: LifecycleModule with globalTracer with children unload should wait for in-progress child module loads  [E]
  Expected: [
              'onWillLoadChildModule',
              'willLoadChildModule',
              'onShouldUnload',
              'willUnload',
              'onDidLoadChildModule',
              'didLoadChildModule',
              'onWillUnloadChildModule',
              'willUnloadChildModule',
              'onDidUnloadChildModule',
              'didUnloadChildModule',
              'onUnload',
              'didUnload',
              'onDispose'
            ]
    Actual: [
              'onWillLoadChildModule',
              'willLoadChildModule',
              'onShouldUnload',
              'willUnload',
              'onDidLoadChildModule',
              'onWillUnloadChildModule',
              'didLoadChildModule',
              'willUnloadChildModule',
              'onDidUnloadChildModule',
              'didUnloadChildModule',
              'onUnload',
              'didUnload',
              'onDispose'
            ]
     Which: was 'onWillUnloadChildModule' instead of 'didLoadChildModule' at location [5]

  package:test                             expect
  test/lifecycle_module_test.dart 2236:11  runTests.<fn>.<fn>.<fn>.<fn>

@evanweible-wf
Copy link
Contributor

QA +1

  • CI passes on Dart 1 and Dart 2

@Workiva/release-management-p

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

Successfully merging this pull request may close these issues.

8 participants