Skip to content

Commit 3b35f9d

Browse files
committed
Cache current directory at context creation
1 parent 897433c commit 3b35f9d

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

dwds/test/fixtures/context.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,21 @@ class TestContext {
129129
/// External VM service.
130130
VmService get vmService => debugConnection.vmService;
131131

132-
TestContext(this.project, this.sdkConfigurationProvider);
132+
final String _savedCurrentDirectory;
133+
134+
TestContext(this.project, this.sdkConfigurationProvider)
135+
: _savedCurrentDirectory = p.current;
133136

134137
Future<void> setUp({
135138
TestSettings testSettings = const TestSettings(),
136139
TestAppMetadata appMetadata = const TestAppMetadata.externalApp(),
137140
TestDebugSettings debugSettings = const TestDebugSettings.noDevTools(),
138141
}) async {
139142
try {
143+
// The frontend server modifies the current path. Make sure that we
144+
// restore it every time the context is set up so that if a previous
145+
// test failed to tear down, we don't affect future tests.
146+
DartUri.currentDirectory = _savedCurrentDirectory;
140147
// Build settings to return from load strategy.
141148
final buildSettings = TestBuildSettings(
142149
appEntrypoint: project.dartEntryFilePackageUri,

test_common/lib/utilities.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ const newDdcTypeSystemVersion = '3.3.0-242.0.dev';
1515
/// The path to the webdev directory in the local machine, e.g.
1616
/// '/workstation/webdev'.
1717
String get webdevPath {
18-
// Use `Directory.current` instead of `p.current` as the latter is allowed to
19-
// change with `DartUri.currentDirectory` modifications.
20-
final pathParts = p.split(Directory.current.path);
18+
final pathParts = p.split(p.current);
2119
assert(pathParts.contains(webdevDirName));
2220
return p.joinAll(
2321
pathParts.sublist(0, pathParts.lastIndexOf(webdevDirName) + 1),

0 commit comments

Comments
 (0)