Automatically select main isolate instead of the test runner isolate when connecting to test runs
- Lingua principale
- Dart
- Stelle
- 1.7k
- Fork
- 404
- Merge medio
- 6g 17h
- PR unite (30g)
- 18
Descrizione
I don't know if this is a DevTools issue or something else, but I'm also not sure how to determine which.
When running tests, CPU profiling never seems to collect any data. For example given a sample project with a `bin/main.dart` that calls a function in `lib` that blocks for 5s, and a test that does the same:
## bin/main.dart
```dart
import 'package:cpu_profile/cpu_profile.dart' as cpu_profile;
void main(List arguments) {
print('starting'); // breakpoint
cpu_profile.calculate();
print('done!'); // breakpoint
}
```
## lib/cpu_profile.dart
```dart
int calculate() {
var start = DateTime.now();
while (start.difference(DateTime.now()).inSeconds.abs() < 5) {}
return 6 * 7;
}
```
## test/cpu_profile_test.dart
```dart
import 'package:cpu_profile/cpu_profile.dart' as cpu_profile;
import 'package:test/test.dart';
void main() {
test('calculate', () {
print('starting'); // breakpoint
cpu_profile.calculate();
print('done!'); // breakpoint
});
}
```
For `bin/main.dart`:
- Open `bin/main.dart`
- Add breakpoints on the marked lines
- Run in debug mode and hit the first breakpoint
- Open DevTools CPU profile, enable profiling, and start recording
- Resume execution and wait for it to hit the second breakpoint
- Stop CPU profiling and observe the results
Perform the same steps but using the test instead, and the profiler doesn't show any data:
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Riproduci il problema con bin/main.dart e test/cpu_profile_test.dart, seguendo i passaggi per i breakpoint e il profiling della CPU descritti nel report. Inizia tracciando il modo in cui DevTools si connette a un'esecuzione di test e seleziona un isolate; il lavoro è completato quando il profiling dell'esecuzione di test acquisisce il lavoro in cpu_profile.calculate() e mostra dati come il programma standalone.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- dart
- Ambito
- devtools, performance, testing
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Tranquilla
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 48/100