Skip to content

Commit

Permalink
Change the archive_test to be more robust if the pmtiles CLI is not a…
Browse files Browse the repository at this point in the history
…vailable.
  • Loading branch information
bramp committed Jan 29, 2024
1 parent fdd99d0 commit fc8ed3f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions packages/pmtiles_tests/test/archive_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class CountingReadAt implements ReadAt {
// the results to our library.
void main() async {
final port = await getUnusedPort(InternetAddress.loopbackIPv4);
late final Process process;
Process? process;
final client = http.Client();

final sampleDir = p.join(Directory.current.path, 'samples');
Expand All @@ -66,6 +66,7 @@ void main() async {
// We could consider allowing this to be set on the env.
final pmtiles =
Process.runSync('which', ['pmtiles']).stdout.toString().trim();

expect(pmtiles, isNotEmpty, reason: 'Could not find pmtiles binary');

// Invoke `pmtiles serve`.
Expand All @@ -82,19 +83,22 @@ void main() async {
);

// Wait until it prints 'Serving ... on port'
final stdout = process.stdout.transform(utf8.decoder).asBroadcastStream();
final stdout = process!.stdout.transform(utf8.decoder).asBroadcastStream();
await stdout.firstWhere((line) => line.contains('Serving'));

// Then ignore the rest
stdout.drain();

// Always print stderr
process.stderr.transform(utf8.decoder).forEach(print);
process!.stderr.transform(utf8.decoder).forEach(print);
});

tearDownAll(() async {
process.kill();
await process.exitCode;
expect(process, isNotNull,
reason: '`pmtiles serve` process was not started');

process!.kill();
await process!.exitCode;
});

/// Use the pmtiles server to get the tile, as a source of comparision
Expand Down

0 comments on commit fc8ed3f

Please sign in to comment.