From 419f6e5382d23b22f4b36dce029b26ba95368c29 Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Wed, 20 Apr 2016 14:29:18 -0700 Subject: [PATCH] add e2e tests for usage/compile errors --- pkg/dev_compiler/test/worker/worker_test.dart | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/pkg/dev_compiler/test/worker/worker_test.dart b/pkg/dev_compiler/test/worker/worker_test.dart index d2f4374d4dc2..25a868f7d6ca 100644 --- a/pkg/dev_compiler/test/worker/worker_test.dart +++ b/pkg/dev_compiler/test/worker/worker_test.dart @@ -103,8 +103,7 @@ main() { setUp(() { greetingDart.writeAsStringSync('String greeting = "hello";'); - helloDart.writeAsStringSync( - 'import "greeting.dart";' + helloDart.writeAsStringSync('import "greeting.dart";' 'main() => print(greeting);'); }); @@ -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 _readResponse(MessageGrouper messageGrouper) async {