| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 library failed_extraction_test; | 4 library failed_extraction_test; |
| 5 | 5 |
| 6 import "message_extraction_test.dart"; | 6 import "message_extraction_test.dart"; |
| 7 import "dart:io"; | 7 import "dart:io"; |
| 8 import "package:unittest/unittest.dart"; | 8 import "package:unittest/unittest.dart"; |
| 9 | 9 |
| 10 main() { | 10 main() { |
| 11 test("Expect warnings but successful extraction", () { | 11 test("Expect warnings but successful extraction", () { |
| 12 runTestWithWarnings(warningsAreErrors: false, expectedExitCode: 0); | 12 runTestWithWarnings(warningsAreErrors: false, expectedExitCode: 0); |
| 13 }); | 13 }); |
| 14 } | 14 } |
| 15 | 15 |
| 16 void runTestWithWarnings({bool warningsAreErrors, int expectedExitCode}) { | 16 const defaultFiles = |
| 17 const ["sample_with_messages.dart", "part_of_sample_with_messages.dart"]; |
| 18 |
| 19 void runTestWithWarnings({bool warningsAreErrors, int expectedExitCode, |
| 20 bool embeddedPlurals: true, List<String> sourceFiles: defaultFiles}) { |
| 17 | 21 |
| 18 void verify(ProcessResult result) { | 22 void verify(ProcessResult result) { |
| 19 try { | 23 try { |
| 20 expect(result.exitCode, expectedExitCode); | 24 expect(result.exitCode, expectedExitCode); |
| 21 } finally { | 25 } finally { |
| 22 deleteGeneratedFiles(); | 26 deleteGeneratedFiles(); |
| 23 } | 27 } |
| 24 } | 28 } |
| 25 | 29 |
| 26 copyFilesToTempDirectory(); | 30 copyFilesToTempDirectory(); |
| 27 var program = asTestDirPath("../../bin/extract_to_arb.dart"); | 31 var program = asTestDirPath("../../bin/extract_to_arb.dart"); |
| 28 var args = ["--output-dir=$tempDir"]; | 32 var args = ["--output-dir=$tempDir"]; |
| 29 if (warningsAreErrors) { | 33 if (warningsAreErrors) { |
| 30 args.add('--warnings-are-errors'); | 34 args.add('--warnings-are-errors'); |
| 31 } | 35 } |
| 32 var files = [asTempDirPath("sample_with_messages.dart"), asTempDirPath( | 36 if (!embeddedPlurals) { |
| 33 "part_of_sample_with_messages.dart"),]; | 37 args.add('--no-embedded-plurals'); |
| 38 } |
| 39 var files = sourceFiles.map(asTempDirPath).toList(); |
| 34 var allArgs = [program] | 40 var allArgs = [program] |
| 35 ..addAll(args) | 41 ..addAll(args) |
| 36 ..addAll(files); | 42 ..addAll(files); |
| 37 var callback = expectAsync(verify); | 43 var callback = expectAsync(verify); |
| 38 run(null, allArgs).then(callback); | 44 run(null, allArgs).then(callback); |
| 39 } | 45 } |
| OLD | NEW |