Skip to content

Commit e7cddf7

Browse files
authored
test(dart_frog_cli): run e2e tests on os matrix (#72)
1 parent dfe5d49 commit e7cddf7

File tree

5 files changed

+35
-11
lines changed

5 files changed

+35
-11
lines changed

.github/workflows/dart_frog_cli.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ jobs:
2929
run:
3030
working-directory: packages/dart_frog_cli/e2e
3131

32-
runs-on: ubuntu-latest
32+
runs-on: ${{ matrix.os }}
33+
34+
strategy:
35+
fail-fast: false
36+
matrix:
37+
os: [macos-latest, windows-latest, ubuntu-latest]
3338

3439
steps:
3540
- name: 📚 Git Checkout

packages/dart_frog_cli/e2e/test/dev_smoke_test.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@ void main() {
1616
const projectName = 'example';
1717
final tempDirectory = Directory.systemTemp.createTempSync();
1818

19+
late Process process;
20+
1921
setUpAll(() async {
2022
await dartFrogCreate(projectName: projectName, directory: tempDirectory);
21-
await dartFrogDev(
23+
process = await dartFrogDev(
2224
directory: Directory(path.join(tempDirectory.path, projectName)),
2325
);
2426
});
2527

2628
tearDownAll(() async {
27-
await killDartFrogServer();
29+
await killDartFrogServer(process.pid);
2830
await tempDirectory.delete(recursive: true);
2931
});
3032

packages/dart_frog_cli/e2e/test/helpers/dart_frog_create.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Future<void> dartFrogCreate({
88
'dart_frog',
99
['create', projectName],
1010
workingDirectory: directory.path,
11+
runInShell: true,
1112
);
1213
if (result.exitCode != 0) {
1314
throw Exception('dart_frog create exited with code $exitCode');

packages/dart_frog_cli/e2e/test/helpers/dart_frog_dev.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ import 'dart:async';
22
import 'dart:convert';
33
import 'dart:io';
44

5-
Future<void> dartFrogDev({required Directory directory}) async {
6-
final completer = Completer<void>();
5+
Future<Process> dartFrogDev({required Directory directory}) async {
6+
final completer = Completer<Process>();
77

88
final process = await Process.start(
99
'dart_frog',
1010
['dev'],
1111
workingDirectory: directory.path,
12+
runInShell: true,
1213
);
1314

1415
late StreamSubscription stdoutSubscription;
@@ -19,7 +20,7 @@ Future<void> dartFrogDev({required Directory directory}) async {
1920
if (message.contains('Hot reload is enabled.')) {
2021
stdoutSubscription.cancel();
2122
stderrSubscription.cancel();
22-
completer.complete();
23+
completer.complete(process);
2324
}
2425
});
2526

@@ -31,5 +32,5 @@ Future<void> dartFrogDev({required Directory directory}) async {
3132
exit(1);
3233
});
3334

34-
await completer.future;
35+
return completer.future;
3536
}
Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
11
import 'dart:io';
22

3-
Future<void> killDartFrogServer() async {
4-
final result = await Process.run('pkill', ['-f', 'dart_frog']);
5-
if (result.exitCode != 0) {
6-
throw Exception('pkill -f dart_frog exited with code $exitCode');
3+
Future<void> killDartFrogServer(int pid) async {
4+
if (Platform.isWindows) {
5+
final result = await Process.run(
6+
'taskkill',
7+
['/F', '/T', '/PID', '$pid'],
8+
runInShell: true,
9+
);
10+
if (result.exitCode != 0) {
11+
throw Exception('taskkill /F /T /PID $pid exited with code $exitCode');
12+
}
13+
return;
14+
}
15+
16+
if (Platform.isLinux || Platform.isMacOS) {
17+
final result = await Process.run('pkill', ['-f', 'dart_frog']);
18+
if (result.exitCode != 0) {
19+
throw Exception('pkill -f dart_frog exited with code $exitCode');
20+
}
21+
return;
722
}
823
}

0 commit comments

Comments
 (0)