@@ -6,6 +6,7 @@ import 'dart:io';
6
6
7
7
import 'package:io/io.dart' ;
8
8
import 'package:path/path.dart' as p;
9
+ import 'package:pubspec_parse/pubspec_parse.dart' ;
9
10
import 'package:test_common/utilities.dart' ;
10
11
11
12
enum IndexBaseMode { noBase, base }
@@ -17,7 +18,6 @@ class TestProject {
17
18
final String webAssetsPath;
18
19
final String dartEntryFileName;
19
20
final String htmlEntryFileName;
20
- final List <TestProject > dependencies;
21
21
final bool editable;
22
22
23
23
late Directory _fixturesCopy;
@@ -74,7 +74,6 @@ class TestProject {
74
74
dartEntryFileName: 'main.dart' ,
75
75
htmlEntryFileName:
76
76
baseMode == IndexBaseMode .base ? 'base_index.html' : 'index.html' ,
77
- dependencies: [TestProject .test],
78
77
);
79
78
80
79
static final testCircular1 = TestProject ._(
@@ -83,7 +82,6 @@ class TestProject {
83
82
webAssetsPath: 'web' ,
84
83
dartEntryFileName: 'main.dart' ,
85
84
htmlEntryFileName: 'index.html' ,
86
- dependencies: [TestProject .testCircular2 ()],
87
85
);
88
86
89
87
TestProject .testCircular2 ({IndexBaseMode baseMode = IndexBaseMode .noBase})
@@ -94,7 +92,6 @@ class TestProject {
94
92
dartEntryFileName: 'main.dart' ,
95
93
htmlEntryFileName:
96
94
baseMode == IndexBaseMode .base ? 'base_index.html' : 'index.html' ,
97
- dependencies: [TestProject .testCircular1],
98
95
);
99
96
100
97
static final test = TestProject ._(
@@ -147,7 +144,6 @@ class TestProject {
147
144
webAssetsPath: 'web' ,
148
145
dartEntryFileName: 'main.dart' ,
149
146
htmlEntryFileName: 'index.html' ,
150
- dependencies: [TestProject .testHotRestart1],
151
147
editable: true ,
152
148
);
153
149
@@ -184,18 +180,45 @@ class TestProject {
184
180
required this .webAssetsPath,
185
181
required this .dartEntryFileName,
186
182
required this .htmlEntryFileName,
187
- this .dependencies = const < TestProject > [],
188
183
this .editable = false ,
189
184
});
190
185
191
- static void _copyPackageIntoTempDirectory (
186
+ static void _copyPackageAndPathDependenciesIntoTempDirectory (
192
187
Directory tempDirectory,
193
188
String packageDirectory,
189
+ Set <String > copiedPackageDirectories,
194
190
) {
191
+ // There may be cycles in dependencies, so check that we already copied this
192
+ // package.
193
+ if (copiedPackageDirectories.contains (packageDirectory)) return ;
195
194
final currentPath = absolutePath (pathFromFixtures: packageDirectory);
196
195
final newPath = p.join (tempDirectory.absolute.path, packageDirectory);
197
196
Directory (newPath).createSync ();
198
197
copyPathSync (currentPath, newPath);
198
+ copiedPackageDirectories.add (packageDirectory);
199
+ final pubspec = Pubspec .parse (
200
+ File (p.join (currentPath, 'pubspec.yaml' )).readAsStringSync (),
201
+ );
202
+ for (final package in pubspec.dependencies.keys) {
203
+ final dependency = pubspec.dependencies[package]! ;
204
+ if (dependency is PathDependency ) {
205
+ final dependencyDirectory = Directory (dependency.path);
206
+ // It may be okay to do some more complicated copying here for path
207
+ // dependencies that aren't immediately under `fixtures`, but for now,
208
+ // only support those that are.
209
+ assert (
210
+ dependencyDirectory.parent == Directory (currentPath).parent,
211
+ 'Path dependency of $packageDirectory : '
212
+ '${dependencyDirectory .absolute .path } is not an immediate directory '
213
+ 'in `fixtures`.' ,
214
+ );
215
+ _copyPackageAndPathDependenciesIntoTempDirectory (
216
+ tempDirectory,
217
+ p.dirname (dependencyDirectory.path),
218
+ copiedPackageDirectories,
219
+ );
220
+ }
221
+ }
199
222
}
200
223
201
224
Future <void > setUp () async {
@@ -210,19 +233,11 @@ class TestProject {
210
233
Directory .systemTemp.resolveSymbolicLinksSync (),
211
234
);
212
235
_fixturesCopy = systemTempDir.createTempSync ();
213
- _copyPackageIntoTempDirectory (_fixturesCopy, packageDirectory);
214
- // Also copy any of its dependencies, recursively.
215
- final copiedPackages = < TestProject > {this };
216
- final dependencyQueue = List <TestProject >.from (dependencies);
217
- while (dependencyQueue.isNotEmpty) {
218
- final dependency = dependencyQueue.removeAt (0 );
219
- if (copiedPackages.contains (dependency)) continue ;
220
- _copyPackageIntoTempDirectory (
221
- _fixturesCopy,
222
- dependency.packageDirectory,
223
- );
224
- dependencyQueue.addAll (dependency.dependencies);
225
- }
236
+ _copyPackageAndPathDependenciesIntoTempDirectory (
237
+ _fixturesCopy,
238
+ packageDirectory,
239
+ {},
240
+ );
226
241
}
227
242
228
243
// Clean up the project.
0 commit comments