Index: test/descriptor.dart |
diff --git a/test/descriptor.dart b/test/descriptor.dart |
index 9890ba3685e691572fa65bcd92688f670bd64cce..ecffceba2783992e0f4cea1acb92af7cd30da7ca 100644 |
--- a/test/descriptor.dart |
+++ b/test/descriptor.dart |
@@ -10,6 +10,7 @@ import 'package:pub/src/io.dart'; |
import 'package:pub/src/utils.dart'; |
import 'package:scheduled_test/descriptor.dart'; |
import 'package:scheduled_test/scheduled_server.dart'; |
+import 'package:package_config/packages_file.dart' as pkgfile; |
import 'descriptor/git.dart'; |
import 'descriptor/tar.dart'; |
@@ -182,3 +183,28 @@ Descriptor credentialsFile( |
/// the given [dependencies]. |
DirectoryDescriptor appDir([Map dependencies]) => |
dir(appPath, [appPubspec(dependencies)]); |
+ |
+/// Desribe a .packages file. |
+/// |
+/// The file path is relative to [appPath]. |
+Descriptor dotPackagesFile(String filePath, |
nweiz
2015/06/10 22:33:59
I'd just call this "packagesFile".
Having the use
Lasse Reichstein Nielsen
2015/06/11 11:21:02
Since we changed the file to have only absolute UR
|
+ [Map<String, String> dependencies]) { |
+ // Check only for existence. |
+ if (dependencies == null) return matcherFile('.packages', (_) => true); |
+ // Check contents as well. |
+ matchFile(content) { |
+ // TODO(lrn): Create a Matcher that gives better error messages. |
+ Uri fileLocation = new Uri.directory(appPath).resolve(filePath); |
Lasse Reichstein Nielsen
2015/06/11 11:21:02
and p.toUri I guess.
|
+ var map = pkgfile.parse(content, fileLocation); |
+ |
+ for (var packageName in dependencies.keys) { |
+ if (!map.containsKey(packageName)) { |
+ return false; |
+ } |
+ var version = dependencies[packageName]; |
+ if (!map[packageName].contains(version)) return false; |
+ } |
+ if (map.length != dependencies.length) return false; |
+ } |
+ return matcherFile('.packages', matchFile); |
+} |