Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 | 4 |
| 5 library message_extraction_test; | 5 library message_extraction_test; |
| 6 | 6 |
| 7 import 'package:unittest/unittest.dart'; | 7 import 'package:unittest/unittest.dart'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 import 'dart:async'; | 9 import 'dart:async'; |
| 10 import 'package:pathos/path.dart' as path; | 10 import 'package:pathos/path.dart' as path; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 48 * Translate a file path into this test directory, regardless of the | 48 * Translate a file path into this test directory, regardless of the |
| 49 * working directory. | 49 * working directory. |
| 50 */ | 50 */ |
| 51 String dir([String s]) => | 51 String dir([String s]) => |
| 52 path.join(intlDirectory, 'test', 'message_extraction', s); | 52 path.join(intlDirectory, 'test', 'message_extraction', s); |
| 53 | 53 |
| 54 main() { | 54 main() { |
| 55 test("Test round trip message extraction, translation, code generation, " | 55 test("Test round trip message extraction, translation, code generation, " |
| 56 "and printing", () { | 56 "and printing", () { |
| 57 deleteGeneratedFiles(); | 57 deleteGeneratedFiles(); |
| 58 extractMessages(null).then((result) { | 58 return runTheTest(); |
|
Emily Fortuna
2013/03/19 20:31:37
if you just add a return statement at this line:
r
Alan Knight
2013/03/19 20:53:46
Done.
| |
| 59 return generateTranslationFiles(result); | |
| 60 }).then((result) { | |
| 61 return generateCodeFromTranslation(result); | |
| 62 }).then((result) { | |
| 63 return runGeneratedCode(result); | |
| 64 }).then(verifyResult); | |
| 65 }); | 59 }); |
| 66 } | 60 } |
| 67 | 61 |
| 62 Future runTheTest() { | |
| 63 return extractMessages(null).then((result) { | |
| 64 return generateTranslationFiles(result); | |
| 65 }).then((result) { | |
| 66 return generateCodeFromTranslation(result); | |
| 67 }).then((result) { | |
| 68 return runGeneratedCode(result); | |
| 69 }).then(verifyResult); | |
| 70 } | |
| 71 | |
| 68 void deleteGeneratedFiles() { | 72 void deleteGeneratedFiles() { |
| 69 var files = [dir('intl_messages.json'), dir('translation_fr.json'), | 73 var files = [dir('intl_messages.json'), dir('translation_fr.json'), |
| 70 dir('messages_fr.dart'), dir('message_de_DE.dart'), | 74 dir('messages_fr.dart'), dir('message_de_DE.dart'), |
| 71 dir('messages_all.dart')]; | 75 dir('messages_all.dart')]; |
| 72 files.map((name) => new File(name)).forEach((x) { | 76 files.map((name) => new File(name)).forEach((x) { |
| 73 if (x.existsSync()) x.deleteSync();}); | 77 if (x.existsSync()) x.deleteSync();}); |
| 74 } | 78 } |
| 75 | 79 |
| 76 /** | 80 /** |
| 77 * Run the process with the given list of filenames, which we assume | 81 * Run the process with the given list of filenames, which we assume |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 Future<ProcessResult> generateCodeFromTranslation(ProcessResult previousResult) | 121 Future<ProcessResult> generateCodeFromTranslation(ProcessResult previousResult) |
| 118 => run( | 122 => run( |
| 119 previousResult, | 123 previousResult, |
| 120 ['generate_from_json.dart', 'sample_with_messages.dart', | 124 ['generate_from_json.dart', 'sample_with_messages.dart', |
| 121 'part_of_sample_with_messages.dart', 'translation_fr.json', | 125 'part_of_sample_with_messages.dart', 'translation_fr.json', |
| 122 'translation_de_DE.json' ]); | 126 'translation_de_DE.json' ]); |
| 123 | 127 |
| 124 Future<ProcessResult> runGeneratedCode(ProcessResult previousResult) => | 128 Future<ProcessResult> runGeneratedCode(ProcessResult previousResult) => |
| 125 run(previousResult, ['sample_with_messages.dart']); | 129 run(previousResult, ['sample_with_messages.dart']); |
| 126 | 130 |
| 127 void verifyResult(results) { | 131 verifyResult(results) { |
| 128 var lineIterator; | 132 var lineIterator; |
| 129 verify(String s) { | 133 verify(String s) { |
| 130 lineIterator.moveNext(); | 134 lineIterator.moveNext(); |
| 131 var value = lineIterator.current; | 135 var value = lineIterator.current; |
| 132 expect(value, s); | 136 expect(value, s); |
| 133 } | 137 } |
| 134 | 138 |
| 135 var output = results.stdout; | 139 var output = results.stdout; |
| 136 var lines = output.split("\n"); | 140 var lines = output.split("\n"); |
| 137 // If it looks like these are CRLF delimited, then use that. Wish strings | 141 // If it looks like these are CRLF delimited, then use that. Wish strings |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 213 verify("Diese Methode ist nicht eine Lambda"); | 217 verify("Diese Methode ist nicht eine Lambda"); |
| 214 verify("Dies ergibt sich aus einer statischen Methode"); | 218 verify("Dies ergibt sich aus einer statischen Methode"); |
| 215 verify("This is missing some translations"); | 219 verify("This is missing some translations"); |
| 216 verify("Antike griechische Galgenmännchen Zeichen: 𐅆𐅇"); | 220 verify("Antike griechische Galgenmännchen Zeichen: 𐅆𐅇"); |
| 217 // verify("Die Sache ist, well"); | 221 // verify("Die Sache ist, well"); |
| 218 // expect("Einer der knifflige Dinge ist der Plural"); | 222 // expect("Einer der knifflige Dinge ist der Plural"); |
| 219 // expect("Zu den kniffligen Dinge Pluralformen"); | 223 // expect("Zu den kniffligen Dinge Pluralformen"); |
| 220 verify("Escapes: "); | 224 verify("Escapes: "); |
| 221 verify("\r\f\b\t\v."); | 225 verify("\r\f\b\t\v."); |
| 222 } | 226 } |
| OLD | NEW |