Skip to content

Commit

Permalink
Merge pull request #515 from jakemac53/fix-up-usage-error-handling
Browse files Browse the repository at this point in the history
add e2e tests for usage/compile errors
  • Loading branch information
John Messerly committed Apr 20, 2016
2 parents 5e44564 + 419f6e5 commit 63666a7
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions pkg/dev_compiler/test/worker/worker_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ main() {

setUp(() {
greetingDart.writeAsStringSync('String greeting = "hello";');
helloDart.writeAsStringSync(
'import "greeting.dart";'
helloDart.writeAsStringSync('import "greeting.dart";'
'main() => print(greeting);');
});

Expand Down Expand Up @@ -148,6 +147,37 @@ main() {
expect(helloJS.existsSync(), isTrue);
});
});

group('Error handling', () {
final badFileDart = new File('test/worker/bad.dart').absolute;
final badFileJs = new File('test/worker/bad.js').absolute;

tearDown(() {
if (badFileDart.existsSync()) badFileDart.deleteSync();
if (badFileJs.existsSync()) badFileJs.deleteSync();
});

test('incorrect usage', () {
var result = Process.runSync('dart', ['bin/dartdevc.dart', 'oops',]);
expect(result.exitCode, 64);
expect(result.stdout, contains('Could not find a command named "oops"'));
expect(result.stdout, isNot(contains('#0')));
});

test('compile errors', () {
badFileDart.writeAsStringSync('main() => "hello world"');
var result = Process.runSync('dart', [
'bin/dartdevc.dart',
'compile',
'--no-source-map',
'-o',
badFileJs.path,
badFileDart.path,
]);
expect(result.exitCode, 1);
expect(result.stdout, contains("[error] Expected to find ';'"));
});
});
}

Future<WorkResponse> _readResponse(MessageGrouper messageGrouper) async {
Expand Down

0 comments on commit 63666a7

Please sign in to comment.