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