@@ -18,16 +18,13 @@ class TestProject {
1818 final String webAssetsPath;
1919 final String dartEntryFileName;
2020 final String htmlEntryFileName;
21- final bool editable;
2221
2322 late Directory _fixturesCopy;
2423
2524 /// The top level directory in which we run the test server, e.g.
26- /// "/workstation/webdev/fixtures /_testSound".
25+ /// "/tmp /_testSound".
2726 String get absolutePackageDirectory =>
28- editable
29- ? p.join (_fixturesCopy.absolute.path, packageDirectory)
30- : absolutePath (pathFromFixtures: packageDirectory);
27+ p.join (_fixturesCopy.absolute.path, packageDirectory);
3128
3229 /// The directory to build and serve, e.g. "example".
3330 String get directoryToServe => p.split (webAssetsPath).first;
@@ -42,17 +39,13 @@ class TestProject {
4239 }
4340
4441 /// The path to the Dart entry file, e.g,
45- /// "/workstation/webdev/fixtures/_testSound/example/hello_world/main.dart":
46- String get dartEntryFilePath {
47- final entryFilePathInPkg = [
48- packageDirectory,
49- webAssetsPath,
50- dartEntryFileName,
51- ];
52- return editable
53- ? p.joinAll ([_fixturesCopy.absolute.path, ...entryFilePathInPkg])
54- : absolutePath (pathFromFixtures: p.joinAll (entryFilePathInPkg));
55- }
42+ /// "/tmp/_testSound/example/hello_world/main.dart":
43+ String get dartEntryFilePath => p.joinAll ([
44+ _fixturesCopy.absolute.path,
45+ packageDirectory,
46+ webAssetsPath,
47+ dartEntryFileName,
48+ ]);
5649
5750 /// The URI for the package_config.json is located in:
5851 /// `<project directory>/.dart_tool/package_config`
@@ -100,7 +93,6 @@ class TestProject {
10093 webAssetsPath: 'example/hello_world' ,
10194 dartEntryFileName: 'main.dart' ,
10295 htmlEntryFileName: 'index.html' ,
103- editable: true ,
10496 );
10597
10698 static final testScopes = TestProject ._(
@@ -117,7 +109,6 @@ class TestProject {
117109 webAssetsPath: webCompatiblePath (['example' , 'append_body' ]),
118110 dartEntryFileName: 'main.dart' ,
119111 htmlEntryFileName: 'index.html' ,
120- editable: true ,
121112 );
122113
123114 static final testExperiment = TestProject ._(
@@ -144,7 +135,6 @@ class TestProject {
144135 webAssetsPath: 'web' ,
145136 dartEntryFileName: 'main.dart' ,
146137 htmlEntryFileName: 'index.html' ,
147- editable: true ,
148138 );
149139
150140 static final testHotRestartBreakpoints = TestProject ._(
@@ -153,7 +143,6 @@ class TestProject {
153143 webAssetsPath: 'web' ,
154144 dartEntryFileName: 'main.dart' ,
155145 htmlEntryFileName: 'index.html' ,
156- editable: true ,
157146 );
158147
159148 static final testHotReload = TestProject ._(
@@ -162,7 +151,6 @@ class TestProject {
162151 webAssetsPath: 'web' ,
163152 dartEntryFileName: 'main.dart' ,
164153 htmlEntryFileName: 'index.html' ,
165- editable: true ,
166154 );
167155
168156 static final testHotReloadBreakpoints = TestProject ._(
@@ -171,7 +159,6 @@ class TestProject {
171159 webAssetsPath: 'web' ,
172160 dartEntryFileName: 'main.dart' ,
173161 htmlEntryFileName: 'index.html' ,
174- editable: true ,
175162 );
176163
177164 TestProject ._({
@@ -180,7 +167,6 @@ class TestProject {
180167 required this .webAssetsPath,
181168 required this .dartEntryFileName,
182169 required this .htmlEntryFileName,
183- this .editable = false ,
184170 });
185171
186172 static void _copyPackageAndPathDependenciesIntoTempDirectory (
@@ -225,21 +211,19 @@ class TestProject {
225211 Future <void > setUp () async {
226212 // Verify that the web assets path has no starting slash.
227213 assert (! webAssetsPath.startsWith ('/' ));
228- // If this project is editable, we should use a copy of the package to edit
229- // instead.
230- if (editable) {
231- final systemTempDir = Directory (
232- // Resolve symbolic links as build_daemon tests rely on paths matching
233- // between the client and the daemon.
234- Directory .systemTemp.resolveSymbolicLinksSync (),
235- );
236- _fixturesCopy = systemTempDir.createTempSync ();
237- _copyPackageAndPathDependenciesIntoTempDirectory (
238- _fixturesCopy,
239- packageDirectory,
240- {},
241- );
242- }
214+ // Copy the package into a temporary directory to allow editing of files if
215+ // needed.
216+ final systemTempDir = Directory (
217+ // Resolve symbolic links as build_daemon tests rely on paths matching
218+ // between the client and the daemon.
219+ Directory .systemTemp.resolveSymbolicLinksSync (),
220+ );
221+ _fixturesCopy = systemTempDir.createTempSync ();
222+ _copyPackageAndPathDependenciesIntoTempDirectory (
223+ _fixturesCopy,
224+ packageDirectory,
225+ {},
226+ );
243227
244228 // Clean up the project.
245229 // Called when we need to rebuild sdk and the app from previous test
@@ -251,26 +235,24 @@ class TestProject {
251235 ], workingDirectory: absolutePackageDirectory);
252236 }
253237
254- /// Delete the project if we made a copy .
238+ /// Delete the copy of the project .
255239 Future <void > tearDown () async {
256- if (editable) {
257- try {
258- _fixturesCopy.deleteSync (recursive: true );
259- } on FileSystemException catch (_) {
260- // On Windows, the build daemon process might still be accessing the
261- // working directory, so wait a second and then try again.
262- await Future .delayed (const Duration (seconds: 1 ));
263- _fixturesCopy.deleteSync (recursive: true );
264- }
240+ try {
241+ _fixturesCopy.deleteSync (recursive: true );
242+ } on FileSystemException catch (_) {
243+ // On Windows, the build daemon process might still be accessing the
244+ // working directory, so wait a second and then try again.
245+ await Future .delayed (const Duration (seconds: 1 ));
246+ _fixturesCopy.deleteSync (recursive: true );
265247 }
266248 }
267249
268250 /// The path to the Dart specified file in the 'lib' directory, e.g,
269- /// "/workstation/webdev/fixtures /_testSound/lib/library.dart":
270- String dartLibFilePath (String dartLibFileName) {
271- final libFilePathInPkg = [packageDirectory, 'lib' , dartLibFileName];
272- return editable
273- ? p. joinAll ([_fixturesCopy.absolute.path, ...libFilePathInPkg])
274- : absolutePath (pathFromFixtures : p. joinAll (libFilePathInPkg));
275- }
251+ /// "/tmp /_testSound/lib/library.dart":
252+ String dartLibFilePath (String dartLibFileName) => p. joinAll ([
253+ _fixturesCopy.absolute.path,
254+ packageDirectory,
255+ 'lib' ,
256+ dartLibFileName,
257+ ]);
276258}
0 commit comments