Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pkgs/code_assets/test/code_assets/config_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ void main() async {
late Uri fakeVcVars;

setUp(() async {
final tempUri = Directory.systemTemp.uri;
final tempUri =
(await Directory.systemTemp.createTemp('code assets config temp '))
.uri;
outFile = tempUri.resolve('output.json');
outputDirectoryShared = tempUri.resolve('out_shared1/');
packageName = 'my_package';
Expand Down
3 changes: 2 additions & 1 deletion pkgs/code_assets/test/code_assets/validation_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ void main() {
late Uri packageRootUri;

setUp(() async {
tempUri = (await Directory.systemTemp.createTemp()).uri;
tempUri =
(await Directory.systemTemp.createTemp('code assets temp ')).uri;
outDirUri = tempUri.resolve('out/');
await Directory.fromUri(outDirUri).create();
outDirSharedUri = tempUri.resolve('out_shared/');
Expand Down
3 changes: 2 additions & 1 deletion pkgs/data_assets/test/data_assets/validation_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ void main() {
late Uri packageRootUri;

setUp(() async {
tempUri = (await Directory.systemTemp.createTemp()).uri;
tempUri =
(await Directory.systemTemp.createTemp('data assets temp ')).uri;
outDirUri = tempUri.resolve('out/');
await Directory.fromUri(outDirUri).create();
outDirSharedUri = tempUri.resolve('out_shared/');
Expand Down
2 changes: 1 addition & 1 deletion pkgs/ffigen/test/test_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ String configPath(String directory, String file) =>
absPath(configPathForTest(directory, file));

/// Returns the temp directory used to store bindings generated by tests.
String tmpDir = path.join(packagePathForTests, 'test', '.temp');
String tmpDir = path.join(packagePathForTests, 'test', '.temp with spaces');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's already a PR in progress for the ffigen part of this: https://github.com/dart-lang/native/pull/3029/changes. This is not the only place in ffigen that creates temporary directories, so that PR has ended up being quite complicated.

How sure are you that you've found all the temp directory locations? Don't restrict your search to test directories.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the pointer, I’ll take a look at #3029 and avoid overlapping changes to ffigen there...

also do a broader search across the repo for all temp directory usages and update this PR to cover any I’ve missed.

Pardon me for late reply...
Will update as soon as possible for me...

Thank you...


/// Generates actual file using library and tests using [expect] with expected.
///
Expand Down
2 changes: 1 addition & 1 deletion pkgs/hooks/lib/src/test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Future<void> testBuildHook({
linkingEnabled ??= false;
const keepTempKey = 'KEEP_TEMPORARY_DIRECTORIES';

final tempDir = await Directory.systemTemp.createTemp();
final tempDir = await Directory.systemTemp.createTemp('hooks test ');

try {
// Deal with Windows temp folder aliases.
Expand Down
3 changes: 2 additions & 1 deletion pkgs/hooks/test/api/build_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ void main() async {
late BuildInput input;

setUp(() async {
tempUri = (await Directory.systemTemp.createTemp()).uri;
tempUri = (await Directory.systemTemp.createTemp('hooks api temp '))
.uri;
outFile = tempUri.resolve('output.json');
outDirUri = tempUri.resolve('out1/');
await Directory.fromUri(outDirUri).create();
Expand Down
4 changes: 3 additions & 1 deletion pkgs/hooks/test/build_input_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ void main() async {
late Map<String, Object?> inputJson;

setUp(() async {
final tempUri = Directory.systemTemp.uri;
final tempUri =
(await Directory.systemTemp.createTemp('hooks build_input temp '))
.uri;
outFile = tempUri.resolve('output.json');
outDirUri = tempUri.resolve('out1/');
outputDirectoryShared = tempUri.resolve('out_shared1/');
Expand Down
3 changes: 2 additions & 1 deletion pkgs/hooks/test/example/native_add_library_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ void main() async {
const name = 'native_add_library';

setUp(() async {
tempUri = (await Directory.systemTemp.createTemp()).uri;
tempUri = (await Directory.systemTemp.createTemp('hooks example temp '))
.uri;
});

tearDown(() async {
Expand Down
3 changes: 2 additions & 1 deletion pkgs/hooks/test/example/native_dynamic_linking_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ void main() async {
const name = 'native_dynamic_linking';

setUp(() async {
tempUri = (await Directory.systemTemp.createTemp()).uri;
tempUri = (await Directory.systemTemp.createTemp('hooks example temp '))
.uri;
});

tearDown(() async {
Expand Down
5 changes: 4 additions & 1 deletion pkgs/hooks/test/helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ Future<void> inTempDir(
String? prefix,
bool keepTemp = false,
}) async {
final tempDir = await Directory.systemTemp.createTemp(prefix);
final basePrefix = prefix ?? 'hooks_test';
final effectivePrefix =
basePrefix.contains(' ') ? basePrefix : '$basePrefix with spaces ';
final tempDir = await Directory.systemTemp.createTemp(effectivePrefix);
// Deal with Windows temp folder aliases.
final tempUri = Directory(
await tempDir.resolveSymbolicLinks(),
Expand Down
4 changes: 3 additions & 1 deletion pkgs/hooks/test/link_input_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ void main() async {
late Map<String, Object?> inputJson;

setUp(() async {
final tempUri = Directory.systemTemp.uri;
final tempUri =
(await Directory.systemTemp.createTemp('hooks link_input temp '))
.uri;
outFile = tempUri.resolve('output.json');
outDirUri = tempUri.resolve('out1/');
outputDirectoryShared = tempUri.resolve('out_shared1/');
Expand Down
3 changes: 2 additions & 1 deletion pkgs/hooks/test/validation_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ void main() {
late Uri packageRootUri;

setUp(() async {
tempUri = (await Directory.systemTemp.createTemp()).uri;
tempUri = (await Directory.systemTemp.createTemp('hooks test temp '))
.uri;
outDirUri = tempUri.resolve('out/');
await Directory.fromUri(outDirUri).create();
outDirSharedUri = tempUri.resolve('out_shared/');
Expand Down
10 changes: 8 additions & 2 deletions pkgs/hooks_runner/test/helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ Future<void> inTempDir(
String? prefix,
bool keepTemp = false,
}) async {
final tempDir = await Directory.systemTemp.createTemp(prefix);
final basePrefix = prefix ?? 'hooks_runner_test';
final effectivePrefix =
basePrefix.contains(' ') ? basePrefix : '$basePrefix with spaces ';
final tempDir = await Directory.systemTemp.createTemp(effectivePrefix);
// Deal with Windows temp folder aliases.
final tempUri = Directory(
await tempDir.resolveSymbolicLinks(),
Expand All @@ -58,7 +61,10 @@ Future<void> inTempDir(
}

Future<Uri> tempDirForTest({String? prefix, bool keepTemp = false}) async {
final tempDir = await Directory.systemTemp.createTemp(prefix);
final basePrefix = prefix ?? 'hooks_runner_test';
final effectivePrefix =
basePrefix.contains(' ') ? basePrefix : '$basePrefix with spaces ';
final tempDir = await Directory.systemTemp.createTemp(effectivePrefix);
// Deal with Windows temp folder aliases.
final tempUri = Directory(
await tempDir.resolveSymbolicLinks(),
Expand Down
3 changes: 2 additions & 1 deletion pkgs/jni/bin/setup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@ void main(List<String> arguments) async {
final jniDirUri = Uri.directory('.dart_tool').resolve('jni');
final jniDir = Directory.fromUri(jniDirUri);
await jniDir.create(recursive: true);
final tempDir = await jniDir.createTemp('jni_native_build_');
final tempDir =
await jniDir.createTemp('jni native build ');
final cmakeArgs = <String>[];
cmakeArgs.addAll(options.cmakeArgs);

Expand Down
3 changes: 2 additions & 1 deletion pkgs/jni/tool/generate_ide_files.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ void main(List<String> arguments) {
return;
}
final generator = cmakeGeneratorNames[argResults['generator']];
final tempDir = Directory.current.createTempSync('clangd_setup_temp_');
final tempDir =
Directory.current.createTempSync('clangd setup temp ');
final src = Directory.current.uri.resolve('src/');
try {
runCommand(
Expand Down
2 changes: 1 addition & 1 deletion pkgs/jnigen/lib/src/tools/gradle_tools.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class GradleTools {
deps,
targetPath,
);
final tempDir = await currentDir.createTemp('maven_temp_');
final tempDir = await currentDir.createTemp('maven temp ');
await createStubProject(tempDir);
final tempGradle = join(tempDir.path, 'temp_build.gradle.kts');
log.finer('using Gradle stub:\n$gradle');
Expand Down
3 changes: 2 additions & 1 deletion pkgs/jnigen/test/generation_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import 'package:test/test.dart';

void main() {
test('Warn if non-jnigen-generated files exist in directory', () async {
final root = await Directory.current.createTemp();
final root =
await Directory.current.createTemp('jnigen generation test ');
final nonGenerated =
await File.fromUri(root.uri.resolve('non_gen.dart')).create();
await nonGenerated.writeAsString('void main() {}');
Expand Down
4 changes: 3 additions & 1 deletion pkgs/jnigen/test/test_util/bindings_test_setup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ Future<void> bindingsTestSetup() async {
'jni:setup',
]);
tempClassDir =
Directory.current.createTempSync('jnigen_runtime_test_classpath_');
Directory.current.createTempSync(
'jnigen_runtime_test_classpath with spaces ',
);
await compileJavaFiles(Directory(simplePackageTestJava), tempClassDir);
await runCommand('dart', [
'run',
Expand Down
11 changes: 8 additions & 3 deletions pkgs/jnigen/test/test_util/test_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ const largeTestTag = 'large_test';
const summarizerTestTag = 'summarizer_test';

Directory getTempDir(String prefix) {
return _currentDirectory.createTempSync(prefix);
final basePrefix = prefix.isEmpty ? 'jnigen_test_temp' : prefix;
final effectivePrefix =
basePrefix.contains(' ') ? basePrefix : '$basePrefix with spaces ';
return _currentDirectory.createTempSync(effectivePrefix);
}

Future<bool> isEmptyOrNotExistDir(String path) async {
Expand Down Expand Up @@ -117,7 +120,8 @@ Future<void> generateAndCompareBindings(Config config) async {
final dartReferenceBindings =
config.outputConfig.dartConfig.path.toFilePath();
final currentDir = Directory.current;
final tempDir = currentDir.createTempSync('jnigen_test_temp');
final tempDir =
currentDir.createTempSync('jnigen_test_temp with spaces ');
final singleFile =
config.outputConfig.dartConfig.structure == OutputStructure.singleFile;
final tempLib = singleFile
Expand All @@ -133,7 +137,8 @@ Future<void> generateAndCompareBindings(Config config) async {

Future<void> generateAndAnalyzeBindings(Config config,
{Iterable<String> confirmExists = const []}) async {
final tempDir = Directory.current.createTempSync('jnigen_test_temp');
final tempDir =
Directory.current.createTempSync('jnigen_test_temp with spaces ');
try {
await _generateTempBindings(config, tempDir);
final analyzeResult = Process.runSync('dart', ['analyze', tempDir.path]);
Expand Down
3 changes: 2 additions & 1 deletion pkgs/native_doc_dartifier/lib/src/code_processor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ class CodeProcessor {
final String _dartifiedCodeFileName = 'dartified_code.dart';
final String _helperCodeFileName = 'helper_code.dart';

CodeProcessor() : _tempDir = Directory('${Directory.current.path}/temp') {
CodeProcessor()
: _tempDir = Directory('${Directory.current.path}/temp dir') {
if (!_tempDir.existsSync()) {
_tempDir.createSync(recursive: true);
}
Expand Down
5 changes: 4 additions & 1 deletion pkgs/native_toolchain_c/test/helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ String testSuffix(List<Object> tags) => switch (tags) {
const keepTempKey = 'KEEP_TEMPORARY_DIRECTORIES';

Future<Uri> tempDirForTest({String? prefix, bool keepTemp = false}) async {
final tempDir = await Directory.systemTemp.createTemp(prefix);
final basePrefix = prefix ?? 'native_toolchain_c_test';
final effectivePrefix =
basePrefix.contains(' ') ? basePrefix : '$basePrefix with spaces ';
final tempDir = await Directory.systemTemp.createTemp(effectivePrefix);
// Deal with Windows temp folder aliases.
final tempUri = Directory(
await tempDir.resolveSymbolicLinks(),
Expand Down
2 changes: 1 addition & 1 deletion pkgs/objective_c/test/hook_build_path_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void main() {
'build hook decodes percent-encoded package root paths',
() async {
final tempDir = await Directory.systemTemp.createTemp(
'objective_c_hook_path',
'objective_c_hook path',
);
addTearDown(() => tempDir.delete(recursive: true));

Expand Down
2 changes: 1 addition & 1 deletion pkgs/swift2objc/lib/src/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:path/path.dart' as path;

import 'ast/_core/interfaces/declaration.dart';

const defaultTempDirPrefix = 'swift2objc_temp_';
const defaultTempDirPrefix = 'swift2objc temp_';
const symbolgraphFileSuffix = '.symbols.json';

class Command {
Expand Down
2 changes: 1 addition & 1 deletion pkgs/swift2objc/test/integration/integration_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void main([List<String>? args]) {
const outputSuffix = '_output.swift';

final thisDir = path.join(testDir, 'integration');
final tempDir = path.join(thisDir, 'temp');
final tempDir = path.join(thisDir, 'temp dir');

var regen = false;
final testNames = <String>[];
Expand Down
2 changes: 1 addition & 1 deletion pkgs/swift2objc/test/unit/filter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void main([List<String>? args]) {

group('Unit test for filter', () {
final thisDir = p.join(testDir, 'unit');
final tempDir = p.join(thisDir, 'temp');
final tempDir = p.join(thisDir, 'temp dir');
final inputFile = p.join(thisDir, 'filter_test_input.swift');

void filterTest(
Expand Down
5 changes: 4 additions & 1 deletion pkgs/swift2objc/test/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ Future<void> expectValidSwift(List<String> files) async {
'-emit-symbol-graph-dir',
'.',
],
workingDirectory: Directory.systemTemp.createTempSync().absolute.path,
workingDirectory:
Directory.systemTemp.createTempSync('swift2objc swiftc temp ')
.absolute
.path,
);

if (processResult.exitCode != 0) {
Expand Down
2 changes: 1 addition & 1 deletion pkgs/swiftgen/example/generate_code.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Future<void> main() async {
),
),
),
).generate(logger: logger, tempDirectory: Uri.directory('temp'));
).generate(logger: logger, tempDirectory: Uri.directory('temp dir'));

final result = Process.runSync('swiftc', [
'-emit-library',
Expand Down
4 changes: 3 additions & 1 deletion pkgs/swiftgen/lib/src/util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ Future<void> run(
}

Uri createTempDirectory() =>
Uri.directory(Directory.systemTemp.createTempSync().path);
Uri.directory(
Directory.systemTemp.createTempSync('swiftgen temp ').path,
);
2 changes: 1 addition & 1 deletion pkgs/swiftgen/test/integration/util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class TestGenerator {
TestGenerator(this.name)
: isObjCCompatible = objCCompatibleTests.contains(name) {
testDir = path.absolute(path.join(pkgDir, 'test/integration'));
tempDir = path.join(testDir, 'temp');
tempDir = path.join(testDir, 'temp dir');
inputFile = path.join(testDir, '$name.swift');
wrapperFile = path.join(tempDir, '${name}_wrapper.swift');
outputFile = path.join(tempDir, '${name}_output.dart');
Expand Down
Loading