[flutter_tools] temporary directory (#105815)
This commit is contained in:
@@ -7,6 +7,7 @@ import 'dart:io' as io;
|
||||
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:file_testing/file_testing.dart';
|
||||
import 'package:flutter_tools/src/base/common.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
@@ -15,6 +16,13 @@ import 'package:test/fake.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
|
||||
class LocalFileSystemFake extends LocalFileSystem {
|
||||
LocalFileSystemFake.test({required super.signals}) : super.test();
|
||||
|
||||
@override
|
||||
Directory get superSystemTempDirectory => directory('/does_not_exist');
|
||||
}
|
||||
|
||||
void main() {
|
||||
group('fsUtils', () {
|
||||
late MemoryFileSystem fs;
|
||||
@@ -174,6 +182,23 @@ void main() {
|
||||
|
||||
expect(temp.existsSync(), isFalse);
|
||||
});
|
||||
|
||||
testWithoutContext('throwToolExit when temp not found', () async {
|
||||
final Signals signals = Signals.test();
|
||||
final LocalFileSystemFake localFileSystem = LocalFileSystemFake.test(
|
||||
signals: signals,
|
||||
);
|
||||
|
||||
try {
|
||||
localFileSystem.systemTempDirectory;
|
||||
fail('expected tool exit');
|
||||
} on ToolExit catch(e) {
|
||||
expect(e.message, 'Your system temp directory (/does_not_exist) does not exist. '
|
||||
'Did you set an invalid override in your environment? '
|
||||
'See issue https://github.com/flutter/flutter/issues/74042 for more context.'
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user