OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 import 'package:path/path.dart' as path; | 5 import 'package:path/path.dart' as path; |
6 import 'package:scheduled_test/scheduled_test.dart'; | 6 import 'package:scheduled_test/scheduled_test.dart'; |
7 | 7 |
8 import '../../lib/src/entrypoint.dart'; | 8 import '../../lib/src/entrypoint.dart'; |
9 import '../../lib/src/io.dart'; | 9 import '../../lib/src/io.dart'; |
10 import '../../lib/src/validator.dart'; | 10 import '../../lib/src/validator.dart'; |
11 import '../../lib/src/validator/name.dart'; | 11 import '../../lib/src/validator/name.dart'; |
12 import '../descriptor.dart' as d; | 12 import '../descriptor.dart' as d; |
13 import '../test_pub.dart'; | 13 import '../test_pub.dart'; |
14 import 'utils.dart'; | 14 import 'utils.dart'; |
15 | 15 |
16 Validator name(Entrypoint entrypoint) => new NameValidator(entrypoint); | 16 Validator name(Entrypoint entrypoint) => new NameValidator(entrypoint); |
17 | 17 |
18 main() { | 18 main() { |
19 initConfig(); | 19 initConfig(); |
20 | 20 |
21 group('should consider a package valid if it', () { | 21 group('should consider a package valid if it', () { |
22 setUp(d.validPackage.create); | 22 setUp(d.validPackage.create); |
23 | 23 |
24 integration('looks normal', () => expectNoValidationError(name)); | 24 integration('looks normal', () => expectNoValidationError(name)); |
25 | 25 |
26 integration('has a badly-named library in lib/src', () { | 26 integration('has a badly-named library in lib/src', () { |
27 d.dir(appPath, [ | 27 d.dir( |
28 d.libPubspec("test_pkg", "1.0.0"), | 28 appPath, |
29 d.dir("lib", [ | 29 [ |
30 d.file("test_pkg.dart", "int i = 1;"), | 30 d.libPubspec("test_pkg", "1.0.0"), |
31 d.dir("src", [d.file("8ball.dart", "int j = 2;")]) | 31 d.dir( |
32 ]) | 32 "lib", |
33 ]).create(); | 33 [ |
| 34 d.file("test_pkg.dart", "int i = 1;"), |
| 35 d.dir("src", [d.file("8ball.dart", "int j = 2;")])])]).cre
ate(); |
34 expectNoValidationError(name); | 36 expectNoValidationError(name); |
35 }); | 37 }); |
36 | 38 |
37 integration('has a name that starts with an underscore', () { | 39 integration('has a name that starts with an underscore', () { |
38 d.dir(appPath, [ | 40 d.dir( |
39 d.libPubspec("_test_pkg", "1.0.0"), | 41 appPath, |
40 d.dir("lib", [ | 42 [ |
41 d.file("_test_pkg.dart", "int i = 1;") | 43 d.libPubspec("_test_pkg", "1.0.0"), |
42 ]) | 44 d.dir("lib", [d.file("_test_pkg.dart", "int i = 1;")])]).create(); |
43 ]).create(); | |
44 expectNoValidationError(name); | 45 expectNoValidationError(name); |
45 }); | 46 }); |
46 }); | 47 }); |
47 | 48 |
48 group('should consider a package invalid if it', () { | 49 group('should consider a package invalid if it', () { |
49 setUp(d.validPackage.create); | 50 setUp(d.validPackage.create); |
50 | 51 |
51 integration('has an empty package name', () { | 52 integration('has an empty package name', () { |
52 d.dir(appPath, [d.libPubspec("", "1.0.0")]).create(); | 53 d.dir(appPath, [d.libPubspec("", "1.0.0")]).create(); |
53 expectValidationError(name); | 54 expectValidationError(name); |
(...skipping 13 matching lines...) Expand all Loading... |
67 d.dir(appPath, [d.libPubspec("TestPkg", "1.0.0")]).create(); | 68 d.dir(appPath, [d.libPubspec("TestPkg", "1.0.0")]).create(); |
68 expectValidationWarning(name); | 69 expectValidationWarning(name); |
69 }); | 70 }); |
70 | 71 |
71 integration('has a package name that is a Dart reserved word', () { | 72 integration('has a package name that is a Dart reserved word', () { |
72 d.dir(appPath, [d.libPubspec("final", "1.0.0")]).create(); | 73 d.dir(appPath, [d.libPubspec("final", "1.0.0")]).create(); |
73 expectValidationError(name); | 74 expectValidationError(name); |
74 }); | 75 }); |
75 | 76 |
76 integration('has a library name with an invalid character', () { | 77 integration('has a library name with an invalid character', () { |
77 d.dir(appPath, [ | 78 d.dir( |
78 d.libPubspec("test_pkg", "1.0.0"), | 79 appPath, |
79 d.dir("lib", [d.file("test-pkg.dart", "int i = 0;")]) | 80 [ |
80 ]).create(); | 81 d.libPubspec("test_pkg", "1.0.0"), |
| 82 d.dir("lib", [d.file("test-pkg.dart", "int i = 0;")])]).create(); |
81 expectValidationWarning(name); | 83 expectValidationWarning(name); |
82 }); | 84 }); |
83 | 85 |
84 integration('has a library name that begins with a number', () { | 86 integration('has a library name that begins with a number', () { |
85 d.dir(appPath, [ | 87 d.dir( |
86 d.libPubspec("test_pkg", "1.0.0"), | 88 appPath, |
87 d.dir("lib", [d.file("8ball.dart", "int i = 0;")]) | 89 [ |
88 ]).create(); | 90 d.libPubspec("test_pkg", "1.0.0"), |
| 91 d.dir("lib", [d.file("8ball.dart", "int i = 0;")])]).create(); |
89 expectValidationWarning(name); | 92 expectValidationWarning(name); |
90 }); | 93 }); |
91 | 94 |
92 integration('has a library name that contains upper-case letters', () { | 95 integration('has a library name that contains upper-case letters', () { |
93 d.dir(appPath, [ | 96 d.dir( |
94 d.libPubspec("test_pkg", "1.0.0"), | 97 appPath, |
95 d.dir("lib", [d.file("TestPkg.dart", "int i = 0;")]) | 98 [ |
96 ]).create(); | 99 d.libPubspec("test_pkg", "1.0.0"), |
| 100 d.dir("lib", [d.file("TestPkg.dart", "int i = 0;")])]).create(); |
97 expectValidationWarning(name); | 101 expectValidationWarning(name); |
98 }); | 102 }); |
99 | 103 |
100 integration('has a library name that is a Dart reserved word', () { | 104 integration('has a library name that is a Dart reserved word', () { |
101 d.dir(appPath, [ | 105 d.dir( |
102 d.libPubspec("test_pkg", "1.0.0"), | 106 appPath, |
103 d.dir("lib", [d.file("for.dart", "int i = 0;")]) | 107 [ |
104 ]).create(); | 108 d.libPubspec("test_pkg", "1.0.0"), |
| 109 d.dir("lib", [d.file("for.dart", "int i = 0;")])]).create(); |
105 expectValidationWarning(name); | 110 expectValidationWarning(name); |
106 }); | 111 }); |
107 | 112 |
108 integration('has a single library named differently than the package', () { | 113 integration('has a single library named differently than the package', () { |
109 schedule(() => | 114 schedule( |
110 deleteEntry(path.join(sandboxDir, appPath, "lib", "test_pkg.dart"))); | 115 () => deleteEntry(path.join(sandboxDir, appPath, "lib", "test_pkg.dart
"))); |
111 d.dir(appPath, [ | 116 d.dir( |
112 d.dir("lib", [d.file("best_pkg.dart", "int i = 0;")]) | 117 appPath, |
113 ]).create(); | 118 [d.dir("lib", [d.file("best_pkg.dart", "int i = 0;")])]).create(); |
114 expectValidationWarning(name); | 119 expectValidationWarning(name); |
115 }); | 120 }); |
116 }); | 121 }); |
117 } | 122 } |
OLD | NEW |