MaikuB / flutter_local_notifications

A Flutter plugin for displaying local notifications on Android, iOS, macOS and Linux
2.47k stars 1.4k forks source link

[flutter_local_notifications_windows] use flutter test instead of dart test #2459

Closed MaikuB closed 3 days ago

MaikuB commented 3 days ago

Switched to flutter test to see if it helps improves output shown in the logs

Levi-Lesches commented 3 days ago

Weird:

flutter_local_notifications_windows:
Resolving dependencies...
Downloading packages...
  _fe_analyzer_shared 73.0.0 (76.0.0 available)
  analyzer 6.8.0 (6.11.0 available)
  ffigen 13.0.0 (15.0.0 available)
! flutter_local_notifications_platform_interface 8.1.0 from path ..\flutter_local_notifications_platform_interface (overridden in .\pubspec_overrides.yaml)
  macros 0.1.2-main.4 (0.1.3-main.0 available)
  matcher 0.12.16+1 (0.12.[17](https://github.com/MaikuB/flutter_local_notifications/actions/runs/11814739691/job/32914415296?pr=2459#step:6:18) available)
  timezone 0.9.4 (0.10.0 available)
Got dependencies!
6 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.

✅ d:/a/flutter_local_notifications/flutter_local_notifications/flutter_local_notifications_windows/test/details_test.dart: Details: No details
✅ d:/a/flutter_local_notifications/flutter_local_notifications/flutter_local_notifications_windows/test/bindings_test.dart: Bindings work in simple cases
✅ d:/a/flutter_local_notifications/flutter_local_notifications/flutter_local_notifications_windows/test/bindings_test.dart: Bindings fail when ID is not found in simple cases
✅ d:/a/flutter_local_notifications/flutter_local_notifications/flutter_local_notifications_windows/test/bindings_test.dart: Bindings are included in show()
✅ d:/a/flutter_local_notifications/flutter_local_notifications/flutter_local_notifications_windows/test/details_test.dart: Details: Simple details
✅ d:/a/flutter_local_notifications/flutter_local_notifications/flutter_local_notifications_windows/test/details_test.dart: Details: Actions
✅ d:/a/flutter_local_notifications/flutter_local_notifications/flutter_local_notifications_windows/test/details_test.dart: Details: Audio
✅ d:/a/flutter_local_notifications/flutter_local_notifications/flutter_local_notifications_windows/test/bindings_test.dart: Bindings fail when notification has been cancelled
✅ d:/a/flutter_local_notifications/flutter_local_notifications/flutter_local_notifications_windows/test/plugin_test.dart: Plugin initializes safely
✅ d:/a/flutter_local_notifications/flutter_local_notifications/flutter_local_notifications_windows/test/plugin_test.dart: Plugin catches bad GUIDs
✅ d:/a/flutter_local_notifications/flutter_local_notifications/flutter_local_notifications_windows/test/plugin_test.dart: Plugin cannot be used before initializing
✅ d:/a/flutter_local_notifications/flutter_local_notifications/flutter_local_notifications_windows/test/plugin_test.dart: Plugin cannot be used after disposed
✅ d:/a/flutter_local_notifications/flutter_local_notifications/flutter_local_notifications_windows/test/plugin_test.dart: Plugin does not support repeating notifications
✅ d:/a/flutter_local_notifications/flutter_local_notifications/flutter_local_notifications_windows/test/scheduled_test.dart: Schedules work with basic times
✅ d:/a/flutter_local_notifications/flutter_local_notifications/flutter_local_notifications_windows/test/details_test.dart: Details: Rows
✅ d:/a/flutter_local_notifications/flutter_local_notifications/flutter_local_notifications_windows/test/details_test.dart: Details: Header
✅ d:/a/flutter_local_notifications/flutter_local_notifications/flutter_local_notifications_windows/test/details_test.dart: Details: Images
✅ d:/a/flutter_local_notifications/flutter_local_notifications/flutter_local_notifications_windows/test/details_test.dart: Details: Inputs
✅ d:/a/flutter_local_notifications/flutter_local_notifications/flutter_local_notifications_windows/test/details_test.dart: Details: Progress
✅ d:/a/flutter_local_notifications/flutter_local_notifications/flutter_local_notifications_windows/test/scheduled_test.dart: Schedules do not work with earlier time
✅ d:/a/flutter_local_notifications/flutter_local_notifications/flutter_local_notifications_windows/test/xml_test.dart: XML catches invalid XML

🎉 15 tests passed.
--------------------------------------------------------------------------------

$ melos exec
  └> flutter test
     └> FAILED (in 1 packages)
        └> flutter_local_notifications_windows (with exit code 1)

melos run test:unit:windows
  └> melos exec -c 1 -- "flutter test"
     └> FAILED
ScriptException: The script test:unit:windows failed to execute.
MaikuB commented 3 days ago

Yeah I noticed. Not sure what is going on there. I recall having a similar problem but don't remember the solution. I think it had to do with the folder/scope that melos was able to run in. If you have ideas then let me know

Levi-Lesches commented 3 days ago

Nope, don't know what's going on here 🤷‍♂️

MaikuB commented 3 days ago

I'm going to abandon this PR for now as I don't have time to see what's going on. Verbose logs seemingly indicate the error is thrown by the Flutter tooling. I haven't been able to reproduce this as I'm having trouble as I'm trouble running the tests locally now. I did take the old DLL you had and used it on my local machine but that worked. Potentially this is to do with having Windows ARM when I run build.bat on my machine. The number of tests being run also looks off when run via GitHub as it should be 21 tests

Levi-Lesches commented 3 days ago

Yeah, I had a lot of issues as well. The tests are inherently flaky due to flutter insisting on multithreading them, whereas the underlying Windows API is inherently not thread-safe. I attempt to explain / debug a bit in bin/crash.dart and solve it with enableMultithreading(), but that didn't fix it 100%. When I had the issues, the test harness would segfault midway through the tests at random lines (even lines that just declare and don't even assign a variable). It's also why the tests all have a few retry attempts, it's to let a few tests fail, and then after the rest have finished, they get their own time to re-run.

Here's something more concrete though -- when I run these locally:

dart test --reporter compact  # rewrites a single line to show progress, works 21/21
dart test --reporter expanded  # each test on its own line, suddenly exits after 12 
dart test --reporter github  # the GitHub Actions text, suddenly exits after 12

These results aren't stable, and sometimes they do all work, but it's interesting that I was able to briefly recreate this problem locally. I'd say it's not worth fixing, and to let the exit code determine whether GitHub goes green or not