forked from lix-project/lix
Fix floating CA tests
We will sometimes try to query the outputs of derivations we can't resolve. That's fine; it just means we don't know what those outputs are yet.
This commit is contained in:
parent
4409530fc9
commit
aad4abcc9c
|
@ -1460,7 +1460,9 @@ void DerivationGoal::inputsRealised()
|
|||
/* We are be able to resolve this derivation based on the
|
||||
now-known results of dependencies. If so, we become a stub goal
|
||||
aliasing that resolved derivation goal */
|
||||
Derivation drvResolved { fullDrv.resolve(worker.store) };
|
||||
std::optional attempt = fullDrv.tryResolve(worker.store);
|
||||
assert(attempt);
|
||||
Derivation drvResolved { *std::move(attempt) };
|
||||
|
||||
auto pathResolved = writeDerivation(worker.store, drvResolved);
|
||||
/* Add to memotable to speed up downstream goal's queries with the
|
||||
|
|
|
@ -671,7 +671,7 @@ static void rewriteDerivation(Store & store, BasicDerivation & drv, const String
|
|||
|
||||
Sync<DrvPathResolutions> drvPathResolutions;
|
||||
|
||||
BasicDerivation Derivation::resolve(Store & store) {
|
||||
std::optional<BasicDerivation> Derivation::tryResolve(Store & store) {
|
||||
BasicDerivation resolved { *this };
|
||||
|
||||
// Input paths that we'll want to rewrite in the derivation
|
||||
|
@ -683,7 +683,7 @@ BasicDerivation Derivation::resolve(Store & store) {
|
|||
for (auto & outputName : input.second) {
|
||||
auto actualPathOpt = inputDrvOutputs.at(outputName);
|
||||
if (!actualPathOpt)
|
||||
throw Error("input drv '%s' wasn't yet built", store.printStorePath(input.first));
|
||||
return std::nullopt;
|
||||
auto actualPath = *actualPathOpt;
|
||||
inputRewrites.emplace(
|
||||
downstreamPlaceholder(store, input.first, outputName),
|
||||
|
|
|
@ -133,7 +133,7 @@ struct Derivation : BasicDerivation
|
|||
1. input drv outputs moved to input sources.
|
||||
|
||||
2. placeholders replaced with realized input store paths. */
|
||||
BasicDerivation resolve(Store & store);
|
||||
std::optional<BasicDerivation> tryResolve(Store & store);
|
||||
|
||||
Derivation() = default;
|
||||
Derivation(BasicDerivation && bd) : BasicDerivation(std::move(bd)) { }
|
||||
|
|
|
@ -825,8 +825,13 @@ std::map<std::string, std::optional<StorePath>> LocalStore::queryPartialDerivati
|
|||
/* can't just use else-if instead of `!haveCached` because we need to unlock
|
||||
`drvPathResolutions` before it is locked in `Derivation::resolve`. */
|
||||
if (!haveCached && drv.type() == DerivationType::CAFloating) {
|
||||
/* Resolve drv and use that path instead. */
|
||||
auto pathResolved = writeDerivation(*this, drv.resolve(*this));
|
||||
/* Try resolve drv and use that path instead. */
|
||||
auto attempt = drv.tryResolve(*this);
|
||||
if (!attempt)
|
||||
/* If we cannot resolve the derivation, we cannot have any path
|
||||
assigned so we return the map of all std::nullopts. */
|
||||
return outputs;
|
||||
auto pathResolved = writeDerivation(*this, *std::move(attempt));
|
||||
/* Store in memo table. */
|
||||
/* FIXME: memo logic should not be local-store specific, should have
|
||||
wrapper-method instead. */
|
||||
|
|
|
@ -9,7 +9,7 @@ testDerivation () {
|
|||
local derivationPath=$1
|
||||
local commonArgs=("--experimental-features" "ca-derivations" "./content-addressed.nix" "-A" "$derivationPath" "--no-out-link")
|
||||
local out1 out2
|
||||
out1=$(set -e; nix-build "${commonArgs[@]}" --arg seed 1)
|
||||
out1=$(nix-build "${commonArgs[@]}" --arg seed 1)
|
||||
out2=$(nix-build "${commonArgs[@]}" --arg seed 2 "${secondSeedArgs[@]}")
|
||||
test "$out1" == "$out2"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue