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

Side by Side Diff: utils/pub/validator.dart

Issue 11543006: Add a validator that checks that the lib directory is not empty. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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 | « no previous file | utils/pub/validator/lib.dart » ('j') | utils/pub/validator/lib.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 library validator; 5 library validator;
6 6
7 import 'entrypoint.dart'; 7 import 'entrypoint.dart';
8 import 'log.dart' as log; 8 import 'log.dart' as log;
9 import 'io.dart'; 9 import 'io.dart';
10 import 'system_cache.dart'; 10 import 'system_cache.dart';
11 import 'utils.dart'; 11 import 'utils.dart';
12 import 'validator/lib.dart';
12 import 'validator/license.dart'; 13 import 'validator/license.dart';
13 import 'validator/name.dart'; 14 import 'validator/name.dart';
14 import 'validator/pubspec_field.dart'; 15 import 'validator/pubspec_field.dart';
15 16
16 /// The base class for validators that check whether a package is fit for 17 /// The base class for validators that check whether a package is fit for
17 /// uploading. Each validator should override [errors], [warnings], or both to 18 /// uploading. Each validator should override [errors], [warnings], or both to
18 /// return lists of errors or warnings to display to the user. Errors will cause 19 /// return lists of errors or warnings to display to the user. Errors will cause
19 /// the package not to be uploaded; warnings will require the user to confirm 20 /// the package not to be uploaded; warnings will require the user to confirm
20 /// the upload. 21 /// the upload.
21 abstract class Validator { 22 abstract class Validator {
(...skipping 11 matching lines...) Expand all
33 /// Validates the entrypoint, adding any errors and warnings to [errors] and 34 /// Validates the entrypoint, adding any errors and warnings to [errors] and
34 /// [warnings], respectively. 35 /// [warnings], respectively.
35 Future validate(); 36 Future validate();
36 37
37 /// Run all validators on the [entrypoint] package and print their results. 38 /// Run all validators on the [entrypoint] package and print their results.
38 /// The future will complete with the error and warning messages, 39 /// The future will complete with the error and warning messages,
39 /// respectively. 40 /// respectively.
40 static Future<Pair<List<String>, List<String>>> runAll( 41 static Future<Pair<List<String>, List<String>>> runAll(
41 Entrypoint entrypoint) { 42 Entrypoint entrypoint) {
42 var validators = [ 43 var validators = [
44 new LibValidator(entrypoint),
43 new LicenseValidator(entrypoint), 45 new LicenseValidator(entrypoint),
44 new NameValidator(entrypoint), 46 new NameValidator(entrypoint),
45 new PubspecFieldValidator(entrypoint) 47 new PubspecFieldValidator(entrypoint)
46 ]; 48 ];
47 49
48 // TODO(nweiz): The sleep 0 here forces us to go async. This works around 50 // TODO(nweiz): The sleep 0 here forces us to go async. This works around
49 // 3356, which causes a bug if all validators are (synchronously) using 51 // 3356, which causes a bug if all validators are (synchronously) using
50 // Future.immediate and an error is thrown before a handler is set up. 52 // Future.immediate and an error is thrown before a handler is set up.
51 return sleep(0).chain((_) { 53 return sleep(0).chain((_) {
52 return Futures.wait(validators.map((validator) => validator.validate())); 54 return Futures.wait(validators.map((validator) => validator.validate()));
(...skipping 14 matching lines...) Expand all
67 for (var warning in warnings) { 69 for (var warning in warnings) {
68 log.warning("* $warning"); 70 log.warning("* $warning");
69 } 71 }
70 log.warning(""); 72 log.warning("");
71 } 73 }
72 74
73 return new Pair<List<String>, List<String>>(errors, warnings); 75 return new Pair<List<String>, List<String>>(errors, warnings);
74 }); 76 });
75 } 77 }
76 } 78 }
OLDNEW
« no previous file with comments | « no previous file | utils/pub/validator/lib.dart » ('j') | utils/pub/validator/lib.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698