[test.py] Fix race condition when copying files
[test.py] Fix race condition when copying files

When testing multitests needed files are copied, but some files are
copied multiple times, creating race conditions that might cause tests
to fail because incomplete files are read.

For instance running
"python tools/test.py -m release -c dartk --strong language_2"
is fine (i.e. everything passes), but running
"python tools/test.py -m release -c dartk --strong language_2/generic_constructor_mixin3_test"
can get 0, 1 or 2 errors depending on the computers mood...

This fixes the problem by introducing a map from copied-to-path to Future,
so the same Future is returned when asked to copy a file subsequent times,
thus avoiding the race condition.

Fixes #31368.

Bug:
Change-Id: Id7d4a12424085c75f3543bd06a617121ad5eff35
Reviewed-on: https://dart-review.googlesource.com/32282
Commit-Queue: Jens Johansen <05223a3c6bdf76af6f84755eae231abeebcf4530@google.com>
Reviewed-by: William Hesse <a821cddceae7dc400f272e3cb1a72f400f9fed6d@google.com>

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