| OLD | NEW |
| 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_test; | 5 library validator_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 import 'dart:json' as json; | 9 import 'dart:json' as json; |
| 10 | 10 |
| 11 import 'test_pub.dart'; | 11 import 'test_pub.dart'; |
| 12 import '../../../pkg/unittest/lib/unittest.dart'; | 12 import '../../../pkg/unittest/lib/unittest.dart'; |
| 13 import '../../../pkg/http/lib/http.dart' as http; | 13 import '../../../pkg/http/lib/http.dart' as http; |
| 14 import '../../../pkg/http/lib/testing.dart'; | 14 import '../../../pkg/http/lib/testing.dart'; |
| 15 import '../../pub/entrypoint.dart'; | 15 import '../../pub/entrypoint.dart'; |
| 16 import '../../pub/io.dart'; | 16 import '../../pub/io.dart'; |
| 17 import '../../pub/validator.dart'; | 17 import '../../pub/validator.dart'; |
| 18 import '../../pub/validator/compiled_dartdoc.dart'; |
| 18 import '../../pub/validator/dependency.dart'; | 19 import '../../pub/validator/dependency.dart'; |
| 19 import '../../pub/validator/directory.dart'; | 20 import '../../pub/validator/directory.dart'; |
| 20 import '../../pub/validator/lib.dart'; | 21 import '../../pub/validator/lib.dart'; |
| 21 import '../../pub/validator/license.dart'; | 22 import '../../pub/validator/license.dart'; |
| 22 import '../../pub/validator/name.dart'; | 23 import '../../pub/validator/name.dart'; |
| 23 import '../../pub/validator/pubspec_field.dart'; | 24 import '../../pub/validator/pubspec_field.dart'; |
| 24 | 25 |
| 25 void expectNoValidationError(ValidatorCreator fn) { | 26 void expectNoValidationError(ValidatorCreator fn) { |
| 26 expectLater(schedulePackageValidation(fn), pairOf(isEmpty, isEmpty)); | 27 expectLater(schedulePackageValidation(fn), pairOf(isEmpty, isEmpty)); |
| 27 } | 28 } |
| 28 | 29 |
| 29 void expectValidationError(ValidatorCreator fn) { | 30 void expectValidationError(ValidatorCreator fn) { |
| 30 expectLater(schedulePackageValidation(fn), pairOf(isNot(isEmpty), anything)); | 31 expectLater(schedulePackageValidation(fn), pairOf(isNot(isEmpty), anything)); |
| 31 } | 32 } |
| 32 | 33 |
| 33 void expectValidationWarning(ValidatorCreator fn) { | 34 void expectValidationWarning(ValidatorCreator fn) { |
| 34 expectLater(schedulePackageValidation(fn), pairOf(isEmpty, isNot(isEmpty))); | 35 expectLater(schedulePackageValidation(fn), pairOf(isEmpty, isNot(isEmpty))); |
| 35 } | 36 } |
| 36 | 37 |
| 38 Validator compiledDartdoc(Entrypoint entrypoint) => |
| 39 new CompiledDartdocValidator(entrypoint); |
| 40 |
| 37 Validator dependency(Entrypoint entrypoint) => | 41 Validator dependency(Entrypoint entrypoint) => |
| 38 new DependencyValidator(entrypoint); | 42 new DependencyValidator(entrypoint); |
| 39 | 43 |
| 40 Validator directory(Entrypoint entrypoint) => | 44 Validator directory(Entrypoint entrypoint) => |
| 41 new DirectoryValidator(entrypoint); | 45 new DirectoryValidator(entrypoint); |
| 42 | 46 |
| 43 Validator lib(Entrypoint entrypoint) => new LibValidator(entrypoint); | 47 Validator lib(Entrypoint entrypoint) => new LibValidator(entrypoint); |
| 44 | 48 |
| 45 Validator license(Entrypoint entrypoint) => new LicenseValidator(entrypoint); | 49 Validator license(Entrypoint entrypoint) => new LicenseValidator(entrypoint); |
| 46 | 50 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 ]).scheduleCreate(); | 122 ]).scheduleCreate(); |
| 119 expectNoValidationError(dependency); | 123 expectNoValidationError(dependency); |
| 120 }); | 124 }); |
| 121 | 125 |
| 122 integration('has a nested directory named "tools"', () { | 126 integration('has a nested directory named "tools"', () { |
| 123 dir(appPath, [ | 127 dir(appPath, [ |
| 124 dir("foo", [dir("tools")]) | 128 dir("foo", [dir("tools")]) |
| 125 ]).scheduleCreate(); | 129 ]).scheduleCreate(); |
| 126 expectNoValidationError(directory); | 130 expectNoValidationError(directory); |
| 127 }); | 131 }); |
| 132 |
| 133 integration('has most but not all files from compiling dartdoc', () { |
| 134 dir(appPath, [ |
| 135 dir("doc-out", [ |
| 136 file("nav.json", ""), |
| 137 file("index.html", ""), |
| 138 file("styles.css", ""), |
| 139 file("dart-logo-small.png", "") |
| 140 ]) |
| 141 ]).scheduleCreate(); |
| 142 expectNoValidationError(compiledDartdoc); |
| 143 }); |
| 128 }); | 144 }); |
| 129 | 145 |
| 130 group('should consider a package invalid if it', () { | 146 group('should consider a package invalid if it', () { |
| 131 setUp(scheduleNormalPackage); | 147 setUp(scheduleNormalPackage); |
| 132 | 148 |
| 133 integration('is missing the "homepage" field', () { | 149 integration('is missing the "homepage" field', () { |
| 134 var package = package("test_pkg", "1.0.0"); | 150 var package = package("test_pkg", "1.0.0"); |
| 135 package.remove("homepage"); | 151 package.remove("homepage"); |
| 136 dir(appPath, [pubspec(package)]).scheduleCreate(); | 152 dir(appPath, [pubspec(package)]).scheduleCreate(); |
| 137 | 153 |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 setUp(scheduleNormalPackage); | 529 setUp(scheduleNormalPackage); |
| 514 | 530 |
| 515 var names = ["tools", "tests", "docs", "examples", "sample", "samples"]; | 531 var names = ["tools", "tests", "docs", "examples", "sample", "samples"]; |
| 516 for (var name in names) { | 532 for (var name in names) { |
| 517 integration('"$name"', () { | 533 integration('"$name"', () { |
| 518 dir(appPath, [dir(name)]).scheduleCreate(); | 534 dir(appPath, [dir(name)]).scheduleCreate(); |
| 519 expectValidationWarning(directory); | 535 expectValidationWarning(directory); |
| 520 }); | 536 }); |
| 521 } | 537 } |
| 522 }); | 538 }); |
| 539 |
| 540 test('contains compiled dartdoc', () { |
| 541 dir(appPath, [ |
| 542 dir('doc-out', [ |
| 543 file('nav.json', ''), |
| 544 file('index.html', ''), |
| 545 file('styles.css', ''), |
| 546 file('dart-logo-small.png', ''), |
| 547 file('client-live-nav.js', '') |
| 548 ]) |
| 549 ]).scheduleCreate(); |
| 550 |
| 551 expectValidationWarning(compiledDartdoc); |
| 552 }); |
| 523 }); | 553 }); |
| 524 } | 554 } |
| OLD | NEW |