Author: kkaempf Date: Mon Dec 31 17:10:34 2007 New Revision: 8169 URL: http://svn.opensuse.org/viewcvs/zypp?rev=8169&view=rev Log: trying to produce more errors, not very successful :-( Modified: trunk/sat-solver/bindings/ruby/tests/problems.rb Modified: trunk/sat-solver/bindings/ruby/tests/problems.rb URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/bindings/ruby/tests/problems.rb?rev=8169&r1=8168&r2=8169&view=diff ============================================================================== --- trunk/sat-solver/bindings/ruby/tests/problems.rb (original) +++ trunk/sat-solver/bindings/ruby/tests/problems.rb Mon Dec 31 17:10:34 2007 @@ -3,40 +3,38 @@ require 'test/unit' require 'satsolver' -def solve_and_check pool, installed, transaction, problem +def solve_and_check solver, transaction, problem - solver = pool.create_solver( installed ) - solver.solve( transaction ) assert solver.problems? - puts "Problems found" + puts "[#{problem}] Problems found" i = 0 found = false solver.each_problem( transaction ) { |p| found = true if p.reason == problem i += 1 case p.reason - when SatSolver::SOLVER_PROBLEM_UPDATE_RULE + when SatSolver::SOLVER_PROBLEM_UPDATE_RULE #1 reason = "problem with installed" - when SatSolver::SOLVER_PROBLEM_JOB_RULE + when SatSolver::SOLVER_PROBLEM_JOB_RULE #2 reason = "conflicting requests" - when SatSolver::SOLVER_PROBLEM_JOB_NOTHING_PROVIDES_DEP + when SatSolver::SOLVER_PROBLEM_JOB_NOTHING_PROVIDES_DEP #3 reason = "nothing provides requested" - when SatSolver::SOLVER_PROBLEM_NOT_INSTALLABLE + when SatSolver::SOLVER_PROBLEM_NOT_INSTALLABLE #4 reason = "not installable" - when SatSolver::SOLVER_PROBLEM_NOTHING_PROVIDES_DEP + when SatSolver::SOLVER_PROBLEM_NOTHING_PROVIDES_DEP #5 reason = "nothing provides rel required by source" - when SatSolver::SOLVER_PROBLEM_SAME_NAME + when SatSolver::SOLVER_PROBLEM_SAME_NAME #6 reason = "cannot install both" - when SatSolver::SOLVER_PROBLEM_PACKAGE_CONFLICT + when SatSolver::SOLVER_PROBLEM_PACKAGE_CONFLICT #7 reason = "source conflicts with rel provided by target" - when SatSolver::SOLVER_PROBLEM_PACKAGE_OBSOLETES + when SatSolver::SOLVER_PROBLEM_PACKAGE_OBSOLETES #8 reason = "source obsoletes rel provided by target" - when SatSolver::SOLVER_PROBLEM_DEP_PROVIDERS_NOT_INSTALLABLE + when SatSolver::SOLVER_PROBLEM_DEP_PROVIDERS_NOT_INSTALLABLE #9 reason = "source requires rel but no providers are installable" else reason = "**unknown**" end - puts "#{i}: [#{reason}] Source #{p.source}, Rel #{p.relation}, Target #{p.target}" + puts "#{i}: [#{p.reason}]: #{reason}] Source #{p.source}, Rel #{p.relation}, Target #{p.target}" } return found end @@ -64,40 +62,77 @@ def test_update_rule transaction = @pool.create_transaction - assert solve_and_check( @pool, @installed, transaction, SatSolver::SOLVER_PROBLEM_UPDATE_RULE ) + solver = @pool.create_solver( @installed ) + solver.solve( transaction ) + assert solve_and_check( solver, transaction, SatSolver::SOLVER_PROBLEM_UPDATE_RULE ) end def test_job_rule transaction = @pool.create_transaction - assert solve_and_check( @pool, @installed, transaction, SatSolver::SOLVER_PROBLEM_JOB_RULE ) + solver = @pool.create_solver( @installed ) + solver.solve( transaction ) + assert solve_and_check( solver, transaction, SatSolver::SOLVER_PROBLEM_JOB_RULE ) end def test_job_nothing_provides transaction = @pool.create_transaction - solv = @pool.find( "A", @repo ) - solv.requires << @pool.create_relation( "ZZ" ) - assert solve_and_check( @pool, @installed, transaction, SatSolver::SOLVER_PROBLEM_JOB_NOTHING_PROVIDES_DEP ) + solver = @pool.create_solver( @installed ) + solver.solve( transaction ) + assert solve_and_check( solver, transaction, SatSolver::SOLVER_PROBLEM_JOB_NOTHING_PROVIDES_DEP ) end def test_not_installable transaction = @pool.create_transaction - assert solve_and_check( @pool, @installed, transaction, SatSolver::SOLVER_PROBLEM_NOT_INSTALLABLE ) + solv = @pool.find( "A", @repo ) + solv.requires << @pool.create_relation( "ZZ" ) + transaction.install( solv ) + solver = @pool.create_solver( @installed ) + solver.solve( transaction ) + assert solve_and_check( solver, transaction, SatSolver::SOLVER_PROBLEM_NOT_INSTALLABLE ) end def test_nothing_provides transaction = @pool.create_transaction - assert solve_and_check( @pool, @installed, transaction, SatSolver::SOLVER_PROBLEM_NOTHING_PROVIDES_DEP ) + solvA = @pool.find( "A", @repo ) + solvA.requires << @pool.create_relation( "B", SatSolver::REL_GE, "2.0-0" ) + solvB = @pool.find( "B", @repo ) + solvB.requires << @pool.create_relation( "ZZ" ) + transaction.install( solvA ) + solver = @pool.create_solver( @installed ) + solver.solve( transaction ) + assert solve_and_check( solver, transaction, SatSolver::SOLVER_PROBLEM_NOTHING_PROVIDES_DEP ) end def test_same_name transaction = @pool.create_transaction - assert solve_and_check( @pool, @installed, transaction, SatSolver::SOLVER_PROBLEM_SAME_NAME ) + solvA = @pool.find( "A", @repo ) + transaction.install( solvA ) + solvA = @repo.create_solvable( "A", "2.0-0" ) + transaction.install( solvA ) + solver = @pool.create_solver( @installed ) + solver.solve( transaction ) + assert solve_and_check( solver, transaction, SatSolver::SOLVER_PROBLEM_SAME_NAME ) end def test_package_conflict transaction = @pool.create_transaction - assert solve_and_check( @pool, @installed, transaction, SatSolver::SOLVER_PROBLEM_PACKAGE_CONFLICT ) + solvA = @pool.find( "A", @repo ) + solvB = @pool.find( "B", @repo ) + solvA.conflicts << @pool.create_relation( solvB.name, SatSolver::REL_EQ, solvB.evr ) + solvB.conflicts << @pool.create_relation( solvA.name, SatSolver::REL_EQ, solvA.evr ) + transaction.install( solvA ) + transaction.install( solvB ) + solver = @pool.create_solver( @installed ) + solver.solve( transaction ) + assert solve_and_check( solver, transaction, SatSolver::SOLVER_PROBLEM_PACKAGE_CONFLICT ) end def test_package_obsoletes transaction = @pool.create_transaction - assert solve_and_check( @pool, @installed, transaction, SatSolver::SOLVER_PROBLEM_PACKAGE_OBSOLETES ) + solvCC = @pool.find( "CC", @repo ) + solvCC.obsoletes << @pool.create_relation( "A" ) + transaction.install( solvCC ) + solver = @pool.create_solver( @installed ) + solver.solve( transaction ) + assert solve_and_check( solver, transaction, SatSolver::SOLVER_PROBLEM_PACKAGE_OBSOLETES ) end def test_providers_not_installable transaction = @pool.create_transaction - assert solve_and_check( @pool, @installed, transaction, SatSolver::SOLVER_PROBLEM_DEP_PROVIDERS_NOT_INSTALLABLE ) + solver = @pool.create_solver( @installed ) + solver.solve( transaction ) + assert solve_and_check( solver, transaction, SatSolver::SOLVER_PROBLEM_DEP_PROVIDERS_NOT_INSTALLABLE ) end end -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org