| 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 import 'dart:math' as math; | 10 import 'dart:math' as math; |
| 11 | 11 |
| 12 import 'test_pub.dart'; | |
| 13 import '../../../pkg/http/lib/http.dart' as http; | 12 import '../../../pkg/http/lib/http.dart' as http; |
| 14 import '../../../pkg/http/lib/testing.dart'; | 13 import '../../../pkg/http/lib/testing.dart'; |
| 15 import '../../../pkg/path/lib/path.dart' as path; | 14 import '../../../pkg/path/lib/path.dart' as path; |
| 16 import '../../../pkg/unittest/lib/unittest.dart'; | 15 import '../../../pkg/unittest/lib/unittest.dart'; |
| 16 |
| 17 import 'test_pub.dart'; |
| 17 import '../../pub/entrypoint.dart'; | 18 import '../../pub/entrypoint.dart'; |
| 18 import '../../pub/io.dart'; | 19 import '../../pub/io.dart'; |
| 19 import '../../pub/validator.dart'; | 20 import '../../pub/validator.dart'; |
| 20 import '../../pub/validator/compiled_dartdoc.dart'; | 21 import '../../pub/validator/compiled_dartdoc.dart'; |
| 21 import '../../pub/validator/dependency.dart'; | 22 import '../../pub/validator/dependency.dart'; |
| 22 import '../../pub/validator/directory.dart'; | 23 import '../../pub/validator/directory.dart'; |
| 23 import '../../pub/validator/lib.dart'; | 24 import '../../pub/validator/lib.dart'; |
| 24 import '../../pub/validator/license.dart'; | 25 import '../../pub/validator/license.dart'; |
| 25 import '../../pub/validator/name.dart'; | 26 import '../../pub/validator/name.dart'; |
| 26 import '../../pub/validator/pubspec_field.dart'; | 27 import '../../pub/validator/pubspec_field.dart'; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 integration('looks normal', () { | 109 integration('looks normal', () { |
| 109 dir(appPath, [libPubspec("test_pkg", "1.0.0")]).scheduleCreate(); | 110 dir(appPath, [libPubspec("test_pkg", "1.0.0")]).scheduleCreate(); |
| 110 expectNoValidationError(dependency); | 111 expectNoValidationError(dependency); |
| 111 expectNoValidationError(lib); | 112 expectNoValidationError(lib); |
| 112 expectNoValidationError(license); | 113 expectNoValidationError(license); |
| 113 expectNoValidationError(name); | 114 expectNoValidationError(name); |
| 114 expectNoValidationError(pubspecField); | 115 expectNoValidationError(pubspecField); |
| 115 }); | 116 }); |
| 116 | 117 |
| 117 integration('has a COPYING file', () { | 118 integration('has a COPYING file', () { |
| 118 file(join(appPath, 'LICENSE'), '').scheduleDelete(); | 119 file(path.join(appPath, 'LICENSE'), '').scheduleDelete(); |
| 119 file(join(appPath, 'COPYING'), '').scheduleCreate(); | 120 file(path.join(appPath, 'COPYING'), '').scheduleCreate(); |
| 120 expectNoValidationError(license); | 121 expectNoValidationError(license); |
| 121 }); | 122 }); |
| 122 | 123 |
| 123 integration('has a prefixed LICENSE file', () { | 124 integration('has a prefixed LICENSE file', () { |
| 124 file(join(appPath, 'LICENSE'), '').scheduleDelete(); | 125 file(path.join(appPath, 'LICENSE'), '').scheduleDelete(); |
| 125 file(join(appPath, 'MIT_LICENSE'), '').scheduleCreate(); | 126 file(path.join(appPath, 'MIT_LICENSE'), '').scheduleCreate(); |
| 126 expectNoValidationError(license); | 127 expectNoValidationError(license); |
| 127 }); | 128 }); |
| 128 | 129 |
| 129 integration('has a suffixed LICENSE file', () { | 130 integration('has a suffixed LICENSE file', () { |
| 130 file(join(appPath, 'LICENSE'), '').scheduleDelete(); | 131 file(path.join(appPath, 'LICENSE'), '').scheduleDelete(); |
| 131 file(join(appPath, 'LICENSE.md'), '').scheduleCreate(); | 132 file(path.join(appPath, 'LICENSE.md'), '').scheduleCreate(); |
| 132 expectNoValidationError(license); | 133 expectNoValidationError(license); |
| 133 }); | 134 }); |
| 134 | 135 |
| 135 integration('has "authors" instead of "author"', () { | 136 integration('has "authors" instead of "author"', () { |
| 136 var pkg = package("test_pkg", "1.0.0"); | 137 var pkg = package("test_pkg", "1.0.0"); |
| 137 pkg["authors"] = [pkg.remove("author")]; | 138 pkg["authors"] = [pkg.remove("author")]; |
| 138 dir(appPath, [pubspec(pkg)]).scheduleCreate(); | 139 dir(appPath, [pubspec(pkg)]).scheduleCreate(); |
| 139 expectNoValidationError(pubspecField); | 140 expectNoValidationError(pubspecField); |
| 140 }); | 141 }); |
| 141 | 142 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 "Bob Nystrom <rnystrom@google.com>", | 266 "Bob Nystrom <rnystrom@google.com>", |
| 266 "<nweiz@google.com>", | 267 "<nweiz@google.com>", |
| 267 "John Messerly <jmesserly@google.com>" | 268 "John Messerly <jmesserly@google.com>" |
| 268 ]; | 269 ]; |
| 269 dir(appPath, [pubspec(pkg)]).scheduleCreate(); | 270 dir(appPath, [pubspec(pkg)]).scheduleCreate(); |
| 270 | 271 |
| 271 expectValidationWarning(pubspecField); | 272 expectValidationWarning(pubspecField); |
| 272 }); | 273 }); |
| 273 | 274 |
| 274 integration('has no LICENSE file', () { | 275 integration('has no LICENSE file', () { |
| 275 file(join(appPath, 'LICENSE'), '').scheduleDelete(); | 276 file(path.join(appPath, 'LICENSE'), '').scheduleDelete(); |
| 276 expectValidationError(license); | 277 expectValidationError(license); |
| 277 }); | 278 }); |
| 278 | 279 |
| 279 integration('has an empty package name', () { | 280 integration('has an empty package name', () { |
| 280 dir(appPath, [libPubspec("", "1.0.0")]).scheduleCreate(); | 281 dir(appPath, [libPubspec("", "1.0.0")]).scheduleCreate(); |
| 281 expectValidationError(name); | 282 expectValidationError(name); |
| 282 }); | 283 }); |
| 283 | 284 |
| 284 integration('has a package name with an invalid character', () { | 285 integration('has a package name with an invalid character', () { |
| 285 dir(appPath, [libPubspec("test-pkg", "1.0.0")]).scheduleCreate(); | 286 dir(appPath, [libPubspec("test-pkg", "1.0.0")]).scheduleCreate(); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 | 328 |
| 328 integration('has a library name that is a Dart reserved word', () { | 329 integration('has a library name that is a Dart reserved word', () { |
| 329 dir(appPath, [ | 330 dir(appPath, [ |
| 330 libPubspec("test_pkg", "1.0.0"), | 331 libPubspec("test_pkg", "1.0.0"), |
| 331 dir("lib", [file("operator.dart", "int i = 0;")]) | 332 dir("lib", [file("operator.dart", "int i = 0;")]) |
| 332 ]).scheduleCreate(); | 333 ]).scheduleCreate(); |
| 333 expectValidationError(name); | 334 expectValidationError(name); |
| 334 }); | 335 }); |
| 335 | 336 |
| 336 integration('has a single library named differently than the package', () { | 337 integration('has a single library named differently than the package', () { |
| 337 file(join(appPath, "lib", "test_pkg.dart"), '').scheduleDelete(); | 338 file(path.join(appPath, "lib", "test_pkg.dart"), '').scheduleDelete(); |
| 338 dir(appPath, [ | 339 dir(appPath, [ |
| 339 dir("lib", [file("best_pkg.dart", "int i = 0;")]) | 340 dir("lib", [file("best_pkg.dart", "int i = 0;")]) |
| 340 ]).scheduleCreate(); | 341 ]).scheduleCreate(); |
| 341 expectValidationWarning(name); | 342 expectValidationWarning(name); |
| 342 }); | 343 }); |
| 343 | 344 |
| 344 integration('has no lib directory', () { | 345 integration('has no lib directory', () { |
| 345 dir(join(appPath, "lib")).scheduleDelete(); | 346 dir(path.join(appPath, "lib")).scheduleDelete(); |
| 346 expectValidationError(lib); | 347 expectValidationError(lib); |
| 347 }); | 348 }); |
| 348 | 349 |
| 349 integration('has an empty lib directory', () { | 350 integration('has an empty lib directory', () { |
| 350 file(join(appPath, "lib", "test_pkg.dart"), '').scheduleDelete(); | 351 file(path.join(appPath, "lib", "test_pkg.dart"), '').scheduleDelete(); |
| 351 expectValidationError(lib); | 352 expectValidationError(lib); |
| 352 }); | 353 }); |
| 353 | 354 |
| 354 integration('has a lib directory containing only src', () { | 355 integration('has a lib directory containing only src', () { |
| 355 file(join(appPath, "lib", "test_pkg.dart"), '').scheduleDelete(); | 356 file(path.join(appPath, "lib", "test_pkg.dart"), '').scheduleDelete(); |
| 356 dir(appPath, [ | 357 dir(appPath, [ |
| 357 dir("lib", [ | 358 dir("lib", [ |
| 358 dir("src", [file("test_pkg.dart", "int i = 0;")]) | 359 dir("src", [file("test_pkg.dart", "int i = 0;")]) |
| 359 ]) | 360 ]) |
| 360 ]).scheduleCreate(); | 361 ]).scheduleCreate(); |
| 361 expectValidationError(lib); | 362 expectValidationError(lib); |
| 362 }); | 363 }); |
| 363 | 364 |
| 364 group('has a git dependency', () { | 365 group('has a git dependency', () { |
| 365 group('where a hosted version exists', () { | 366 group('where a hosted version exists', () { |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 }); | 576 }); |
| 576 | 577 |
| 577 test('has a README with invalid utf-8', () { | 578 test('has a README with invalid utf-8', () { |
| 578 dir(appPath, [ | 579 dir(appPath, [ |
| 579 binaryFile("README", [192]) | 580 binaryFile("README", [192]) |
| 580 ]).scheduleCreate(); | 581 ]).scheduleCreate(); |
| 581 expectValidationWarning(utf8Readme); | 582 expectValidationWarning(utf8Readme); |
| 582 }); | 583 }); |
| 583 }); | 584 }); |
| 584 } | 585 } |
| OLD | NEW |