Fix tests on systems with a non-master git defaultBranch #1

Open
zebreus wants to merge 140 commits from fix-tests-without-master into main
2 changed files with 14 additions and 25 deletions
Showing only changes of commit 40f154c0ed - Show all commits

View file

@ -46,7 +46,6 @@ Worker::~Worker()
goals that refer to this worker should be gone. (Otherwise we goals that refer to this worker should be gone. (Otherwise we
are in trouble, since goals may call childTerminated() etc. in are in trouble, since goals may call childTerminated() etc. in
their destructors). */ their destructors). */
topGoals.clear();
children.clear(); children.clear();
assert(expectedSubstitutions == 0); assert(expectedSubstitutions == 0);
@ -216,14 +215,6 @@ void Worker::removeGoal(GoalPtr goal)
nix::removeGoal(subGoal, drvOutputSubstitutionGoals); nix::removeGoal(subGoal, drvOutputSubstitutionGoals);
else else
assert(false); assert(false);
if (topGoals.find(goal) != topGoals.end()) {
topGoals.erase(goal);
/* If a top-level goal failed, then kill all other goals
(unless keepGoing was set). */
if (goal->exitCode == Goal::ecFailed && !settings.keepGoing)
topGoals.clear();
}
} }
@ -268,7 +259,7 @@ try {
std::vector<GoalPtr> Worker::run(std::function<Targets (GoalFactory &)> req) std::vector<GoalPtr> Worker::run(std::function<Targets (GoalFactory &)> req)
{ {
auto _topGoals = req(goalFactory()); auto topGoals = req(goalFactory());
assert(!running); assert(!running);
running = true; running = true;
@ -276,9 +267,7 @@ std::vector<GoalPtr> Worker::run(std::function<Targets (GoalFactory &)> req)
std::vector<GoalPtr> results; std::vector<GoalPtr> results;
topGoals.clear(); for (auto & [goal, _promise] : topGoals) {
for (auto & [goal, _promise] : _topGoals) {
topGoals.insert(goal);
results.push_back(goal); results.push_back(goal);
} }
@ -287,7 +276,7 @@ std::vector<GoalPtr> Worker::run(std::function<Targets (GoalFactory &)> req)
return result::failure(std::make_exception_ptr(makeInterrupted())); return result::failure(std::make_exception_ptr(makeInterrupted()));
}); });
auto promise = runImpl(std::move(_topGoals)) auto promise = runImpl(std::move(topGoals))
.exclusiveJoin(updateStatistics()) .exclusiveJoin(updateStatistics())
.exclusiveJoin(std::move(onInterrupt.promise)); .exclusiveJoin(std::move(onInterrupt.promise));
@ -302,21 +291,26 @@ std::vector<GoalPtr> Worker::run(std::function<Targets (GoalFactory &)> req)
return results; return results;
} }
kj::Promise<Result<void>> Worker::runImpl(Targets _topGoals) kj::Promise<Result<void>> Worker::runImpl(Targets topGoals)
try { try {
debug("entered goal loop"); debug("entered goal loop");
kj::Vector<Targets::value_type> promises(_topGoals.size()); kj::Vector<Targets::value_type> promises(topGoals.size());
for (auto & gp : _topGoals) { for (auto & gp : topGoals) {
promises.add(std::move(gp)); promises.add(std::move(gp));
} }
auto collect = AsyncCollect(promises.releaseAsArray()); auto collect = AsyncCollect(promises.releaseAsArray());
while (auto done = co_await collect.next()) { while (auto done = co_await collect.next()) {
// propagate goal exceptions outward // propagate goal exceptions outward
BOOST_OUTCOME_CO_TRYV(done->second); BOOST_OUTCOME_CO_TRY(auto result, done->second);
if (topGoals.empty()) break; /* If a top-level goal failed, then kill all other goals
(unless keepGoing was set). */
if (result.exitCode == Goal::ecFailed && !settings.keepGoing) {
children.clear();
break;
}
} }
/* If --keep-going is not set, it's possible that the main goal /* If --keep-going is not set, it's possible that the main goal

View file

@ -91,11 +91,6 @@ private:
bool running = false; bool running = false;
/**
* The top-level goals of the worker.
*/
Goals topGoals;
template<typename G> template<typename G>
struct CachedGoal struct CachedGoal
{ {
@ -172,7 +167,7 @@ private:
statisticsUpdateInhibitor = {}; statisticsUpdateInhibitor = {};
} }
kj::Promise<Result<void>> runImpl(Targets _topGoals); kj::Promise<Result<void>> runImpl(Targets topGoals);
kj::Promise<Result<void>> boopGC(LocalStore & localStore); kj::Promise<Result<void>> boopGC(LocalStore & localStore);
public: public: