Running flutter/dart tests in AOT/release or profile mode?
I have found a rather simple solution which is documented on the dart website. Starting with Dart 2.3 there is a dart2aot
and dartaotruntime
bundled with the SDK. This allows simple execution and I was able to reproduce my crash.
Herbys-MacBook-Pro-2017:migrate$ dart2aot migrate_aot_test.dart migrate_aot_test.dart.aot
Herbys-MacBook-Pro-2017:migrate$ dartaotruntime migrate_aot_test.dart.aot
[...]
===== CRASH =====
si_signo=Segmentation fault: 11(11), si_code=1, si_addr=0x1061000410f
Abort trap: 6
Herbys-MacBook-Pro-2017:migrate$
Herbert Poul
Checkout my personal website at https://codeux.design/ and my latest projects: AuthPass: Password Manager for mobile and desktop, based on flutter (Keepass/kdbx compatible) WorkTrail: easily tracking your work time . Anlage.App: keep track of stock portfolio MarketCap Game: iOS and Android Game to compare market caps of public companies
Updated on December 12, 2022Comments
-
Herbert Poul over 1 year
If I understand it correctly by default
flutter test
will run with a JIT on the Dart VM, while the release mode uses an AOT compiler to native code. I (think to) have a crash which only happens in AOT mode (release and profile), and it would be way easier to debug and reproduce it when I could isolate it by running code in AOT/profile mode.So how can I run tests (or at least code snippets) in AOT mode? (I don't really care if it runs on an actual iOS or Android device, or is executed on the dev machine or simulators.
(I have found an article which seems to describe the compilation process, but is pretty involved. Is there some easier way for tests?)
-
Rémi Rousselet almost 5 yearsInstead of
flutter test
you may wantflutter drive
-
Herbert Poul almost 5 yearsI'd rather run individual unit tests, than integration tests, also are you sure that
flutter drive
would use AOT compiled code to run? -
Rémi Rousselet almost 5 yearsYes, there's an option on
flutter drive
for that:--profile
-
-
Vyacheslav Egorov almost 5 yearsPlease report a bug at dartbug.com with a reproduction. We will take a look. Thanks!
-
Herbert Poul almost 5 years@VyacheslavEgorov thanks, actually just did that :-) github.com/dart-lang/sdk/issues/37656