/**
	 * As a input method takes normalized map of dependency
	 */
	bool DependencySolver::orderDependency() const {
		DependencyIdSet parentsSet;

		/**
		 * Read parents to sort members of
		 */
		{
			DependencyIdMap::const_iterator iter = normalizedMap.begin();
			DependencyIdMap::const_iterator eiter = normalizedMap.end();
			for(; iter!=eiter; iter++) {
				//LogInfo << "dependency[" << iter->first << "]: ";
				//print(iter->second);
				//LogInfo << std::endl;

				DependencyId unitId = iter->first;
				//DependencyIdSet depsSet = iter->second;
				//fix_dependency(unitId, depsSet);

				test_unit* unit = getUnit(unitId);
				DependencyId parentId = unit->p_parent_id;

				parentsSet.insert(parentId);
			}
		}

		/**
		 * Sort members
		 */
		{
			DependencyIdSet::iterator iter = parentsSet.begin();
			DependencyIdSet::iterator eiter = parentsSet.end();
			for(; iter!=eiter; iter++) {
				//LogInfo << *iter << ", ";
				//check_dep(levels, unitId, *iter);

				DependencyId currId = *iter;

				test_suite* curr = getSuite(currId);

				ReadDirectMembersVisitor reader;
				traverse_test_tree(*curr, reader);
				std::deque<DependencyId>& members = reader.members;

				bool sorted = sortMembers(normalizedMap, members);
				if (sorted) {
					//exchange elements
					bool exchanged = actualizeMembers(*curr, members);
					if (exchanged==false) {
						DEPENDENCY_LOG_ERROR( "Unable to actualize suite[" << currId << "] with dependencies" );
						return false;
					}
					//else actualized
				} else {
					//unable to resolve dependencies
					DEPENDENCY_LOG_ERROR( "Unable to sort dependencies" );
					return false;
				}

			}
			return true;
		}
	}
Пример #2
0
	void TestCase::runNextTestCase()
	{
		getSuite()->runNextCase();
	}