--- ./Source/CTest/cmCTestMultiProcessHandler.cxx.orig 2010-12-07 15:31:57.091228582 -0800 +++ ./Source/CTest/cmCTestMultiProcessHandler.cxx 2010-12-07 19:59:11.115740666 -0800 @@ -434,9 +434,14 @@ if(index == -1) continue; this->Properties[index]->PreviousRuns = prev; - if(this->Properties[index] && this->Properties[index]->Cost == 0) + // When not running in parallel mode, don't clobber test's cost with + // running average. + if(this->ParallelLevel > 1) { - this->Properties[index]->Cost = cost; + if(this->Properties[index] && this->Properties[index]->Cost == 0) + { + this->Properties[index]->Cost = cost; + } } } // Next part of the file is the failed tests @@ -475,20 +480,23 @@ { SortedTests.push_back(i->first); - //If the test failed last time, it should be run first, so max the cost - if(std::find(this->LastTestsFailed.begin(), - this->LastTestsFailed.end(), - this->Properties[i->first]->Name) - != this->LastTestsFailed.end()) + //If the test failed last time, it should be run first, so max the cost. + //Only do this for parallel runs; in non-parallel runs, avoid clobbering + //the test's original cost. + if(this->ParallelLevel > 1) { - this->Properties[i->first]->Cost = FLT_MAX; + if(std::find(this->LastTestsFailed.begin(), + this->LastTestsFailed.end(), + this->Properties[i->first]->Name) + != this->LastTestsFailed.end()) + { + this->Properties[i->first]->Cost = FLT_MAX; + } } } - if(this->ParallelLevel > 1) - { + TestComparator comp(this); std::sort(SortedTests.begin(), SortedTests.end(), comp); - } } //---------------------------------------------------------