Remove unnecessary python path updates for bundled subunit/testtools.
[samba.git] / lib / subunit / c++ / SubunitTestProgressListener.cpp
1 /*  Subunit test listener for cppunit (http://cppunit.sourceforge.net).
2  *  Copyright (C) 2006  Robert Collins <robertc@robertcollins.net>
3  *
4  *  Licensed under either the Apache License, Version 2.0 or the BSD 3-clause
5  *  license at the users choice. A copy of both licenses are available in the
6  *  project source as Apache-2.0 and BSD. You may not use this file except in
7  *  compliance with one of these two licences.
8  *  
9  *  Unless required by applicable law or agreed to in writing, software
10  *  distributed under these licenses is distributed on an "AS IS" BASIS,
11  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  *  See the license you chose for the specific language governing permissions
13  *  and limitations under that license.
14  */
15
16 #include <cppunit/Exception.h>
17 #include <cppunit/Test.h>
18 #include <cppunit/TestFailure.h>
19 #include <cppunit/TextOutputter.h>
20 #include <iostream>
21
22 // Have to be able to import the public interface without config.h.
23 #include "SubunitTestProgressListener.h"
24 #include "config.h"
25 #include "subunit/child.h"
26
27
28 CPPUNIT_NS_BEGIN
29
30
31 void 
32 SubunitTestProgressListener::startTest( Test *test )
33 {
34   subunit_test_start(test->getName().c_str());
35   last_test_failed = false;
36 }
37
38 void 
39 SubunitTestProgressListener::addFailure( const TestFailure &failure )
40 {
41   std::ostringstream capture_stream;
42   TextOutputter outputter(NULL, capture_stream);
43   outputter.printFailureLocation(failure.sourceLine());
44   outputter.printFailureDetail(failure.thrownException());
45
46   if (failure.isError())
47       subunit_test_error(failure.failedTestName().c_str(),
48                          capture_stream.str().c_str());
49   else
50       subunit_test_fail(failure.failedTestName().c_str(),
51                         capture_stream.str().c_str());
52   last_test_failed = true;
53 }
54
55 void 
56 SubunitTestProgressListener::endTest( Test *test)
57 {
58   if (!last_test_failed)
59       subunit_test_pass(test->getName().c_str());
60 }
61
62
63 CPPUNIT_NS_END