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; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 integration('looks normal', () { | 114 integration('looks normal', () { |
115 d.dir(appPath, [d.libPubspec("test_pkg", "1.0.0")]).create(); | 115 d.dir(appPath, [d.libPubspec("test_pkg", "1.0.0")]).create(); |
116 expectNoValidationError(dependency); | 116 expectNoValidationError(dependency); |
117 expectNoValidationError(lib); | 117 expectNoValidationError(lib); |
118 expectNoValidationError(license); | 118 expectNoValidationError(license); |
119 expectNoValidationError(name); | 119 expectNoValidationError(name); |
120 expectNoValidationError(pubspecField); | 120 expectNoValidationError(pubspecField); |
121 }); | 121 }); |
122 | 122 |
123 integration('has a COPYING file', () { | 123 integration('has a COPYING file', () { |
124 schedule(() => deleteFile(path.join(sandboxDir, appPath, 'LICENSE'))); | 124 schedule(() => deleteEntry(path.join(sandboxDir, appPath, 'LICENSE'))); |
125 d.file(path.join(appPath, 'COPYING'), '').create(); | 125 d.file(path.join(appPath, 'COPYING'), '').create(); |
126 expectNoValidationError(license); | 126 expectNoValidationError(license); |
127 }); | 127 }); |
128 | 128 |
129 integration('has a prefixed LICENSE file', () { | 129 integration('has a prefixed LICENSE file', () { |
130 schedule(() => deleteFile(path.join(sandboxDir, appPath, 'LICENSE'))); | 130 schedule(() => deleteEntry(path.join(sandboxDir, appPath, 'LICENSE'))); |
131 d.file(path.join(appPath, 'MIT_LICENSE'), '').create(); | 131 d.file(path.join(appPath, 'MIT_LICENSE'), '').create(); |
132 expectNoValidationError(license); | 132 expectNoValidationError(license); |
133 }); | 133 }); |
134 | 134 |
135 integration('has a suffixed LICENSE file', () { | 135 integration('has a suffixed LICENSE file', () { |
136 schedule(() => deleteFile(path.join(sandboxDir, appPath, 'LICENSE'))); | 136 schedule(() => deleteEntry(path.join(sandboxDir, appPath, 'LICENSE'))); |
137 d.file(path.join(appPath, 'LICENSE.md'), '').create(); | 137 d.file(path.join(appPath, 'LICENSE.md'), '').create(); |
138 expectNoValidationError(license); | 138 expectNoValidationError(license); |
139 }); | 139 }); |
140 | 140 |
141 integration('has "authors" instead of "author"', () { | 141 integration('has "authors" instead of "author"', () { |
142 var pkg = packageMap("test_pkg", "1.0.0"); | 142 var pkg = packageMap("test_pkg", "1.0.0"); |
143 pkg["authors"] = [pkg.remove("author")]; | 143 pkg["authors"] = [pkg.remove("author")]; |
144 d.dir(appPath, [d.pubspec(pkg)]).create(); | 144 d.dir(appPath, [d.pubspec(pkg)]).create(); |
145 expectNoValidationError(pubspecField); | 145 expectNoValidationError(pubspecField); |
146 }); | 146 }); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 "Bob Nystrom <rnystrom@google.com>", | 262 "Bob Nystrom <rnystrom@google.com>", |
263 "<nweiz@google.com>", | 263 "<nweiz@google.com>", |
264 "John Messerly <jmesserly@google.com>" | 264 "John Messerly <jmesserly@google.com>" |
265 ]; | 265 ]; |
266 d.dir(appPath, [d.pubspec(pkg)]).create(); | 266 d.dir(appPath, [d.pubspec(pkg)]).create(); |
267 | 267 |
268 expectValidationWarning(pubspecField); | 268 expectValidationWarning(pubspecField); |
269 }); | 269 }); |
270 | 270 |
271 integration('has no LICENSE file', () { | 271 integration('has no LICENSE file', () { |
272 schedule(() => deleteFile(path.join(sandboxDir, appPath, 'LICENSE'))); | 272 schedule(() => deleteEntry(path.join(sandboxDir, appPath, 'LICENSE'))); |
273 expectValidationError(license); | 273 expectValidationError(license); |
274 }); | 274 }); |
275 | 275 |
276 integration('has an empty package name', () { | 276 integration('has an empty package name', () { |
277 d.dir(appPath, [d.libPubspec("", "1.0.0")]).create(); | 277 d.dir(appPath, [d.libPubspec("", "1.0.0")]).create(); |
278 expectValidationError(name); | 278 expectValidationError(name); |
279 }); | 279 }); |
280 | 280 |
281 integration('has a package name with an invalid character', () { | 281 integration('has a package name with an invalid character', () { |
282 d.dir(appPath, [d.libPubspec("test-pkg", "1.0.0")]).create(); | 282 d.dir(appPath, [d.libPubspec("test-pkg", "1.0.0")]).create(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 integration('has a library name that is a Dart reserved word', () { | 325 integration('has a library name that is a Dart reserved word', () { |
326 d.dir(appPath, [ | 326 d.dir(appPath, [ |
327 d.libPubspec("test_pkg", "1.0.0"), | 327 d.libPubspec("test_pkg", "1.0.0"), |
328 d.dir("lib", [d.file("for.dart", "int i = 0;")]) | 328 d.dir("lib", [d.file("for.dart", "int i = 0;")]) |
329 ]).create(); | 329 ]).create(); |
330 expectValidationWarning(name); | 330 expectValidationWarning(name); |
331 }); | 331 }); |
332 | 332 |
333 integration('has a single library named differently than the package', () { | 333 integration('has a single library named differently than the package', () { |
334 schedule(() => | 334 schedule(() => |
335 deleteFile(path.join(sandboxDir, appPath, "lib", "test_pkg.dart"))); | 335 deleteEntry(path.join(sandboxDir, appPath, "lib", "test_pkg.dart"))); |
336 d.dir(appPath, [ | 336 d.dir(appPath, [ |
337 d.dir("lib", [d.file("best_pkg.dart", "int i = 0;")]) | 337 d.dir("lib", [d.file("best_pkg.dart", "int i = 0;")]) |
338 ]).create(); | 338 ]).create(); |
339 expectValidationWarning(name); | 339 expectValidationWarning(name); |
340 }); | 340 }); |
341 | 341 |
342 integration('has no lib directory', () { | 342 integration('has no lib directory', () { |
343 schedule(() => deleteDir(path.join(sandboxDir, appPath, "lib"))); | 343 schedule(() => deleteEntry(path.join(sandboxDir, appPath, "lib"))); |
344 expectValidationError(lib); | 344 expectValidationError(lib); |
345 }); | 345 }); |
346 | 346 |
347 integration('has an empty lib directory', () { | 347 integration('has an empty lib directory', () { |
348 schedule(() => | 348 schedule(() => |
349 deleteFile(path.join(sandboxDir, appPath, "lib", "test_pkg.dart"))); | 349 deleteEntry(path.join(sandboxDir, appPath, "lib", "test_pkg.dart"))); |
350 expectValidationError(lib); | 350 expectValidationError(lib); |
351 }); | 351 }); |
352 | 352 |
353 integration('has a lib directory containing only src', () { | 353 integration('has a lib directory containing only src', () { |
354 schedule(() => | 354 schedule(() => |
355 deleteFile(path.join(sandboxDir, appPath, "lib", "test_pkg.dart"))); | 355 deleteEntry(path.join(sandboxDir, appPath, "lib", "test_pkg.dart"))); |
356 d.dir(appPath, [ | 356 d.dir(appPath, [ |
357 d.dir("lib", [ | 357 d.dir("lib", [ |
358 d.dir("src", [d.file("test_pkg.dart", "int i = 0;")]) | 358 d.dir("src", [d.file("test_pkg.dart", "int i = 0;")]) |
359 ]) | 359 ]) |
360 ]).create(); | 360 ]).create(); |
361 expectValidationError(lib); | 361 expectValidationError(lib); |
362 }); | 362 }); |
363 | 363 |
364 group('has a git dependency', () { | 364 group('has a git dependency', () { |
365 group('where a hosted version exists', () { | 365 group('where a hosted version exists', () { |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 }); | 575 }); |
576 | 576 |
577 integration('has a README with invalid utf-8', () { | 577 integration('has a README with invalid utf-8', () { |
578 d.dir(appPath, [ | 578 d.dir(appPath, [ |
579 d.binaryFile("README", [192]) | 579 d.binaryFile("README", [192]) |
580 ]).create(); | 580 ]).create(); |
581 expectValidationWarning(utf8Readme); | 581 expectValidationWarning(utf8Readme); |
582 }); | 582 }); |
583 }); | 583 }); |
584 } | 584 } |
OLD | NEW |