Skip to content

Commit

Permalink
Disable frontend_server_client_test on windows (#2376)
Browse files Browse the repository at this point in the history
  • Loading branch information
elliette authored Feb 27, 2024
1 parent c29e5f8 commit b39cefc
Showing 1 changed file with 129 additions and 117 deletions.
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

0 comments on commit b39cefc

Please sign in to comment.