-
Notifications
You must be signed in to change notification settings - Fork 2.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
[go_router] Don't log if hierarchicalLoggingEnabled
is true
#6019
[go_router] Don't log if hierarchicalLoggingEnabled
is true
#6019
Conversation
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact "@test-exemption-reviewer" in the #hackers channel in Chat (don't just cc them here, they won't see it! Use Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
I would like to ask for some help with the tests here. Here is the packages/packages/go_router/lib/src/logging.dart Lines 27 to 62 in 5b48c44
My idea was to write 2 tests (both with
I first wrote this test: testWidgets(
'It should log the known routes and the initial route if debugLogDiagnostics is false',
(WidgetTester tester) async {
final _FakeStdout stdout = _FakeStdout();
IOOverrides.runZoned(
() {
final List<String> logs = <String>[];
Logger.root.onRecord.listen(
(LogRecord event) => logs.add(event.message),
);
GoRouter(
debugLogDiagnostics: true,
routes: <RouteBase>[
GoRoute(
path: '/',
builder: (_, GoRouterState state) => const Text('home'),
),
],
);
expect(
logs,
const <String>[
'Full paths for routes:\n => /\n',
'setting initial location null'
],
);
expect(stdout.writtenObjects, isNotEmpty);
},
stdout: () => stdout,
);
},
); But Do you have any suggestion? |
…-if-hierarchical-logging-enabled-is-true # Conflicts: # packages/go_router/CHANGELOG.md # packages/go_router/pubspec.yaml
…enabled-is-true # Conflicts: # packages/go_router/CHANGELOG.md
@chunhtai Any idea how I can write a test for that? |
Hello @chunhtai, do you have any thoughts on this? |
df6f51d
to
998a25e
Compare
…-if-hierarchical-logging-enabled-is-true # Conflicts: # packages/go_router/CHANGELOG.md
Hello @chunhtai @johnpryan @hangyujin , do you have any idea/feedback for the tests? |
I think you have to get someone on discord for the review |
@cedvdb Would you know which channel I should use ? I tried hackers-routing-🛤️ , but no one answered |
@ValentinVignal I will take a look at this PR, also @chunhtai will be back in a week |
/// Called when this route is removed from GoRouter's route history. | ||
/// | ||
/// Corresponds to [GoRoute.onExit]. | ||
FutureOr<bool> onExit(BuildContext context) => true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this from other patch? we should probably separate this out
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops yeah, that's a mistake. I reverted it
@@ -72,6 +72,8 @@ class GoRouterDelegate extends RouterDelegate<RouteMatchList> | |||
// This should be the only place where the last GoRoute exit the screen. | |||
final GoRoute lastRoute = currentConfiguration.last.route; | |||
if (lastRoute.onExit != null && navigatorKey.currentContext != null) { | |||
walker.buildState(_configuration, _configuration.); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems unrelated?
…-if-hierarchical-logging-enabled-is-true # Conflicts: # packages/go_router/CHANGELOG.md
…-if-hierarchical-logging-enabled-is-true # Conflicts: # packages/go_router/CHANGELOG.md
…-if-hierarchical-logging-enabled-is-true
@chunhtai I refactored |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Hi @ValentinVignal, can you bump version? |
…-if-hierarchical-logging-enabled-is-true # Conflicts: # packages/go_router/CHANGELOG.md # packages/go_router/pubspec.yaml
@ValentinVignal looks like the ci is still not happy |
…-if-hierarchical-logging-enabled-is-true # Conflicts: # packages/go_router/CHANGELOG.md
@chunhtai It should be good now |
flutter/packages@87a7c51...cc47b06 2024-04-30 joonas.kerttula@codemate.com [google_maps_flutter_web] Add marker clustering support (flutter/packages#6187) 2024-04-30 joonas.kerttula@codemate.com [google_maps_flutter_android] Add marker clustering support (flutter/packages#6185) 2024-04-29 32538273+ValentinVignal@users.noreply.github.com [go_router] Don't log if `hierarchicalLoggingEnabled` is `true` (flutter/packages#6019) 2024-04-29 43054281+camsim99@users.noreply.github.com [file_selector_android] Update `LICENSE` file to include newly added licensed code (flutter/packages#6626) 2024-04-29 43054281+camsim99@users.noreply.github.com [file_selector_android] Modifies `getDirectoryPath`, `openFile`, `openFiles` to return file/directory paths instead of URIs (flutter/packages#6438) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC flutter-ecosystem@google.com,rmistry@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…ter#6019) Fixes flutter/flutter#139667 *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
…ter#6019) Fixes flutter/flutter#139667 *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
Fixes flutter/flutter#139667
If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.
Pre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style.///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.