Skip to content

Disable frontend_server_client_test on windows #2376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,123 +58,135 @@ String get message => p.join('hello', 'world');
await client.shutdown();
});

test('can compile, recompile, and hot reload a vm app', () async {
var entrypoint = p.join(packageRoot, 'bin', 'main.dart');
client = await FrontendServerClient.start(
entrypoint, p.join(packageRoot, 'out.dill'), vmPlatformDill);
var result = await client.compile();
client.accept();
expect(result.compilerOutputLines, isEmpty);
expect(result.errorCount, 0);
expect(
result.newSources,
containsAll([
File(entrypoint).uri,
packageConfig.resolve(Uri.parse('package:path/path.dart')),
]));
expect(result.removedSources, isEmpty);
expect(result.dillOutput, isNotNull);
expect(File(result.dillOutput!).existsSync(), true);
var process = await Process.start(Platform.resolvedExecutable, [
'--observe',
'--no-pause-isolates-on-exit',
'--pause-isolates-on-start',
result.dillOutput!
]);
addTearDown(process.kill);
var stdoutLines = StreamQueue(
process.stdout.transform(utf8.decoder).transform(const LineSplitter()));

var observatoryLine = await stdoutLines.next;
var observatoryUri =
'${observatoryLine.split(' ').last.replaceFirst('http', 'ws')}ws';
var vmService = await vmServiceConnectUri(observatoryUri);
var isolate = await waitForIsolatesAndResume(vmService);

await expectLater(stdoutLines, emitsThrough(p.join('hello', 'world')));

var appFile = File(entrypoint);
var originalContent = await appFile.readAsString();
var newContent = originalContent.replaceFirst('hello', 'goodbye');
await appFile.writeAsString(newContent);

result = await client.compile([File(entrypoint).uri]);

client.accept();
expect(result.newSources, isEmpty);
expect(result.removedSources, isEmpty);
expect(result.compilerOutputLines, isEmpty);
expect(result.errorCount, 0);
expect(result.dillOutput, endsWith('.incremental.dill'));

await vmService.reloadSources(isolate.id!, rootLibUri: result.dillOutput);

expect(await stdoutLines.next, p.join('goodbye', 'world'));
expect(await process.exitCode, 0);
});

test('can handle compile errors and reload fixes', () async {
var entrypoint = p.join(packageRoot, 'bin', 'main.dart');
var entrypointFile = File(entrypoint);
var originalContent = await entrypointFile.readAsString();
// append two compile errors to the bottom
await entrypointFile
.writeAsString('$originalContent\nint foo = 1.0;\nString bar = 4;');

client = await FrontendServerClient.start(
entrypoint, p.join(packageRoot, 'out.dill'), vmPlatformDill);
var result = await client.compile();

client.accept();
expect(result.errorCount, 2);
expect(result.compilerOutputLines,
allOf(contains('int foo = 1.0;'), contains('String bar = 4;')));
expect(
result.newSources,
containsAll([
File(entrypoint).uri,
packageConfig.resolve(Uri.parse('package:path/path.dart')),
]));
expect(result.removedSources, isEmpty);
expect(result.dillOutput, isNotNull);
expect(File(result.dillOutput!).existsSync(), true);

var process = await Process.start(Platform.resolvedExecutable, [
'--observe',
'--no-pause-isolates-on-exit',
'--pause-isolates-on-start',
result.dillOutput!
]);
addTearDown(process.kill);
var stdoutLines = StreamQueue(
process.stdout.transform(utf8.decoder).transform(const LineSplitter()));

var observatoryLine = await stdoutLines.next;
var observatoryUri =
'${observatoryLine.split(' ').last.replaceFirst('http', 'ws')}ws';
var vmService = await vmServiceConnectUri(observatoryUri);
var isolate = await waitForIsolatesAndResume(vmService);

// The program actually runs regardless of the errors, as they don't affect
// the runtime behavior.
await expectLater(stdoutLines, emitsThrough(p.join('hello', 'world')));

await entrypointFile
.writeAsString(originalContent.replaceFirst('hello', 'goodbye'));
result = await client.compile([entrypointFile.uri]);
client.accept();
expect(result.errorCount, 0);
expect(result.compilerOutputLines, isEmpty);
expect(result.newSources, isEmpty);
expect(result.removedSources, isEmpty);
expect(result.dillOutput, isNotNull);
expect(File(result.dillOutput!).existsSync(), true);

await vmService.reloadSources(isolate.id!, rootLibUri: result.dillOutput);

expect(await stdoutLines.next, p.join('goodbye', 'world'));
expect(await process.exitCode, 0);
});
test(
'can compile, recompile, and hot reload a vm app',
() async {
var entrypoint = p.join(packageRoot, 'bin', 'main.dart');
client = await FrontendServerClient.start(
entrypoint, p.join(packageRoot, 'out.dill'), vmPlatformDill);
var result = await client.compile();
client.accept();
expect(result.compilerOutputLines, isEmpty);
expect(result.errorCount, 0);
expect(
result.newSources,
containsAll([
File(entrypoint).uri,
packageConfig.resolve(Uri.parse('package:path/path.dart')),
]));
expect(result.removedSources, isEmpty);
expect(result.dillOutput, isNotNull);
expect(File(result.dillOutput!).existsSync(), true);
var process = await Process.start(Platform.resolvedExecutable, [
'--observe',
'--no-pause-isolates-on-exit',
'--pause-isolates-on-start',
result.dillOutput!
]);
addTearDown(process.kill);
var stdoutLines = StreamQueue(process.stdout
.transform(utf8.decoder)
.transform(const LineSplitter()));

var observatoryLine = await stdoutLines.next;
var observatoryUri =
'${observatoryLine.split(' ').last.replaceFirst('http', 'ws')}ws';
var vmService = await vmServiceConnectUri(observatoryUri);
var isolate = await waitForIsolatesAndResume(vmService);

await expectLater(stdoutLines, emitsThrough(p.join('hello', 'world')));

var appFile = File(entrypoint);
var originalContent = await appFile.readAsString();
var newContent = originalContent.replaceFirst('hello', 'goodbye');
await appFile.writeAsString(newContent);

result = await client.compile([File(entrypoint).uri]);

client.accept();
expect(result.newSources, isEmpty);
expect(result.removedSources, isEmpty);
expect(result.compilerOutputLines, isEmpty);
expect(result.errorCount, 0);
expect(result.dillOutput, endsWith('.incremental.dill'));

await vmService.reloadSources(isolate.id!, rootLibUri: result.dillOutput);

expect(await stdoutLines.next, p.join('goodbye', 'world'));
expect(await process.exitCode, 0);
},
// Issue: https://github.com/dart-lang/webdev/issues/2377
skip: Platform.isWindows,
);

