Unverified Commit 4b65c058 authored by Kate Lovett's avatar Kate Lovett Committed by GitHub

Reduce potential collisions from Gold RNG (#81792)

parent 3101374f
......@@ -4,7 +4,6 @@
import 'dart:async' show FutureOr;
import 'dart:io' as io show OSError, SocketException;
import 'dart:math' as math show Random;
import 'dart:typed_data' show Uint8List;
import 'package:file/file.dart';
......@@ -131,17 +130,14 @@ abstract class FlutterGoldenFileComparator extends GoldenFileComparator {
static Directory getBaseDirectory(
LocalFileComparator defaultComparator,
Platform platform, {
String suffix = '',
bool local = false,
String? suffix,
}) {
const FileSystem fs = LocalFileSystem();
final Directory flutterRoot = fs.directory(platform.environment[_kFlutterRootKey]);
Directory comparisonRoot;
if (!local) {
comparisonRoot = fs.systemTempDirectory.childDirectory(
'skia_goldens_$suffix'
);
if (suffix != null) {
comparisonRoot = fs.systemTempDirectory.createTempSync(suffix);
} else {
comparisonRoot = flutterRoot.childDirectory(
fs.path.join(
......@@ -225,7 +221,7 @@ class FlutterPostSubmitFileComparator extends FlutterGoldenFileComparator {
final Directory baseDirectory = FlutterGoldenFileComparator.getBaseDirectory(
defaultComparator,
platform,
suffix: '${math.Random().nextInt(10000)}',
suffix: 'flutter_goldens_postsubmit.',
);
baseDirectory.createSync(recursive: true);
......@@ -304,7 +300,7 @@ class FlutterPreSubmitFileComparator extends FlutterGoldenFileComparator {
final Directory baseDirectory = testBasedir ?? FlutterGoldenFileComparator.getBaseDirectory(
defaultComparator,
platform,
suffix: '${math.Random().nextInt(10000)}',
suffix: 'flutter_goldens_presubmit.',
);
if (!baseDirectory.existsSync())
......@@ -469,7 +465,6 @@ class FlutterLocalFileComparator extends FlutterGoldenFileComparator with LocalC
baseDirectory ??= FlutterGoldenFileComparator.getBaseDirectory(
defaultComparator,
platform,
local: true,
);
if(!baseDirectory.existsSync()) {
......
......@@ -330,7 +330,6 @@ void main() {
final Directory basedir = FlutterGoldenFileComparator.getBaseDirectory(
defaultComparator,
platform,
local: true,
);
expect(
basedir.uri,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment