Skip to content

Commit c8390cf

Browse files
committed
Clean up debug prints, move sync calls to async, and set currentDirectory to p.current before project setUp
1 parent 060bc55 commit c8390cf

File tree

4 files changed

+14
-24
lines changed

4 files changed

+14
-24
lines changed

dwds/lib/src/utilities/dart_uri.dart

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -168,26 +168,18 @@ class DartUri {
168168
/// We store this here because for tests we may want to act as if we're
169169
/// running in the directory of a target package, even if the current
170170
/// directory of the tests is actually the main dwds directory.
171-
static String get currentDirectory {
172-
print('Getting current directory: $_currentDirectory');
173-
return _currentDirectory;
174-
}
171+
static String get currentDirectory => _currentDirectory;
175172

176173
static set currentDirectory(String newDir) {
177-
print('Setting current directory: $newDir');
178174
_currentDirectory = newDir;
179-
print('Setting current directory uri: ${p.toUri(newDir)}');
180175
_currentDirectoryUri = '${p.toUri(newDir)}';
181176
}
182177

183178
static String _currentDirectoryUri = '${p.toUri(currentDirectory)}';
184179

185180
/// The current directory as a file: Uri, saved in a field to avoid
186181
/// re-computing.
187-
static String get currentDirectoryUri {
188-
print('Getting current directory uri: $_currentDirectoryUri');
189-
return _currentDirectoryUri;
190-
}
182+
static String get currentDirectoryUri => _currentDirectoryUri;
191183

192184
/// Record library and script uris to enable resolving library and script paths.
193185
static Future<void> initialize() async {

dwds/test/fixtures/context.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ class TestContext {
137137
TestDebugSettings debugSettings = const TestDebugSettings.noDevTools(),
138138
}) async {
139139
try {
140+
DartUri.currentDirectory = p.current;
140141
// Build settings to return from load strategy.
141142
final buildSettings = TestBuildSettings(
142143
appEntrypoint: project.dartEntryFilePackageUri,
@@ -541,7 +542,6 @@ class TestContext {
541542
await _webDriver?.quit(closeSession: true);
542543
_chromeDriver?.kill();
543544
DartUri.currentDirectory = p.current;
544-
print('Setting currentDirectory in tearDown: ${DartUri.currentDirectory}');
545545
await _daemonClient?.close();
546546
await ddcService?.stop();
547547
await _webRunner?.stop();

dwds/test/fixtures/project.dart

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -171,20 +171,19 @@ class TestProject {
171171

172172
static Future<void> _copyPackageAndPathDependenciesIntoTempDirectory(
173173
Directory tempDirectory,
174-
String absolutePackageDirectory,
174+
String packageDirectory,
175175
Set<String> copiedPackageDirectories,
176176
) async {
177177
// There may be cycles in dependencies, so check that we already copied this
178178
// package.
179-
final packageDirectory = p.basename(absolutePackageDirectory);
180179
if (copiedPackageDirectories.contains(packageDirectory)) return;
181180
final currentPath = absolutePath(pathFromFixtures: packageDirectory);
182181
final newPath = p.join(tempDirectory.absolute.path, packageDirectory);
183-
Directory(newPath).createSync();
184-
copyPathSync(currentPath, newPath);
182+
await Directory(newPath).create();
183+
await copyPath(currentPath, newPath);
185184
copiedPackageDirectories.add(packageDirectory);
186185
final pubspec = Pubspec.parse(
187-
File(p.join(currentPath, 'pubspec.yaml')).readAsStringSync(),
186+
await File(p.join(currentPath, 'pubspec.yaml')).readAsString(),
188187
);
189188
for (final dependency in pubspec.dependencies.values) {
190189
if (dependency is PathDependency) {
@@ -202,7 +201,7 @@ class TestProject {
202201
);
203202
await _copyPackageAndPathDependenciesIntoTempDirectory(
204203
tempDirectory,
205-
dependencyDirectory.path,
204+
p.basename(dependencyDirectory.path),
206205
copiedPackageDirectories,
207206
);
208207
}
@@ -215,7 +214,7 @@ class TestProject {
215214
'run',
216215
'build_runner',
217216
'clean',
218-
], workingDirectory: absolutePackageDirectory);
217+
], workingDirectory: newPath);
219218
}
220219

221220
Future<void> setUp() async {
@@ -226,25 +225,25 @@ class TestProject {
226225
final systemTempDir = Directory(
227226
// Resolve symbolic links as build_daemon tests rely on paths matching
228227
// between the client and the daemon.
229-
Directory.systemTemp.resolveSymbolicLinksSync(),
228+
await Directory.systemTemp.resolveSymbolicLinks(),
230229
);
231-
_fixturesCopy = systemTempDir.createTempSync();
230+
_fixturesCopy = await systemTempDir.createTemp();
232231
await _copyPackageAndPathDependenciesIntoTempDirectory(
233232
_fixturesCopy,
234-
absolutePackageDirectory,
233+
packageDirectory,
235234
{},
236235
);
237236
}
238237

239238
/// Delete the copy of the project.
240239
Future<void> tearDown() async {
241240
try {
242-
_fixturesCopy.deleteSync(recursive: true);
241+
await _fixturesCopy.delete(recursive: true);
243242
} on FileSystemException catch (_) {
244243
// On Windows, the build daemon process might still be accessing the
245244
// working directory, so wait a second and then try again.
246245
await Future.delayed(const Duration(seconds: 1));
247-
_fixturesCopy.deleteSync(recursive: true);
246+
await _fixturesCopy.delete(recursive: true);
248247
}
249248
}
250249

test_common/lib/utilities.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ const newDdcTypeSystemVersion = '3.3.0-242.0.dev';
1616
/// '/workstation/webdev'.
1717
String get webdevPath {
1818
final pathParts = p.split(p.current);
19-
print('Path parts: $pathParts');
2019
// We expect all tests to be run from the webdev mono-repo:
2120
assert(pathParts.contains(webdevDirName));
2221
return p.joinAll(

0 commit comments

Comments
 (0)