|
@@ -1022,6 +1022,31 @@ esac
|
|
|
return archive;
|
|
return archive;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Builds a .usmc archive for pkg-<name> at an explicit version
|
|
|
|
|
+ * providing bin:pkg-<name> with the given runtime refs (used for
|
|
|
|
|
+ * provider-selection fixtures).
|
|
|
|
|
+ */
|
|
|
|
|
+ string make_versioned_package_archive(string scratch, string name, string version, string[] runtime_refs) throws Error {
|
|
|
|
|
+ var source = Path.build_filename(scratch, @"src-$name-$version");
|
|
|
|
|
+ DirUtils.create(source, 0755);
|
|
|
|
|
+
|
|
|
|
|
+ var refs = new StringBuilder();
|
|
|
|
|
+ foreach(var resource_ref in runtime_refs) {
|
|
|
|
|
+ if(refs.len > 0) {
|
|
|
|
|
+ refs.append(",");
|
|
|
|
|
+ }
|
|
|
|
|
+ refs.append_printf("\"%s\"", resource_ref);
|
|
|
|
|
+ }
|
|
|
|
|
+ FileUtils.set_contents(Path.build_filename(source, "MANIFEST.usm"),
|
|
|
|
|
+ APP_MANIFEST.printf(@"pkg-$name", @"pkg-$name", depends_with("runtime", "[" + refs.str + "]"))
|
|
|
|
|
+ .replace("\"version\": \"1.0.0\"", @"\"version\": \"$version\""));
|
|
|
|
|
+
|
|
|
|
|
+ var archive = Path.build_filename(scratch, @"pkg-$name-$version.usmc");
|
|
|
|
|
+ Usm.Util.archive(source, archive);
|
|
|
|
|
+ return archive;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Builds a .usmc archive for pkg-<name> providing provides_key with the
|
|
* Builds a .usmc archive for pkg-<name> providing provides_key with the
|
|
|
* given BUILD-phase refs (used for lot-admission fixtures).
|
|
* given BUILD-phase refs (used for lot-admission fixtures).
|
|
@@ -1091,9 +1116,34 @@ esac
|
|
|
Usm.Util.delete_tree(scratch);
|
|
Usm.Util.delete_tree(scratch);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- void test_resolve_spm_before_usm() throws Error {
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * A dependency ref must resolve to the HIGHEST version among its
|
|
|
|
|
+ * providers: the catalog is name/version-ascending and the cache
|
|
|
|
|
+ * sorts ahead of repository listings, so a first-match scan pulled
|
|
|
|
|
+ * the oldest cached copy — fresh installs of high-level packages
|
|
|
|
|
+ * shipped stale dependencies until `usm update` ran.
|
|
|
|
|
+ */
|
|
|
|
|
+ void test_resolve_prefers_newest_provider() throws Error {
|
|
|
var scratch = make_scratch();
|
|
var scratch = make_scratch();
|
|
|
var resolver = new Usm.Resolver(new Usm.ResourceFinder());
|
|
var resolver = new Usm.Resolver(new Usm.ResourceFinder());
|
|
|
|
|
+ resolver.supply_package(make_versioned_package_archive(scratch, "x", "1.0.0", {}));
|
|
|
|
|
+ resolver.supply_package(make_versioned_package_archive(scratch, "x", "1.1.0", {}));
|
|
|
|
|
+ resolver.supply_package(make_versioned_package_archive(scratch, "x", "0.9.0", {}));
|
|
|
|
|
+ resolver.supply_package(make_package_archive(scratch, "app", { "bin:pkg-x" }));
|
|
|
|
|
+
|
|
|
|
|
+ var roots = new Vector<Usm.AbstractPackage>();
|
|
|
|
|
+ roots.add(((!)resolver.find_package("pkg-app")));
|
|
|
|
|
+ var result = resolver.resolve(roots, null);
|
|
|
|
|
+
|
|
|
|
|
+ var chosen = result.packages.where(p => p.manifest.name == "pkg-x").to_vector();
|
|
|
|
|
+ check(chosen.length == 1, "exactly one provider version is resolved for the ref");
|
|
|
|
|
+ check(chosen[0].manifest.version.to_string() == "1.1.0", "a dependency ref resolves to the highest provider version, not the oldest cached copy");
|
|
|
|
|
+
|
|
|
|
|
+ Usm.Util.delete_tree(scratch);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ void test_resolve_spm_before_usm() throws Error {
|
|
|
|
|
+ var scratch = make_scratch(); var resolver = new Usm.Resolver(new Usm.ResourceFinder());
|
|
|
resolver.supply_package(make_package_archive(scratch, "x", {}));
|
|
resolver.supply_package(make_package_archive(scratch, "x", {}));
|
|
|
|
|
|
|
|
var roots = new Vector<Usm.AbstractPackage>();
|
|
var roots = new Vector<Usm.AbstractPackage>();
|
|
@@ -2961,6 +3011,7 @@ echo "Installing libmeson-pkg.so to /usr/lib"
|
|
|
test_satisfied_by_constraints();
|
|
test_satisfied_by_constraints();
|
|
|
test_manifest_satisfies_pc_fallback();
|
|
test_manifest_satisfies_pc_fallback();
|
|
|
test_resolve_diamond_usm_only();
|
|
test_resolve_diamond_usm_only();
|
|
|
|
|
+ test_resolve_prefers_newest_provider();
|
|
|
test_resolve_spm_before_usm();
|
|
test_resolve_spm_before_usm();
|
|
|
test_resolver_constrained_lib_dep();
|
|
test_resolver_constrained_lib_dep();
|
|
|
test_resolver_skips_spm_for_constrained_refs();
|
|
test_resolver_skips_spm_for_constrained_refs();
|