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

Unified Diff: pkg/intl/test/message_extraction/message_extraction_test.dart

Issue 290073002: Use deferred loading for message catalogs. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Review fixes Created 6 years, 7 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 | « pkg/intl/pubspec.yaml ('k') | pkg/intl/test/message_extraction/sample_with_messages.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/intl/test/message_extraction/message_extraction_test.dart
diff --git a/pkg/intl/test/message_extraction/message_extraction_test.dart b/pkg/intl/test/message_extraction/message_extraction_test.dart
index 0402765784041f628e970f88f02ec593b16d4256..ec6c73ff96feed29750958bdeead7abcdb76190f 100644
--- a/pkg/intl/test/message_extraction/message_extraction_test.dart
+++ b/pkg/intl/test/message_extraction/message_extraction_test.dart
@@ -16,8 +16,18 @@ final dart = Platform.executable;
/** The VM arguments we were given, most important package-root. */
final vmArgs = Platform.executableArguments;
-var tempDir = Directory.systemTemp.createTempSync('message_extraction_test'
- ).path;
+/**
+ * For testing we move the files into a temporary directory so as not to leave
+ * generated files around after a failed test. For debugging, we omit that
+ * step if [useLocalDirectory] is true. The place we move them to is saved as
+ * [tempDir].
+ */
+String get tempDir => _tempDir == null ? _tempDir = _createTempDir() : _tempDir;
+var _tempDir;
+_createTempDir() => useLocalDirectory ? '.' :
+ Directory.systemTemp.createTempSync('message_extraction_test').path;
+
+var useLocalDirectory = false;
/**
* Translate a relative file path into this test directory. This is
@@ -41,7 +51,14 @@ String asTempDirPath([String s]) {
return path.join(tempDir, s);
}
-main() {
+main(arguments) {
+ // If debugging, use --local to avoid copying everything to temporary
+ // directories to make it even harder to debug. Note that this will also
+ // not delete the generated files, so may require manual cleanup.
+ if (arguments.contains("--local")) {
+ print("Testing using local directory for generated files");
+ useLocalDirectory = true;
+ }
setUp(copyFilesToTempDirectory);
test("Test round trip message extraction, translation, code generation, "
"and printing", () {
@@ -56,6 +73,7 @@ main() {
}
void copyFilesToTempDirectory() {
+ if (useLocalDirectory) return;
var files = [asTestDirPath('sample_with_messages.dart'),
asTestDirPath('part_of_sample_with_messages.dart'),
asTestDirPath('verify_messages.dart'),
@@ -68,6 +86,7 @@ void copyFilesToTempDirectory() {
}
void deleteGeneratedFiles() {
+ if (useLocalDirectory) return;
try {
var dir = new Directory(tempDir);
dir.listSync().forEach((x) => x.deleteSync());
« no previous file with comments | « pkg/intl/pubspec.yaml ('k') | pkg/intl/test/message_extraction/sample_with_messages.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698