@@ -9,32 +9,36 @@ import 'package:test/test.dart';
9
9
// https://github.com/getsentry/sentry-dart/issues/1893
10
10
void main () {
11
11
group ('Compile example_web' , () {
12
- test ('dart pub get should run successfully' , () async {
13
- final result = await _runProcess ('dart pub get' ,
14
- workingDirectory: _exampleWebWorkingDir);
15
- expect (result.exitCode, 0 ,
16
- reason: 'Could run `dart pub get` for example_web. '
17
- 'Likely caused by outdated dependencies' );
18
- });
19
- test ('dart run build_runner build should run successfully' , () async {
20
- // running this test locally require clean working directory
21
- final cleanResult = await _runProcess ('dart run build_runner clean' ,
22
- workingDirectory: _exampleWebWorkingDir);
23
- expect (cleanResult.exitCode, 0 );
24
- final result = await _runProcess (
25
- 'dart run build_runner build -r web -o build --delete-conflicting-outputs' ,
26
- workingDirectory: _exampleWebWorkingDir);
27
- expect (result.exitCode, 0 ,
28
- reason: 'Could not compile example_web project' );
29
- expect (
30
- result.stdout,
31
- isNot (contains (
32
- 'Skipping compiling sentry_dart_web_example|web/main.dart' )),
33
- reason:
34
- 'Could not compile main.dart, likely because of dart:io import.' );
35
- expect (result.stdout,
36
- contains ('build_web_compilers:entrypoint on web/main.dart:Compiled' ));
37
- });
12
+ test (
13
+ 'dart pub get and compilation should run successfully' ,
14
+ () async {
15
+ final result = await _runProcess ('dart pub get' ,
16
+ workingDirectory: _exampleWebWorkingDir);
17
+ expect (result.exitCode, 0 ,
18
+ reason: 'Could run `dart pub get` for example_web. '
19
+ 'Likely caused by outdated dependencies' );
20
+ // running this test locally require clean working directory
21
+ final cleanResult = await _runProcess ('dart run build_runner clean' ,
22
+ workingDirectory: _exampleWebWorkingDir);
23
+ expect (cleanResult.exitCode, 0 );
24
+ final compileResult = await _runProcess (
25
+ 'dart run build_runner build -r web -o build --delete-conflicting-outputs' ,
26
+ workingDirectory: _exampleWebWorkingDir);
27
+ expect (compileResult.exitCode, 0 ,
28
+ reason: 'Could not compile example_web project' );
29
+ expect (
30
+ compileResult.stdout,
31
+ isNot (contains (
32
+ 'Skipping compiling sentry_dart_web_example|web/main.dart' )),
33
+ reason:
34
+ 'Could not compile main.dart, likely because of dart:io import.' );
35
+ expect (
36
+ compileResult.stdout,
37
+ contains (
38
+ 'build_web_compilers:entrypoint on web/main.dart:Compiled' ));
39
+ },
40
+ timeout: Timeout (const Duration (minutes: 1 )), // double of detault timeout
41
+ );
38
42
});
39
43
}
40
44
@@ -53,17 +57,25 @@ Future<_CommandResult> _runProcess(String command,
53
57
// forward standard streams
54
58
unawaited (stderr.addStream (process.stderr));
55
59
final buffer = < int > [];
56
- await for (final units in process.stdout) {
57
- buffer.addAll (units);
58
- stdout.add (units);
59
- }
60
+ final stdoutCompleter = Completer .sync ();
61
+ process.stdout.listen (
62
+ (units) {
63
+ buffer.addAll (units);
64
+ stdout.add (units);
65
+ },
66
+ cancelOnError: true ,
67
+ onDone: () {
68
+ stdoutCompleter.complete ();
69
+ },
70
+ );
71
+ await stdoutCompleter.future;
60
72
final processOut = utf8.decode (buffer);
61
73
int exitCode = await process.exitCode;
62
74
return _CommandResult (exitCode: exitCode, stdout: processOut);
63
75
}
64
76
65
77
String get _exampleWebWorkingDir {
66
- return Directory .current.uri. resolve ( './ example_web'). normalizePath ().path ;
78
+ return '${ Directory .current .path }${ Platform . pathSeparator } example_web' ;
67
79
}
68
80
69
81
class _CommandResult {
0 commit comments