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

Side by Side Diff: tools/testing/dart/test_progress.dart

Issue 23714002: test.py: Print the warning about left-over dirs only for directories created using Directory.create… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 test_progress; 5 library test_progress;
6 6
7 import "dart:async";
7 import "dart:io"; 8 import "dart:io";
8 import "dart:io" as io; 9 import "dart:io" as io;
9 import "http_server.dart" as http_server; 10 import "http_server.dart" as http_server;
10 import "status_file_parser.dart"; 11 import "status_file_parser.dart";
11 import "test_runner.dart"; 12 import "test_runner.dart";
12 import "test_suite.dart"; 13 import "test_suite.dart";
13 import "utils.dart"; 14 import "utils.dart";
14 15
15 String _pad(String s, int length) { 16 String _pad(String s, int length) {
16 StringBuffer buffer = new StringBuffer(); 17 StringBuffer buffer = new StringBuffer();
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 if (_skippedCompilations > 0) { 321 if (_skippedCompilations > 0) {
321 print('\n$_skippedCompilations compilations were skipped because ' 322 print('\n$_skippedCompilations compilations were skipped because '
322 'the previous output was already up to date\n'); 323 'the previous output was already up to date\n');
323 } 324 }
324 } 325 }
325 } 326 }
326 327
327 class LeftOverTempDirPrinter extends EventListener { 328 class LeftOverTempDirPrinter extends EventListener {
328 final MIN_NUMBER_OF_TEMP_DIRS = 50; 329 final MIN_NUMBER_OF_TEMP_DIRS = 50;
329 330
330 Path _tempDir() { 331 static Directory _getTemporaryDirectory() {
331 // Dir will be located in the system temporary directory. 332 // Dir will be located in the system temporary directory.
332 var dir = new Directory('').createTempSync(); 333 var dir = new Directory('').createTempSync();
333 var path = new Path(dir.path).directoryPath; 334 var path = new Path(dir.path).directoryPath;
334 dir.deleteSync(); 335 dir.deleteSync();
335 return path; 336 return new Directory(path.toNativePath());
337 }
338
339 static RegExp _getTemporaryDirectoryRegexp() {
340 // These are the patterns of temporary directory names created by
341 // 'Directory.createTempSync()' on linux/macos and windows.
342 if (['macos', 'linux'].contains(Platform.operatingSystem)) {
343 return new RegExp(r'^temp_dir1_......$');
344 } else {
345 return new RegExp(r'tempdir-........-....-....-....-............$');
346 }
347 }
348
349 static Stream<Directory> getLeftOverTemporaryDirectories() {
350 var regExp = _getTemporaryDirectoryRegexp();
351 return _getTemporaryDirectory().list().where(
352 (FileSystemEntity fse) {
353 if (fse is Directory) {
354 if (regExp.hasMatch(new Path(fse.path).filename)) {
355 return true;
356 }
357 }
358 return false;
359 });
336 } 360 }
337 361
338 void allDone() { 362 void allDone() {
339 var count = 0; 363 getLeftOverTemporaryDirectories().length.then((int count) {
340 var systemTempDir = _tempDir(); 364 if (count > MIN_NUMBER_OF_TEMP_DIRS) {
341 var lister = new Directory(systemTempDir.toNativePath()).list().listen( 365 DebugLogger.warning("There are ${count} directories "
342 (FileSystemEntity fse) { 366 "in the system tempdir "
343 if (fse is Directory) count++; 367 "('${_getTemporaryDirectory().path}')! "
344 }, 368 "Maybe left over directories?\n");
345 onError: (error) {
346 DebugLogger.warning("Could not list temp directories, got: $error");
347 },
348 onDone: () {
349 if (count > MIN_NUMBER_OF_TEMP_DIRS) {
350 DebugLogger.warning("There are ${count} directories "
351 "in the system tempdir ('$systemTempDir')! "
352 "Maybe left over directories?\n");
353 } 369 }
370 }).catchError((error) {
371 DebugLogger.warning("Could not list temp directories, got: $error");
354 }); 372 });
355 } 373 }
356 } 374 }
357 375
358 class LineProgressIndicator extends EventListener { 376 class LineProgressIndicator extends EventListener {
359 void done(TestCase test) { 377 void done(TestCase test) {
360 var status = 'pass'; 378 var status = 'pass';
361 if (test.unexpectedOutput) { 379 if (test.unexpectedOutput) {
362 status = 'fail'; 380 status = 'fail';
363 } 381 }
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 return new VerboseProgressIndicator(startTime); 557 return new VerboseProgressIndicator(startTime);
540 case 'status': 558 case 'status':
541 return new ProgressIndicator(startTime); 559 return new ProgressIndicator(startTime);
542 case 'buildbot': 560 case 'buildbot':
543 return new BuildbotProgressIndicator(startTime); 561 return new BuildbotProgressIndicator(startTime);
544 default: 562 default:
545 assert(false); 563 assert(false);
546 break; 564 break;
547 } 565 }
548 } 566 }
OLDNEW
« no previous file with comments | « tools/test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698