Merge pull request #336 from naderman/solver-only-error-reporting
Errors are now reported solely by the solver without any workaroundspull/339/merge
commit
93ac0eb523
|
@ -156,34 +156,6 @@ EOT
|
|||
// solve dependencies
|
||||
$operations = $solver->solve($request);
|
||||
|
||||
// check for missing deps
|
||||
// TODO this belongs in the solver, but this will do for now to report top-level deps missing at least
|
||||
foreach ($request->getJobs() as $job) {
|
||||
if ('install' === $job['cmd']) {
|
||||
foreach ($installedRepo->getPackages() as $package ) {
|
||||
if ($installedRepo->hasPackage($package) && !$package->isPlatform() && !$installationManager->isPackageInstalled($package)) {
|
||||
$operations[$job['packageName']] = new InstallOperation($package, Solver::RULE_PACKAGE_NOT_EXIST);
|
||||
}
|
||||
if (in_array($job['packageName'], $package->getNames())) {
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
foreach ($operations as $operation) {
|
||||
if ('install' === $operation->getJobType() && in_array($job['packageName'], $operation->getPackage()->getNames())) {
|
||||
continue 2;
|
||||
}
|
||||
if ('update' === $operation->getJobType() && in_array($job['packageName'], $operation->getTargetPackage()->getNames())) {
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
|
||||
if ($pool->whatProvides($job['packageName'])) {
|
||||
throw new \UnexpectedValueException('Package '.$job['packageName'].' can not be installed, either because its version constraint is incorrect, or because one of its dependencies was not found.');
|
||||
}
|
||||
throw new \UnexpectedValueException('Package '.$job['packageName'].' was not found in the package pool, check the name for typos.');
|
||||
}
|
||||
}
|
||||
|
||||
// execute operations
|
||||
if (!$operations) {
|
||||
$io->write('<info>Nothing to install/update</info>');
|
||||
|
|
|
@ -147,10 +147,6 @@ class Solver
|
|||
*/
|
||||
protected function createInstallOneOfRule(array $packages, $reason, $reasonData = null)
|
||||
{
|
||||
if (empty($packages)) {
|
||||
return $this->createImpossibleRule($reason, $reasonData);
|
||||
}
|
||||
|
||||
$literals = array();
|
||||
foreach ($packages as $package) {
|
||||
$literals[] = new Literal($package, true);
|
||||
|
@ -200,22 +196,6 @@ class Solver
|
|||
return new Rule(array(new Literal($issuer, false), new Literal($provider, false)), $reason, $reasonData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Intentionally creates a rule impossible to solve
|
||||
*
|
||||
* The rule is an empty one so it can never be satisfied.
|
||||
*
|
||||
* @param int $reason A RULE_* constant describing the reason for
|
||||
* generating this rule
|
||||
* @param mixed $reasonData Any data, e.g. the package name, that goes with
|
||||
* the reason
|
||||
* @return Rule An empty rule
|
||||
*/
|
||||
protected function createImpossibleRule($reason, $reasonData = null)
|
||||
{
|
||||
return new Rule(array(), $reason, $reasonData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a rule unless it duplicates an existing one of any type
|
||||
*
|
||||
|
@ -972,12 +952,6 @@ class Solver
|
|||
|
||||
|
||||
foreach ($this->jobs as $job) {
|
||||
if (empty($job['packages']) && $job['cmd'] == 'install') {
|
||||
$this->addRule(
|
||||
RuleSet::TYPE_JOB,
|
||||
$this->createImpossibleRule(static::RULE_JOB_INSTALL, $job)
|
||||
);
|
||||
}
|
||||
foreach ($job['packages'] as $package) {
|
||||
switch ($job['cmd']) {
|
||||
case 'install':
|
||||
|
@ -1002,9 +976,13 @@ class Solver
|
|||
foreach ($this->jobs as $job) {
|
||||
switch ($job['cmd']) {
|
||||
case 'install':
|
||||
$rule = $this->createInstallOneOfRule($job['packages'], self::RULE_JOB_INSTALL, $job['packageName']);
|
||||
$this->addRule(RuleSet::TYPE_JOB, $rule);
|
||||
$this->ruleToJob[$rule->getId()] = $job;
|
||||
if (empty($job['packages'])) {
|
||||
$this->problems[] = array($job);
|
||||
} else {
|
||||
$rule = $this->createInstallOneOfRule($job['packages'], self::RULE_JOB_INSTALL, $job['packageName']);
|
||||
$this->addRule(RuleSet::TYPE_JOB, $rule);
|
||||
$this->ruleToJob[$rule->getId()] = $job;
|
||||
}
|
||||
break;
|
||||
case 'remove':
|
||||
// remove all packages with this name including uninstalled
|
||||
|
|
|
@ -57,8 +57,6 @@ class SolverTest extends TestCase
|
|||
|
||||
public function testInstallNonExistingPackageFails()
|
||||
{
|
||||
$this->markTestIncomplete('Reporting this failure is not implemented/working yet');
|
||||
|
||||
$this->repo->addPackage($this->getPackage('A', '1.0'));
|
||||
$this->reposComplete();
|
||||
|
||||
|
|
Loading…
Reference in New Issue