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 pub_update_test; | 5 library pub_update_test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 | 9 |
10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 _packages.putIfAbsent(description, () => new Map<Version, Package>()); | 933 _packages.putIfAbsent(description, () => new Map<Version, Package>()); |
934 _packages[description][package.version] = package; | 934 _packages[description][package.version] = package; |
935 } | 935 } |
936 } | 936 } |
937 | 937 |
938 Package mockPackage(String description, String version, | 938 Package mockPackage(String description, String version, |
939 Map dependencyStrings) { | 939 Map dependencyStrings) { |
940 var sdkConstraint = null; | 940 var sdkConstraint = null; |
941 | 941 |
942 // Build the pubspec dependencies. | 942 // Build the pubspec dependencies. |
943 var dependencies = <PackageRef>[]; | 943 var dependencies = <PackageDep>[]; |
944 var devDependencies = <PackageRef>[]; | 944 var devDependencies = <PackageDep>[]; |
945 | 945 |
946 dependencyStrings.forEach((name, constraint) { | 946 dependencyStrings.forEach((name, constraint) { |
947 parseSource(name, (isDev, name, source) { | 947 parseSource(name, (isDev, name, source) { |
948 var packageName = name.replaceFirst(new RegExp(r"-[^-]+$"), ""); | 948 var packageName = name.replaceFirst(new RegExp(r"-[^-]+$"), ""); |
949 constraint = new VersionConstraint.parse(constraint); | 949 constraint = new VersionConstraint.parse(constraint); |
950 | 950 |
951 if (name == 'sdk') { | 951 if (name == 'sdk') { |
952 sdkConstraint = constraint; | 952 sdkConstraint = constraint; |
953 return; | 953 return; |
954 } | 954 } |
955 | 955 |
956 var ref = new PackageRef(packageName, source, constraint, name); | 956 var dep = new PackageDep(packageName, source, constraint, name); |
957 | 957 |
958 if (isDev) { | 958 if (isDev) { |
959 devDependencies.add(ref); | 959 devDependencies.add(dep); |
960 } else { | 960 } else { |
961 dependencies.add(ref); | 961 dependencies.add(dep); |
962 } | 962 } |
963 }); | 963 }); |
964 }); | 964 }); |
965 | 965 |
966 var name = description.replaceFirst(new RegExp(r"-[^-]+$"), ""); | 966 var name = description.replaceFirst(new RegExp(r"-[^-]+$"), ""); |
967 var pubspec = new Pubspec( | 967 var pubspec = new Pubspec( |
968 name, new Version.parse(version), dependencies, devDependencies, | 968 name, new Version.parse(version), dependencies, devDependencies, |
969 new PubspecEnvironment(sdkConstraint)); | 969 new PubspecEnvironment(sdkConstraint)); |
970 return new Package.inMemory(pubspec); | 970 return new Package.inMemory(pubspec); |
971 } | 971 } |
(...skipping 17 matching lines...) Expand all Loading... |
989 }; | 989 }; |
990 | 990 |
991 var match = new RegExp(r"(.*) from (.*)").firstMatch(description); | 991 var match = new RegExp(r"(.*) from (.*)").firstMatch(description); |
992 if (match != null) { | 992 if (match != null) { |
993 name = match[1]; | 993 name = match[1]; |
994 source = sourceNames[match[2]]; | 994 source = sourceNames[match[2]]; |
995 } | 995 } |
996 | 996 |
997 callback(isDev, name, source); | 997 callback(isDev, name, source); |
998 } | 998 } |
OLD | NEW |