简体   繁体   中英

Running flutter/dart tests in AOT/release or profile mode?

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?)

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$

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM