| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 library failed_extraction_test; |
| 5 |
| 1 import "message_extraction_test.dart"; | 6 import "message_extraction_test.dart"; |
| 2 import "dart:io"; | 7 import "dart:io"; |
| 3 import "package:unittest/unittest.dart"; | 8 import "package:unittest/unittest.dart"; |
| 4 | 9 |
| 5 main() { | 10 main() { |
| 6 run(null, ["extract_to_json.dart", | 11 test("Expect warnings but successful extraction", () { |
| 7 "sample_with_messages.dart", "part_of_sample_with_messages.dart"]) | 12 runTestWithWarnings(warningsAreErrors: false, expectedExitCode: 0); |
| 8 .then((ProcessResult result) { | |
| 9 expect(result.exitCode, 0); | |
| 10 }); | 13 }); |
| 11 run(null, ["extract_to_json.dart", "--warnings-are-errors", | 14 } |
| 12 "sample_with_messages.dart", "part_of_sample_with_messages.dart"]) | 15 |
| 13 .then((ProcessResult result) { | 16 void runTestWithWarnings({bool warningsAreErrors, int expectedExitCode}) { |
| 14 expect(result.exitCode, 1); | 17 |
| 15 }); | 18 void verify(ProcessResult result) { |
| 16 } | 19 try { |
| 20 expect(result.exitCode, expectedExitCode); |
| 21 } finally { |
| 22 deleteGeneratedFiles(); |
| 23 } |
| 24 } |
| 25 |
| 26 copyFilesToTempDirectory(); |
| 27 var program = asTestDirPath("extract_to_json.dart"); |
| 28 var args = ["--output-dir=$tempDir"]; |
| 29 if (warningsAreErrors) { |
| 30 args.add('--warnings-are-errors'); |
| 31 } |
| 32 var files = [asTempDirPath("sample_with_messages.dart"), asTempDirPath( |
| 33 "part_of_sample_with_messages.dart"),]; |
| 34 var allArgs = [program] |
| 35 ..addAll(args) |
| 36 ..addAll(files); |
| 37 var callback = expectAsync(verify); |
| 38 run(null, allArgs).then(callback); |
| 39 } |
| OLD | NEW |