test(
'can handle compile errors and reload fixes',
() async {
var entrypoint = p.join(packageRoot, 'bin', 'main.dart');
var entrypointFile = File(entrypoint);
var originalContent = await entrypointFile.readAsString();
// append two compile errors to the bottom
await entrypointFile
.writeAsString('$originalContent\nint foo = 1.0;\nString bar = 4;');

client = await FrontendServerClient.start(
entrypoint, p.join(packageRoot, 'out.dill'), vmPlatformDill);
var result = await client.compile();

client.accept();
expect(result.errorCount, 2);
expect(result.compilerOutputLines,
allOf(contains('int foo = 1.0;'), contains('String bar = 4;')));
expect(
result.newSources,
containsAll([
File(entrypoint).uri,
packageConfig.resolve(Uri.parse('package:path/path.dart')),
]));
expect(result.removedSources, isEmpty);
expect(result.dillOutput, isNotNull);
expect(File(result.dillOutput!).existsSync(), true);

var process = await Process.start(Platform.resolvedExecutable, [
'--observe',
'--no-pause-isolates-on-exit',
'--pause-isolates-on-start',
result.dillOutput!
]);
addTearDown(process.kill);
var stdoutLines = StreamQueue(process.stdout
.transform(utf8.decoder)
.transform(const LineSplitter()));

var observatoryLine = await stdoutLines.next;
var observatoryUri =
'${observatoryLine.split(' ').last.replaceFirst('http', 'ws')}ws';
var vmService = await vmServiceConnectUri(observatoryUri);
var isolate = await waitForIsolatesAndResume(vmService);

// The program actually runs regardless of the errors, as they don't affect
// the runtime behavior.
await expectLater(stdoutLines, emitsThrough(p.join('hello', 'world')));

await entrypointFile
.writeAsString(originalContent.replaceFirst('hello', 'goodbye'));
result = await client.compile([entrypointFile.uri]);
client.accept();
expect(result.errorCount, 0);
expect(result.compilerOutputLines, isEmpty);
expect(result.newSources, isEmpty);
expect(result.removedSources, isEmpty);
expect(result.dillOutput, isNotNull);
expect(File(result.dillOutput!).existsSync(), true);

await vmService.reloadSources(isolate.id!, rootLibUri: result.dillOutput);

expect(await stdoutLines.next, p.join('goodbye', 'world'));
expect(await process.exitCode, 0);
},
// Issue: https://github.com/dart-lang/webdev/issues/2377
skip: Platform.isWindows,
);

test('can compile and recompile a dartdevc app', () async {
var entrypoint =
Expand Down