Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(285)

Unified Diff: test/worker/worker_test.dart

Issue 1930133002: Make parts hermetic, fixes #531 (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/compiler/compiler.dart ('k') | tool/sdk_expected_errors.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/worker/worker_test.dart
diff --git a/test/worker/worker_test.dart b/test/worker/worker_test.dart
index 25a868f7d6ca25783eaeadf88b2c5c6e509ecacf..2a5f0a7a0b2c612c2879aaed129dc5c7b3568725 100644
--- a/test/worker/worker_test.dart
+++ b/test/worker/worker_test.dart
@@ -12,6 +12,9 @@ import 'package:bazel_worker/src/async_message_grouper.dart';
import 'package:bazel_worker/testing.dart';
import 'package:test/test.dart';
+import 'package:dev_compiler/src/compiler/compiler.dart'
+ show missingPartErrorCode, unusedPartWarningCode;
+
main() {
group('Hello World', () {
final argsFile = new File('test/worker/hello_world.args').absolute;
@@ -178,6 +181,82 @@ main() {
expect(result.stdout, contains("[error] Expected to find ';'"));
});
});
+
+ group('Parts', () {
+ final partFile = new File('test/worker/greeting.dart').absolute;
+ final libraryFile = new File('test/worker/hello.dart').absolute;
+
+ final outJS = new File('test/worker/output.js').absolute;
+
+ setUp(() {
+ partFile.writeAsStringSync('part of hello;\n'
+ 'String greeting = "hello";');
+ libraryFile.writeAsStringSync('library hello;\n'
+ 'part "greeting.dart";\n'
+ 'main() => print(greeting);\n');
+ });
+
+ tearDown(() {
+ if (partFile.existsSync()) partFile.deleteSync();
+ if (libraryFile.existsSync()) libraryFile.deleteSync();
+ if (outJS.existsSync()) outJS.deleteSync();
+ });
+
+ test('works if part and library supplied', () {
+ var result = Process.runSync('dart', [
+ 'bin/dartdevc.dart',
+ 'compile',
+ '--no-summarize',
+ '--no-source-map',
+ '-o',
+ outJS.path,
+ partFile.path,
+ libraryFile.path,
+ ]);
+ expect(result.stdout, isEmpty);
+ expect(result.stderr, isEmpty);
+ expect(result.exitCode, 0);
+ expect(outJS.existsSync(), isTrue);
+ });
+
+ test('error if part is not supplied', () {
+ var result = Process.runSync('dart', [
+ 'bin/dartdevc.dart',
+ 'compile',
+ '--no-summarize',
+ '--no-source-map',
+ '-o',
+ outJS.path,
+ libraryFile.path,
+ ]);
+ expect(
+ result.stdout,
+ startsWith('[error] ${missingPartErrorCode.message} '
+ '(test/worker/greeting.dart, line 1, col 1)'));
+ expect(result.stderr, isEmpty);
+ expect(result.exitCode, 1);
+ expect(outJS.existsSync(), isFalse);
+ });
+
+ test('warning if part without library is supplied', () {
+ var result = Process.runSync('dart', [
+ 'bin/dartdevc.dart',
+ 'compile',
+ '--no-summarize',
+ '--no-source-map',
+ '-o',
+ outJS.path,
+ partFile.path,
+ ]);
+ expect(
+ result.stdout,
+ startsWith('[warning] ${unusedPartWarningCode.message} '
+ '(test/worker/greeting.dart, line 1, col 1)'));
+ expect(result.stderr, isEmpty);
+ expect(result.exitCode, 0);
+ expect(outJS.existsSync(), isTrue);
+ });
+ });
}
Future<WorkResponse> _readResponse(MessageGrouper messageGrouper) async {
« no previous file with comments | « lib/src/compiler/compiler.dart ('k') | tool/sdk_expected_errors.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698