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

Side by Side Diff: utils/testrunner/utils.dart

Issue 11093033: Added ability to have custom test HTTP server handlers in the test directories. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 part of testrunner; 5 part of testrunner;
6 6
7 /** 7 /**
8 * Read the contents of a file [fileName] into a [List] of [String]s. 8 * Read the contents of a file [fileName] into a [List] of [String]s.
9 * If the file does not exist and [errorIfNoFile] is true, throw an 9 * If the file does not exist and [errorIfNoFile] is true, throw an
10 * exception, else return an empty list. 10 * exception, else return an empty list.
(...skipping 21 matching lines...) Expand all
32 } else { 32 } else {
33 var cwd = new Path((new Directory.current()).path); 33 var cwd = new Path((new Directory.current()).path);
34 return cwd.join(p).toString(); 34 return cwd.join(p).toString();
35 } 35 }
36 } 36 }
37 37
38 /** 38 /**
39 * Create the list of all the files in a set of directories 39 * Create the list of all the files in a set of directories
40 * ([dirs]) whose names match [filePat]. If [recurse] is true 40 * ([dirs]) whose names match [filePat]. If [recurse] is true
41 * look at subdirectories too. Once they have all been enumerated, 41 * look at subdirectories too. Once they have all been enumerated,
42 * call [onComplete]. 42 * call [onComplete]. An optional [excludePat] can be supplied
43 * and files or directories that match that will be excluded.
44 * If [symLinks] is false, symlinks will be excluded.
Siggi Cherem (dart-lang) 2012/10/10 17:51:32 I rather name the variable 'includeSymLinks' and r
gram 2012/10/17 00:03:28 Done.
43 */ 45 */
46 // TODO(gram): The key thing here is we want to avoid package
47 // directories, which have symlinks. excludePat was added for
48 // that but can't currently be used because the symlinked files
49 // have canonicalized paths. So instead we exploit that fact and
50 // assert that every file must have a prefix that matches the
51 // directory. If this changes then we will need to switch to using
52 // the exclude pattern or some other mechanism.
53 //
54
44 void buildFileList(List dirs, RegExp filePat, bool recurse, 55 void buildFileList(List dirs, RegExp filePat, bool recurse,
45 Function onComplete) { 56 Function onComplete,
57 [RegExp excludePat, bool symLinks = false]) {
46 var files = new List(); 58 var files = new List();
47 var dirCount = 1; 59 var dirCount = 1;
48 for (var i = 0; i < dirs.length; i++) { 60 for (var i = 0; i < dirs.length; i++) {
49 var path = dirs[i]; 61 var path = dirs[i];
62 if (excludePat != null && excludePat.hasMatch(path)) {
63 continue;
64 }
50 // Is this a regular file? 65 // Is this a regular file?
51 File f = new File(path); 66 File f = new File(path);
52 if (f.existsSync()) { 67 if (f.existsSync()) {
53 if (filePat.hasMatch(path)) { 68 if (filePat.hasMatch(path)) {
54 files.add(path); 69 files.add(path);
55 } 70 }
56 } else { // Try treat it as a directory. 71 } else { // Try treat it as a directory.
72 path = makePathAbsolute(path);
57 Directory d = new Directory(path); 73 Directory d = new Directory(path);
58 if (d.existsSync()) { 74 if (d.existsSync()) {
59 ++dirCount; 75 ++dirCount;
60 var lister = d.list(recursive: recurse); 76 var lister = d.list(recursive: recurse);
61 lister.onFile = (file) { 77 lister.onFile = (file) {
62 if (filePat.hasMatch(file)) { 78 if (filePat.hasMatch(file)) {
63 files.add(file); 79 if (excludePat == null || !excludePat.hasMatch(file)) {
80 if (symLinks || file.startsWith(path)) {
81 files.add(file);
82 }
83 }
64 } 84 }
65 }; 85 };
66 lister.onDone = (complete) { 86 lister.onDone = (complete) {
67 if (complete && --dirCount == 0) { 87 if (complete && --dirCount == 0) {
68 onComplete(files); 88 onComplete(files);
69 } 89 }
70 }; 90 };
71 } else { // Does not exist. 91 } else { // Does not exist.
72 print('$path does not exist.'); 92 print('$path does not exist.');
73 } 93 }
74 } 94 }
75 } 95 }
76 if (--dirCount == 0) { 96 if (--dirCount == 0) {
77 onComplete(files); 97 onComplete(files);
78 } 98 }
79 } 99 }
80 100
81 /** 101 /**
82 * Get the directory that testrunner lives in; we need it to import 102 * Get the directory that testrunner lives in; we need it to import
83 * support files into the generated scripts. 103 * support files into the generated scripts.
84 */ 104 */
85 105
86 String get runnerDirectory() { 106 String get runnerDirectory() {
87 var libDirectory = makePathAbsolute(new Options().script); 107 var libDirectory = makePathAbsolute(new Options().script);
88 return libDirectory.substring(0, 108 return libDirectory.substring(0,
89 libDirectory.lastIndexOf(Platform.pathSeparator)); 109 libDirectory.lastIndexOf(Platform.pathSeparator));
90 } 110 }
91 111
OLDNEW
« utils/testrunner/run_pipeline.dart ('K') | « utils/testrunner/testrunner.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698