Skip to content

Commit 8951f55

Browse files
committed
Logging
1 parent 52ad019 commit 8951f55

File tree

2 files changed

+36
-17
lines changed

2 files changed

+36
-17
lines changed

dwds/test/fixtures/context.dart

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ class TestContext {
132132
TestContext(this.project, this.sdkConfigurationProvider);
133133

134134
Future<void> setUp({
135+
int setupNum = -1,
135136
TestSettings testSettings = const TestSettings(),
136137
TestAppMetadata appMetadata = const TestAppMetadata.externalApp(),
137138
TestDebugSettings debugSettings =
@@ -154,12 +155,14 @@ class TestContext {
154155

155156
DartUri.currentDirectory = project.absolutePackageDirectory;
156157

157-
_logger.info(
158-
'Serving: ${project.directoryToServe}/${project.filePathToServe}',
159-
);
160-
_logger.info('Project: ${project.absolutePackageDirectory}');
161-
_logger.info('Packages: ${project.packageConfigFile}');
162-
_logger.info('Entry: ${project.dartEntryFilePath}');
158+
void log(String s) {
159+
_logger.info('${DateTime.now()}: ($setupNum): $s');
160+
}
161+
162+
log('Serving: ${project.directoryToServe}/${project.filePathToServe}');
163+
log('Project: ${project.absolutePackageDirectory}');
164+
log('Packages: ${project.packageConfigFile}');
165+
log('Entry: ${project.dartEntryFilePath}');
163166

164167
configureLogWriter();
165168

@@ -174,12 +177,17 @@ class TestContext {
174177
_outputDir = systemTempDir.createTempSync('foo bar');
175178

176179
final chromeDriverPort = await findUnusedPort();
180+
log('Picked chromeDriverPort = $chromeDriverPort');
177181
final chromeDriverUrlBase = 'wd/hub';
178182
try {
179-
_chromeDriver = await Process.start('chromedriver$_exeExt', [
180-
'--port=$chromeDriverPort',
181-
'--url-base=$chromeDriverUrlBase',
182-
]);
183+
final localDriver =
184+
_chromeDriver = await Process.start('chromedriver$_exeExt', [
185+
'--port=$chromeDriverPort',
186+
'--url-base=$chromeDriverUrlBase',
187+
]);
188+
log(
189+
'Started chrome driver - identity hash code = ${identityHashCode(localDriver)}',
190+
);
183191
// On windows this takes a while to boot up, wait for the first line
184192
// of stdout as a signal that it is ready.
185193
final stdOutLines =
@@ -194,14 +202,11 @@ class TestContext {
194202
.transform(const LineSplitter())
195203
.asBroadcastStream();
196204

197-
stdOutLines.listen(
198-
(line) => _logger.finest('ChromeDriver stdout: $line'),
199-
);
200-
stdErrLines.listen(
201-
(line) => _logger.warning('ChromeDriver stderr: $line'),
202-
);
205+
stdOutLines.listen((line) => log('ChromeDriver stdout: $line'));
206+
stdErrLines.listen((line) => log('ChromeDriver stderr: $line'));
203207

204-
await stdOutLines.first;
208+
final firstLine = await stdOutLines.first;
209+
log('Notice first line = $firstLine');
205210
} catch (e) {
206211
throw StateError(
207212
'Could not start ChromeDriver. Is it installed?\nError: $e',
@@ -221,6 +226,7 @@ class TestContext {
221226
var filePathToServe = project.filePathToServe;
222227

223228
_port = await findUnusedPort();
229+
log('Port #2: $_port');
224230
switch (testSettings.compilationMode) {
225231
case CompilationMode.buildDaemon:
226232
{
@@ -337,6 +343,7 @@ class TestContext {
337343
);
338344

339345
final assetServerPort = await findUnusedPort();
346+
log('Port #3: $assetServerPort');
340347
_hostname = appMetadata.hostname;
341348
await webRunner.run(
342349
frontendServerFileSystem,
@@ -391,6 +398,7 @@ class TestContext {
391398
}
392399

393400
final debugPort = await findUnusedPort();
401+
log('Port #4: $debugPort');
394402
if (testSettings.launchChrome) {
395403
// If the environment variable DWDS_DEBUG_CHROME is set to the string
396404
// true then Chrome will be launched with a UI rather than headless.
@@ -417,6 +425,14 @@ class TestContext {
417425
],
418426
},
419427
});
428+
log(
429+
'Now creating web driver for chrome driver port; '
430+
'going for port $chromeDriverPort',
431+
);
432+
log(
433+
' -> notice chrome driver identity hash code is '
434+
'${identityHashCode(_chromeDriver)}',
435+
);
420436
_webDriver = await createDriver(
421437
spec: WebDriverSpec.JsonWire,
422438
desired: capabilities,

dwds/test/hot_restart_breakpoints_test.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import 'fixtures/context.dart';
2121
import 'fixtures/project.dart';
2222
import 'fixtures/utilities.dart';
2323

24+
int setupNum = 0;
25+
2426
void main() {
2527
// Enable verbose logging for debugging.
2628
const debug = false;
@@ -52,6 +54,7 @@ void main() {
5254
setUp(() async {
5355
setCurrentLogWriter(debug: debug);
5456
await context.setUp(
57+
setupNum: ++setupNum,
5558
testSettings: TestSettings(
5659
enableExpressionEvaluation: true,
5760
compilationMode: CompilationMode.frontendServer,

0 commit comments

Comments
 (0)