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

Side by Side Diff: sdk/lib/_internal/pub_generated/test/pubspec_test.dart

Issue 887483002: Don't crash 'pub get' if a dev dependency is broken. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 5 years, 10 months 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 | « sdk/lib/_internal/pub_generated/test/get/hosted/gets_a_package_with_busted_dev_dependencies_test.dart ('k') | no next file » | no next file with comments »
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 pubspec_test; 5 library pubspec_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:pub_semver/pub_semver.dart'; 9 import 'package:pub_semver/pub_semver.dart';
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
11 11
12 import '../lib/src/package.dart'; 12 import '../lib/src/package.dart';
13 import '../lib/src/pubspec.dart'; 13 import '../lib/src/pubspec.dart';
14 import '../lib/src/source.dart'; 14 import '../lib/src/source.dart';
15 import '../lib/src/source/path.dart';
15 import '../lib/src/source_registry.dart'; 16 import '../lib/src/source_registry.dart';
16 import 'test_pub.dart'; 17 import 'test_pub.dart';
17 18
18 class MockSource extends Source { 19 class MockSource extends Source {
19 final String name = "mock"; 20 final String name = "mock";
20 21
21 Future<Pubspec> doDescribe(PackageId id) => 22 Future<Pubspec> doDescribe(PackageId id) =>
22 throw new UnsupportedError("Cannot describe mock packages."); 23 throw new UnsupportedError("Cannot describe mock packages.");
23 24
24 Future get(PackageId id, String symlink) => 25 Future get(PackageId id, String symlink) =>
(...skipping 12 matching lines...) Expand all
37 description1 == description2; 38 description1 == description2;
38 39
39 String packageName(description) => 'foo'; 40 String packageName(description) => 'foo';
40 } 41 }
41 42
42 main() { 43 main() {
43 initConfig(); 44 initConfig();
44 group('parse()', () { 45 group('parse()', () {
45 var sources = new SourceRegistry(); 46 var sources = new SourceRegistry();
46 sources.register(new MockSource()); 47 sources.register(new MockSource());
48 sources.register(new PathSource());
47 49
48 var throwsPubspecException = 50 var throwsPubspecException =
49 throwsA(new isInstanceOf<PubspecException>('PubspecException')); 51 throwsA(new isInstanceOf<PubspecException>('PubspecException'));
50 52
51 expectPubspecException(String contents, fn(Pubspec pubspec), 53 expectPubspecException(String contents, fn(Pubspec pubspec),
52 [String expectedContains]) { 54 [String expectedContains]) {
53 var expectation = throwsPubspecException; 55 var expectation = throwsPubspecException;
54 if (expectedContains != null) { 56 if (expectedContains != null) {
55 expectation = throwsA( 57 expectation = throwsA(
56 allOf( 58 allOf(
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 foo: 162 foo:
161 unknown: blah 163 unknown: blah
162 ''', sources); 164 ''', sources);
163 165
164 var foo = pubspec.dependencies[0]; 166 var foo = pubspec.dependencies[0];
165 expect(foo.name, equals('foo')); 167 expect(foo.name, equals('foo'));
166 expect(foo.source, equals('unknown')); 168 expect(foo.source, equals('unknown'));
167 }); 169 });
168 170
169 test("throws if a package is in dependencies and dev_dependencies", () { 171 test("throws if a package is in dependencies and dev_dependencies", () {
170 var contents = ''' 172 expectPubspecException('''
171 dependencies: 173 dependencies:
172 foo: 174 foo:
173 mock: ok 175 mock: ok
174 dev_dependencies: 176 dev_dependencies:
175 foo: 177 foo:
176 mock: ok 178 mock: ok
177 '''; 179 ''', (pubspec) {
178 expectPubspecException(contents, (pubspec) => pubspec.dependencies); 180 // This check only triggers if both [dependencies] and [devDependencies]
179 expectPubspecException(contents, (pubspec) => pubspec.devDependencies); 181 // are accessed.
182 pubspec.dependencies;
183 pubspec.devDependencies;
184 });
180 }); 185 });
181 186
182 test("throws if it dependes on itself", () { 187 test("throws if it dependes on itself", () {
183 expectPubspecException(''' 188 expectPubspecException('''
184 name: myapp 189 name: myapp
185 dependencies: 190 dependencies:
186 myapp: 191 myapp:
187 mock: ok 192 mock: ok
188 ''', (pubspec) => pubspec.dependencies); 193 ''', (pubspec) => pubspec.dependencies);
189 }); 194 });
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 var pubspec = new Pubspec.parse(''' 401 var pubspec = new Pubspec.parse('''
397 # No external dependencies yet 402 # No external dependencies yet
398 # Including for completeness 403 # Including for completeness
399 # ...and hoping the spec expands to include details about author, version, etc 404 # ...and hoping the spec expands to include details about author, version, etc
400 # See http://www.dartlang.org/docs/pub-package-manager/ for details 405 # See http://www.dartlang.org/docs/pub-package-manager/ for details
401 ''', sources); 406 ''', sources);
402 expect(pubspec.version, equals(Version.none)); 407 expect(pubspec.version, equals(Version.none));
403 expect(pubspec.dependencies, isEmpty); 408 expect(pubspec.dependencies, isEmpty);
404 }); 409 });
405 410
411 test("throws a useful error for unresolvable path dependencies", () {
412 expectPubspecException('''
413 name: pkg
414 dependencies:
415 from_path: {path: non_local_path}
416 ''',
417 (pubspec) => pubspec.dependencies,
418 '"non_local_path" is a relative path, but this isn\'t a local ' 'pubsp ec.');
419 });
420
406 group("environment", () { 421 group("environment", () {
407 test("defaults to any SDK constraint if environment is omitted", () { 422 test("defaults to any SDK constraint if environment is omitted", () {
408 var pubspec = new Pubspec.parse('', sources); 423 var pubspec = new Pubspec.parse('', sources);
409 expect(pubspec.environment.sdkVersion, equals(VersionConstraint.any)); 424 expect(pubspec.environment.sdkVersion, equals(VersionConstraint.any));
410 }); 425 });
411 426
412 test("allows an empty environment map", () { 427 test("allows an empty environment map", () {
413 var pubspec = new Pubspec.parse(''' 428 var pubspec = new Pubspec.parse('''
414 environment: 429 environment:
415 ''', sources); 430 ''', sources);
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 test("uses the key if the value is null", () { 549 test("uses the key if the value is null", () {
535 var pubspec = new Pubspec.parse(''' 550 var pubspec = new Pubspec.parse('''
536 executables: 551 executables:
537 command: 552 command:
538 ''', sources); 553 ''', sources);
539 expect(pubspec.executables['command'], equals('command')); 554 expect(pubspec.executables['command'], equals('command'));
540 }); 555 });
541 }); 556 });
542 }); 557 });
543 } 558 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/pub_generated/test/get/hosted/gets_a_package_with_busted_dev_dependencies_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698