/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "Util.h" #include "zookeeper_log.h" using namespace std; CPPUNIT_NS_BEGIN class EclipseOutputter: public CompilerOutputter { public: EclipseOutputter(TestResultCollector *result,ostream &stream): CompilerOutputter(result,stream,"%p:%l: "),stream_(stream) { } virtual void printFailedTestName( TestFailure *failure ){} virtual void printFailureMessage( TestFailure *failure ) { stream_<<": "; Message msg = failure->thrownException()->message(); stream_<< msg.shortDescription(); string text; for(int i=0; i the output must be in the compiler error format. //bool selfTest = (argc > 1) && (std::string("-ide") == argv[1]); globalTestConfig.addConfigFromCmdLine(argc,argv); ZKServer zkserver; // Create the event manager and test controller CPPUNIT_NS::TestResult controller; // Add a listener that colllects test result CPPUNIT_NS::TestResultCollector result; controller.addListener( &result ); // A listener that print dots as tests run. // CPPUNIT_NS::TextTestProgressListener progress; // CPPUNIT_NS::BriefTestProgressListener progress; // brief + elapsed time TimingListener progress; controller.addListener( &progress ); CPPUNIT_NS::TestRunner runner; runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() ); try { CPPUNIT_NS::stdCOut() << endl << "Running " << endl; zoo_set_debug_level(ZOO_LOG_LEVEL_INFO); //zoo_set_debug_level(ZOO_LOG_LEVEL_DEBUG); runner.run( controller, globalTestConfig.getTestName()); // Print test in a compiler compatible format. CPPUNIT_NS::EclipseOutputter outputter( &result,cout); outputter.write(); // Uncomment this for XML output #ifdef ENABLE_XML_OUTPUT std::ofstream file( "tests.xml" ); CPPUNIT_NS::XmlOutputter xml( &result, file ); xml.setStyleSheet( "report.xsl" ); xml.write(); file.close(); #endif } catch ( std::invalid_argument &e ) { // Test path not resolved cout<<"\nERROR: "<