@@ -61,40 +61,6 @@ class TestContext {
6161 final NullSafety nullSafety;
6262 final TestSdkConfigurationProvider sdkConfigurationProvider;
6363
64- /// Top level directory in which we run the test server, e.g.
65- /// "/workstation/webdev/fixtures/_testSound".
66- String get workingDirectory =>
67- absolutePath (pathFromFixtures: project.packageDirectory);
68-
69- /// The directory to build and serve, e.g. "example".
70- String get directoryToServe => p.split (project.webAssetsPath).first;
71-
72- /// The path to the HTML file to serve, relative to the [directoryToServe] ,
73- /// e.g. "hello_world/index.html".
74- String get filePathToServe {
75- final pathParts = p.split (project.webAssetsPath).where (
76- (pathPart) => pathPart != directoryToServe,
77- );
78- return webCompatiblePath ([...pathParts, project.htmlEntryFileName]);
79- }
80-
81- /// The path to the Dart entry file, e.g,
82- /// "/workstation/webdev/fixtures/_testSound/example/hello_world/main.dart":
83- String get _dartEntryFilePath => absolutePath (
84- pathFromFixtures: p.joinAll (
85- [
86- project.packageDirectory,
87- project.webAssetsPath,
88- project.dartEntryFileName,
89- ],
90- ),
91- );
92-
93- /// The URI for the package_config.json is located in:
94- /// <project directory>/.dart_tool/package_config
95- Uri get _packageConfigFile =>
96- p.toUri (p.join (workingDirectory, '.dart_tool' , 'package_config.json' ));
97-
9864 String get appUrl => _appUrl! ;
9965 late String ? _appUrl;
10066
@@ -150,14 +116,16 @@ class TestContext {
150116
151117 TestContext (this .project, this .sdkConfigurationProvider)
152118 : nullSafety = project.nullSafety {
153- DartUri .currentDirectory = workingDirectory ;
119+ DartUri .currentDirectory = project.absolutePackageDirectory ;
154120
155121 project.validate ();
156122
157- _logger.info ('Serving: $directoryToServe /$filePathToServe ' );
158- _logger.info ('Project: $workingDirectory ' );
159- _logger.info ('Packages: $_packageConfigFile ' );
160- _logger.info ('Entry: $_dartEntryFilePath ' );
123+ _logger.info (
124+ 'Serving: ${project .directoryToServe }/${project .filePathToServe }' ,
125+ );
126+ _logger.info ('Project: ${project .absolutePackageDirectory }' );
127+ _logger.info ('Packages: ${project .packageConfigFile }' );
128+ _logger.info ('Entry: ${project .dartEntryFilePath }' );
161129 }
162130
163131 Future <void > setUp ({
@@ -187,7 +155,7 @@ class TestContext {
187155 final configuration = await sdkConfigurationProvider.configuration;
188156 configuration.validate ();
189157
190- DartUri .currentDirectory = workingDirectory ;
158+ DartUri .currentDirectory = project.absolutePackageDirectory ;
191159 configureLogWriter ();
192160
193161 _client = IOClient (
@@ -234,7 +202,7 @@ class TestContext {
234202 await Process .run (
235203 sdkLayout.dartPath,
236204 ['pub' , 'upgrade' ],
237- workingDirectory: workingDirectory ,
205+ workingDirectory: project.absolutePackageDirectory ,
238206 );
239207
240208 ExpressionCompiler ? expressionCompiler;
@@ -257,7 +225,8 @@ class TestContext {
257225 '--verbose' ,
258226 ];
259227 _daemonClient = await connectClient (
260- sdkLayout.dartPath, workingDirectory, options, (log) {
228+ sdkLayout.dartPath, project.absolutePackageDirectory, options,
229+ (log) {
261230 final record = log.toLogRecord ();
262231 final name =
263232 record.loggerName == '' ? '' : '${record .loggerName }: ' ;
@@ -269,19 +238,22 @@ class TestContext {
269238 );
270239 });
271240 daemonClient.registerBuildTarget (
272- DefaultBuildTarget ((b) => b..target = directoryToServe),
241+ DefaultBuildTarget ((b) => b..target = project. directoryToServe),
273242 );
274243 daemonClient.startBuild ();
275244
276245 await waitForSuccessfulBuild ();
277246
278- final assetServerPort = daemonPort (workingDirectory);
247+ final assetServerPort =
248+ daemonPort (project.absolutePackageDirectory);
279249 _assetHandler = proxyHandler (
280- 'http://localhost:$assetServerPort /$directoryToServe /' ,
250+ 'http://localhost:$assetServerPort /${ project . directoryToServe } /' ,
281251 client: client,
282252 );
283- assetReader =
284- ProxyServerAssetReader (assetServerPort, root: directoryToServe);
253+ assetReader = ProxyServerAssetReader (
254+ assetServerPort,
255+ root: project.directoryToServe,
256+ );
285257
286258 if (enableExpressionEvaluation) {
287259 ddcService = ExpressionCompilerService (
@@ -306,25 +278,25 @@ class TestContext {
306278 break ;
307279 case CompilationMode .frontendServer:
308280 {
309- _logger.warning ('Index: $filePathToServe ' );
281+ _logger.warning ('Index: $project . filePathToServe' );
310282
311283 final entry = p.toUri (
312284 p.join (project.webAssetsPath, project.dartEntryFileName),
313285 );
314286 final fileSystem = LocalFileSystem ();
315287 final packageUriMapper = await PackageUriMapper .create (
316288 fileSystem,
317- _packageConfigFile ,
289+ project.packageConfigFile ,
318290 useDebuggerModuleNames: useDebuggerModuleNames,
319291 );
320292
321293 _webRunner = ResidentWebRunner (
322294 mainUri: entry,
323295 urlTunneler: urlEncoder,
324- projectDirectory: p.toUri (workingDirectory ),
325- packageConfigFile: _packageConfigFile ,
296+ projectDirectory: p.toUri (project.absolutePackageDirectory ),
297+ packageConfigFile: project.packageConfigFile ,
326298 packageUriMapper: packageUriMapper,
327- fileSystemRoots: [p.toUri (workingDirectory )],
299+ fileSystemRoots: [p.toUri (project.absolutePackageDirectory )],
328300 fileSystemScheme: 'org-dartlang-app' ,
329301 outputPath: outputDir.path,
330302 soundNullSafety: nullSafety == NullSafety .sound,
@@ -338,7 +310,7 @@ class TestContext {
338310 fileSystem,
339311 hostname,
340312 assetServerPort,
341- p.join (directoryToServe, filePathToServe),
313+ p.join (project. directoryToServe, project. filePathToServe),
342314 );
343315
344316 if (enableExpressionEvaluation) {
@@ -402,7 +374,7 @@ class TestContext {
402374 assetHandler,
403375 assetReader,
404376 requireStrategy,
405- directoryToServe,
377+ project. directoryToServe,
406378 buildResults,
407379 () async => connection,
408380 serveDevTools,
@@ -420,8 +392,8 @@ class TestContext {
420392 );
421393
422394 _appUrl = basePath.isEmpty
423- ? 'http://localhost:$port /$filePathToServe '
424- : 'http://localhost:$port /$basePath /$filePathToServe ' ;
395+ ? 'http://localhost:$port /${ project . filePathToServe } '
396+ : 'http://localhost:$port /$basePath /${ project . filePathToServe } ' ;
425397
426398 if (launchChrome) {
427399 await _webDriver? .get (appUrl);
@@ -483,7 +455,7 @@ class TestContext {
483455 required String toReplace,
484456 required String replaceWith,
485457 }) {
486- final file = File (_dartEntryFilePath );
458+ final file = File (project.dartEntryFilePath );
487459 final fileContents = file.readAsStringSync ();
488460 file.writeAsStringSync (fileContents.replaceAll (toReplace, replaceWith));
489461 }
0 commit comments