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 @@ ...@@ -4,7 +4,6 @@
import 'dart:async' show FutureOr; import 'dart:async' show FutureOr;
import 'dart:io' as io show OSError, SocketException; import 'dart:io' as io show OSError, SocketException;
import 'dart:math' as math show Random;
import 'dart:typed_data' show Uint8List; import 'dart:typed_data' show Uint8List;
import 'package:file/file.dart'; import 'package:file/file.dart';
...@@ -131,17 +130,14 @@ abstract class FlutterGoldenFileComparator extends GoldenFileComparator { ...@@ -131,17 +130,14 @@ abstract class FlutterGoldenFileComparator extends GoldenFileComparator {
static Directory getBaseDirectory( static Directory getBaseDirectory(
LocalFileComparator defaultComparator, LocalFileComparator defaultComparator,
Platform platform, { Platform platform, {
String suffix = '', String? suffix,
bool local = false,
}) { }) {
const FileSystem fs = LocalFileSystem(); const FileSystem fs = LocalFileSystem();
final Directory flutterRoot = fs.directory(platform.environment[_kFlutterRootKey]); final Directory flutterRoot = fs.directory(platform.environment[_kFlutterRootKey]);
Directory comparisonRoot; Directory comparisonRoot;
if (!local) { if (suffix != null) {
comparisonRoot = fs.systemTempDirectory.childDirectory( comparisonRoot = fs.systemTempDirectory.createTempSync(suffix);
'skia_goldens_$suffix'
);
} else { } else {
comparisonRoot = flutterRoot.childDirectory( comparisonRoot = flutterRoot.childDirectory(
fs.path.join( fs.path.join(
...@@ -225,7 +221,7 @@ class FlutterPostSubmitFileComparator extends FlutterGoldenFileComparator { ...@@ -225,7 +221,7 @@ class FlutterPostSubmitFileComparator extends FlutterGoldenFileComparator {
final Directory baseDirectory = FlutterGoldenFileComparator.getBaseDirectory( final Directory baseDirectory = FlutterGoldenFileComparator.getBaseDirectory(
defaultComparator, defaultComparator,
platform, platform,
suffix: '${math.Random().nextInt(10000)}', suffix: 'flutter_goldens_postsubmit.',
); );
baseDirectory.createSync(recursive: true); baseDirectory.createSync(recursive: true);
...@@ -304,7 +300,7 @@ class FlutterPreSubmitFileComparator extends FlutterGoldenFileComparator { ...@@ -304,7 +300,7 @@ class FlutterPreSubmitFileComparator extends FlutterGoldenFileComparator {
final Directory baseDirectory = testBasedir ?? FlutterGoldenFileComparator.getBaseDirectory( final Directory baseDirectory = testBasedir ?? FlutterGoldenFileComparator.getBaseDirectory(
defaultComparator, defaultComparator,
platform, platform,
suffix: '${math.Random().nextInt(10000)}', suffix: 'flutter_goldens_presubmit.',
); );
if (!baseDirectory.existsSync()) if (!baseDirectory.existsSync())
...@@ -469,7 +465,6 @@ class FlutterLocalFileComparator extends FlutterGoldenFileComparator with LocalC ...@@ -469,7 +465,6 @@ class FlutterLocalFileComparator extends FlutterGoldenFileComparator with LocalC
baseDirectory ??= FlutterGoldenFileComparator.getBaseDirectory( baseDirectory ??= FlutterGoldenFileComparator.getBaseDirectory(
defaultComparator, defaultComparator,
platform, platform,
local: true,
); );
if(!baseDirectory.existsSync()) { if(!baseDirectory.existsSync()) {
......
...@@ -330,7 +330,6 @@ void main() { ...@@ -330,7 +330,6 @@ void main() {
final Directory basedir = FlutterGoldenFileComparator.getBaseDirectory( final Directory basedir = FlutterGoldenFileComparator.getBaseDirectory(
defaultComparator, defaultComparator,
platform, platform,
local: true,
); );
expect( expect(
basedir.uri, 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