[Test] Fixes flakiness in spawn_function_test caused by racing.
[Test] Fixes flakiness in spawn_function_test caused by racing.

Previously the test would create and run an isolate, then checking the debugName of the isolate.
However, if the isolate ran to completion and got collected before the check happened, the debugName would be null, causing the test to fail.

The test was running at about 1.5% flakiness when run locally before.
With the change no flakiness was observed across several couple hundred runs.

Tested:
    tools/test.py -n dartk-optcounter-linux-release-x64 \
        lib_2/isolate/spawn_function_test --repeat=1000
Change-Id: I0aea6bbae08fbe321e1bea7301655ad06ec3dcd2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/108410
Reviewed-by: Ben Konyi <67ffcaedcc3dc3d87dddb9627b72dd41756b31b1@google.com>
Reviewed-by: Martin Kustermann <a35dd5b79fac84b2bb3b026a16b8becc55af5961@google.com>
Commit-Queue: Clement Skau <495593248b6158163719b90dde8357b589c8e5d0@google.com>

dartino/dart-sdk,dart-archive/dart-sdk,dart-lang/sdk,dartino/dart-sdk,dart-archive/dart-sdk,dartino/dart-sdk,dartino/dart-sdk,dart-archive/dart-sdk,dart-lang/sdk,dart-archive/dart-sdk,dartino/dart-sdk,dartino/dart-sdk,dart-lang/sdk,dart-archive/dart-sdk,dart-lang/sdk,dart-archive/dart-sdk,dartino/dart-sdk,dart-archive/dart-sdk,dart-archive/dart-sdk,dartino/dart-sdk,dart-lang/sdk,dart-archive/dart-sdk,dart-lang/sdk,dartino/dart-sdk,dart-lang/sdk,dart-lang/sdk