Skip to content

feat(dart_frog_cli): update cli bundles #1692

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
20 changes: 4 additions & 16 deletions packages/dart_frog_cli/e2e/test/daemon/daemon_domain_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ void main() {
late final DaemonStdioHelper daemonStdio;

setUpAll(() async {
await dartFrogCreate(
projectName: projectName,
directory: tempDirectory,
);
await dartFrogCreate(projectName: projectName, directory: tempDirectory);
daemonProcess = await dartFrogDaemonStart();

daemonStdio = DaemonStdioHelper(daemonProcess);
Expand All @@ -34,10 +31,7 @@ void main() {
group('daemon domain', () {
test('daemon is ready', () async {
final readyEvent = await daemonStdio.awaitForDaemonEvent('daemon.ready');
expect(
readyEvent.params?.keys,
containsAll(['version', 'processId']),
);
expect(readyEvent.params?.keys, containsAll(['version', 'processId']));
});

group('daemon responds to invalid messages', () {
Expand All @@ -46,10 +40,7 @@ void main() {
final protocolError = await daemonStdio.awaitForDaemonEvent(
'daemon.protocolError',
);
expect(
protocolError.params?['message'],
equals('Not a valid JSON'),
);
expect(protocolError.params?['message'], equals('Not a valid JSON'));
});

test('daemon process responds to invalid json', () async {
Expand Down Expand Up @@ -127,10 +118,7 @@ void main() {
),
);

expect(
response.result,
equals({'version': '0.0.1'}),
);
expect(response.result, equals({'version': '0.0.1'}));
});

test('daemon.kill', () async {
Expand Down
112 changes: 43 additions & 69 deletions packages/dart_frog_cli/e2e/test/daemon/dev_server_domain_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,8 @@ void main() {
var requestCount = 0;

setUpAll(() async {
await dartFrogCreate(
projectName: projectName1,
directory: tempDirectory,
);
await dartFrogCreate(
projectName: projectName2,
directory: tempDirectory,
);
await dartFrogCreate(projectName: projectName1, directory: tempDirectory);
await dartFrogCreate(projectName: projectName2, directory: tempDirectory);

daemonProcess = await dartFrogDaemonStart();
daemonStdio = DaemonStdioHelper(daemonProcess);
Expand Down Expand Up @@ -191,8 +185,9 @@ void main() {
);
});

testServer(port: project1Server2Port, 'GET / on project 1 server 2',
(host) async {
testServer(port: project1Server2Port, 'GET / on project 1 server 2', (
host,
) async {
final response = await http.get(Uri.parse(host));
expect(response.statusCode, equals(HttpStatus.ok));
expect(response.body, equals('Welcome to Dart Frog!'));
Expand All @@ -205,10 +200,7 @@ void main() {

test('modify files on project 2', () async {
final routesDirectory = Directory(
path.join(
projectDirectory2.path,
'routes',
),
path.join(projectDirectory2.path, 'routes'),
);

expect(fileAt('index.dart', on: routesDirectory), exists);
Expand All @@ -224,17 +216,16 @@ void main() {
id: '${++requestCount}',
domain: 'dev_server',
method: 'reload',
params: {
'applicationId': project2ServerId,
},
params: {'applicationId': project2ServerId},
),
);

expect(response.isSuccess, isTrue);
});

testServer(port: project2ServerPort, 'GET /new_route on project 2',
(host) async {
testServer(port: project2ServerPort, 'GET /new_route on project 2', (
host,
) async {
final response = await http.get(Uri.parse(host));
expect(response.statusCode, equals(HttpStatus.ok));
expect(response.headers, contains('date'));
Expand All @@ -245,27 +236,21 @@ void main() {
});

test('try staggered-stop a dev server on project 1', () async {
final (response1, response2) =
await daemonStdio.sendStaggeredDaemonRequest(
(
DaemonRequest(
id: '${++requestCount}',
domain: 'dev_server',
method: 'stop',
params: {
'applicationId': project1Server1Id,
},
),
DaemonRequest(
id: '${++requestCount}',
domain: 'dev_server',
method: 'stop',
params: {
'applicationId': project1Server1Id,
},
),
),
);
final (response1, response2) = await daemonStdio
.sendStaggeredDaemonRequest((
DaemonRequest(
id: '${++requestCount}',
domain: 'dev_server',
method: 'stop',
params: {'applicationId': project1Server1Id},
),
DaemonRequest(
id: '${++requestCount}',
domain: 'dev_server',
method: 'stop',
params: {'applicationId': project1Server1Id},
),
));

expect(response1.isSuccess, isTrue);
expect(response1.result!['exitCode'], equals(0));
Expand All @@ -278,9 +263,7 @@ void main() {
id: '${++requestCount}',
domain: 'dev_server',
method: 'stop',
params: {
'applicationId': project1Server1Id,
},
params: {'applicationId': project1Server1Id},
),
);

Expand All @@ -305,16 +288,15 @@ void main() {
});

testServer(
// TODO(renancaraujo): this fails on linux: https://github.com/VeryGoodOpenSource/dart_frog/issues/807
skip: Platform.isLinux,
'GET on project 1 server 1: connection refused', (host) async {
final responseFuture = http.get(Uri.parse(host));

await expectLater(
responseFuture,
throwsA(isA<SocketException>()),
);
});
// TODO(renancaraujo): this fails on linux: https://github.com/VeryGoodOpenSource/dart_frog/issues/807
skip: Platform.isLinux,
'GET on project 1 server 1: connection refused',
(host) async {
final responseFuture = http.get(Uri.parse(host));

await expectLater(responseFuture, throwsA(isA<SocketException>()));
},
);

testServer(
port: project2ServerPort,
Expand All @@ -325,12 +307,7 @@ void main() {
(host) async {
final responseFuture = http.get(Uri.parse(host));

await expectLater(
responseFuture,
throwsA(
isA<SocketException>(),
),
);
await expectLater(responseFuture, throwsA(isA<SocketException>()));
},
);

Expand All @@ -340,16 +317,13 @@ void main() {
// TODO(renancaraujo): this fails on linux: https://github.com/VeryGoodOpenSource/dart_frog/issues/807
skip: Platform.isLinux,
(host) async {
await expectLater(
() async {
final response = await http.get(Uri.parse(host));
stderr
..writeln(response.statusCode)
..writeln(response.body);
return response;
},
throwsA(isA<SocketException>()),
);
await expectLater(() async {
final response = await http.get(Uri.parse(host));
stderr
..writeln(response.statusCode)
..writeln(response.body);
return response;
}, throwsA(isA<SocketException>()));
},
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ void main() {
late String projectWatcherId;

setUpAll(() async {
await dartFrogCreate(
projectName: projectName,
directory: tempDirectory,
);
await dartFrogCreate(projectName: projectName, directory: tempDirectory);
daemonProcess = await dartFrogDaemonStart();

daemonStdio = DaemonStdioHelper(daemonProcess);
Expand All @@ -54,9 +51,7 @@ void main() {
id: '${++requestCount}',
domain: 'route_configuration',
method: 'watcherStart',
params: {
'workingDirectory': projectDirectory.path,
},
params: {'workingDirectory': projectDirectory.path},
),
);

Expand Down Expand Up @@ -164,9 +159,7 @@ void main() {
id: '${requestCount++}',
domain: 'route_configuration',
method: 'watcherGenerateRouteConfiguration',
params: {
'watcherId': projectWatcherId,
},
params: {'watcherId': projectWatcherId},
),
);

Expand Down Expand Up @@ -208,10 +201,7 @@ void main() {
containsPair('requestId', '1'),
containsPair(
'message',
allOf(
startsWith('[watcher] add'),
endsWith('rogue_route.dart'),
),
allOf(startsWith('[watcher] add'), endsWith('rogue_route.dart')),
),
),
timeout: const Duration(seconds: 5),
Expand All @@ -236,27 +226,21 @@ void main() {
});

test('staggered-stop watcher', () async {
final (response1, response2) =
await daemonStdio.sendStaggeredDaemonRequest(
(
DaemonRequest(
id: '${requestCount++}',
domain: 'route_configuration',
method: 'watcherStop',
params: {
'watcherId': projectWatcherId,
},
),
DaemonRequest(
id: '${requestCount++}',
domain: 'route_configuration',
method: 'watcherStop',
params: {
'watcherId': projectWatcherId,
},
),
),
);
final (response1, response2) = await daemonStdio
.sendStaggeredDaemonRequest((
DaemonRequest(
id: '${requestCount++}',
domain: 'route_configuration',
method: 'watcherStop',
params: {'watcherId': projectWatcherId},
),
DaemonRequest(
id: '${requestCount++}',
domain: 'route_configuration',
method: 'watcherStop',
params: {'watcherId': projectWatcherId},
),
));

expect(response1.isSuccess, isTrue);
expect(response1.result?['exitCode'], equals(0));
Expand Down
59 changes: 28 additions & 31 deletions packages/dart_frog_cli/e2e/test/dev_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,41 +63,38 @@ void main() {
tempDirectory.delete(recursive: true).ignore();
});

test(
'running two different dart_frog dev command will fail '
'when different dart vm port is not set',
() async {
final process1 = await dartFrogDev(
directory: Directory(path.join(tempDirectory.path, projectName1)),
test('running two different dart_frog dev command will fail '
'when different dart vm port is not set', () async {
final process1 = await dartFrogDev(
directory: Directory(path.join(tempDirectory.path, projectName1)),
);
addTearDown(() async {
await killDartFrogServer(process1.pid).ignoreErrors();
});

try {
final process2 = await dartFrogDev(
directory: Directory(path.join(tempDirectory.path, projectName2)),
exitOnError: false,
);
addTearDown(() async {
await killDartFrogServer(process1.pid).ignoreErrors();
await killDartFrogServer(process2.pid).ignoreErrors();
});

try {
final process2 = await dartFrogDev(
directory: Directory(path.join(tempDirectory.path, projectName2)),
exitOnError: false,
);
addTearDown(() async {
await killDartFrogServer(process2.pid).ignoreErrors();
});

fail('exception not thrown');
} catch (e) {
expect(e.toString(), contains('Could not start the VM service:'));

expect(
e.toString(),
contains(
'DartDevelopmentServiceException: Failed to create server socket',
),
);

expect(e.toString(), contains('127.0.0.1:8181'));
}
},
);
fail('exception not thrown');
} catch (e) {
expect(e.toString(), contains('Could not start the VM service:'));

expect(
e.toString(),
contains(
'DartDevelopmentServiceException: Failed to create server socket',
),
);

expect(e.toString(), contains('127.0.0.1:8181'));
}
});

test(
'runs two different dart_frog dev servers without any issues',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import 'dart:io';

import 'helpers.dart';

Future<void> dartFrogBuild({
required Directory directory,
}) async {
Future<void> dartFrogBuild({required Directory directory}) async {
await runProcess(
'dart_frog',
['build'],
Expand Down
Loading