Skip to content

Commit

Permalink
Fix the build on latest dev sdks (#3416)
Browse files Browse the repository at this point in the history
* use TypeError instead of NullThrownError

* skip tests checking for no output on stderr until dart-lang/sdk#50592 is resolved

* fix serve tests
  • Loading branch information
jakemac53 authored Dec 2, 2022
1 parent 776ea2c commit 5e4f4e1
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
6 changes: 5 additions & 1 deletion _test/test/common/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ Future<void> _startServer(String command, List<String> buildArgs,
}

final proc = _process = await Process.start(command, buildArgs);
unawaited(proc.exitCode.then((_) {
if (_process != null) _process = null;
}));
final stdOutLines = _stdOutLines = proc.stdout
.transform(utf8.decoder)
.transform(const LineSplitter())
Expand All @@ -92,8 +95,9 @@ Future<void> stopServer({bool? cleanUp}) async {
final process = _process;
if (process != null) {
expect(process.kill(), true);
await process.exitCode;
var exitCode = process.exitCode;
_process = null;
await exitCode;
}
_stdOutLines = null;

Expand Down
4 changes: 3 additions & 1 deletion _test/test/help_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ Future<void> _testHelpCommand(List<String> args, {String? checkContent}) async {
var result = await asyncResult;
expect(result.exitCode, equals(0),
reason: 'should give a successful exit code');
expect(result.stderr, isEmpty, reason: 'Should output nothing on stderr');
expect(result.stderr, isEmpty,
reason: 'Should output nothing on stderr',
skip: 'https://github.com/dart-lang/sdk/issues/50592');
expect(result.stdout, isNot(contains('"Unhandled exception"')),
reason: 'Should not print an unhandled exception');
if (checkContent != null) {
Expand Down
4 changes: 2 additions & 2 deletions _test/test/serve_integration_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ void main() {
var error = nextStdOutLine('Error compiling dartdevc module:'
'_test|test/common/message.sound.ddc.js');
var nextBuild = nextFailedBuild;
await replaceAllInFile(path, "'Hello World!'", '1');
await replaceAllInFile(path, "'Hello World!';", '1;');
await error;
await nextBuild;

nextBuild = nextSuccessfulBuild;
await replaceAllInFile(path, '1', "'Hello World!'");
await replaceAllInFile(path, '1;', "'Hello World!';");
await nextBuild;
await expectTestsPass();
});
Expand Down
2 changes: 1 addition & 1 deletion build_runner/lib/src/build_script_generate/bootstrap.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Future<int> generateAndRun(
errorPort = ReceivePort();
messagePort = ReceivePort();
errorListener = errorPort.listen((e) {
final error = e[0] as Object? ?? NullThrownError();
final error = e[0] as Object? ?? TypeError();
final trace = Trace.parse(e[1] as String? ?? '').terse;

handleUncaughtError(error, trace);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ builders:
]).create();

var result = await runPub('a', 'run', args: ['build_runner', 'build']);
expect(result.stderr, isEmpty);
expect(result.stderr, isEmpty,
skip: 'https://github.com/dart-lang/sdk/issues/50592');
expect(
result.stdout,
contains(
Expand All @@ -58,7 +59,8 @@ builders:
]).create();

var result = await runPub('a', 'run', args: ['build_runner', 'build']);
expect(result.stderr, isEmpty);
expect(result.stderr, isEmpty,
skip: 'https://github.com/dart-lang/sdk/issues/50592');
expect(
result.stdout,
isNot(contains(
Expand Down Expand Up @@ -87,7 +89,8 @@ builders:
''')
]).create();
var result = await runPub('a', 'run', args: ['build_runner', 'build']);
expect(result.stderr, isEmpty);
expect(result.stderr, isEmpty,
skip: 'https://github.com/dart-lang/sdk/issues/50592');
expect(result.stdout, contains('could not be parsed'));
});
});
Expand All @@ -103,7 +106,8 @@ global_options:
]).create();

var result = await runPub('a', 'run', args: ['build_runner', 'build']);
expect(result.stderr, isEmpty);
expect(result.stderr, isEmpty,
skip: 'https://github.com/dart-lang/sdk/issues/50592');
expect(
result.stdout,
allOf(
Expand Down

0 comments on commit 5e4f4e1

Please sign in to comment.