visual tests: still generate error report on ctrl-c

This commit is contained in:
Dane Springmeyer 2015-06-23 21:54:24 -07:00
parent 717ab98788
commit c24229f5c8
3 changed files with 48 additions and 9 deletions

View file

@ -26,6 +26,7 @@
// stl
#include <vector>
#include <string>
#include <exception>
// boost
#include <boost/filesystem.hpp>
@ -33,6 +34,28 @@
namespace visual_tests
{
class early_exit_error : public std::exception
{
public:
early_exit_error() :
what_() {}
early_exit_error( std::string const& what ) :
what_( what )
{
}
virtual ~early_exit_error() throw() {}
virtual const char * what() const throw()
{
return what_.c_str();
}
protected:
mutable std::string what_;
};
struct map_size
{
map_size(int _width, int _height) : width(_width), height(_height) { }

View file

@ -22,6 +22,8 @@
#include "runner.hpp"
#include "config.hpp"
#include <cstdio>
#include <csignal>
#include <mapnik/datasource_cache.hpp>
#include <mapnik/font_engine_freetype.hpp>
@ -31,6 +33,12 @@
#include "cleanup.hpp" // run_cleanup()
void signal_handler(int /*signal*/)
{
throw visual_tests::early_exit_error("SIGINT");
}
int main(int argc, char** argv)
{
using namespace visual_tests;
@ -81,6 +89,10 @@ int main(int argc, char** argv)
report_type report = vm.count("verbose") ? report_type((console_report())) : report_type((console_short_report()));
result_list results;
std::signal(SIGINT,signal_handler);
unsigned failed_count = 0;
try
{
if (vm.count("styles"))
@ -91,19 +103,19 @@ int main(int argc, char** argv)
{
results = run.test_all(report);
}
}
catch (std::exception & e)
{
std::cerr << "Error runnig tests: " << e.what() << std::endl;
return 1;
}
unsigned failed_count = mapnik::util::apply_visitor(summary_visitor(results), report);
failed_count = mapnik::util::apply_visitor(summary_visitor(results), report);
if (failed_count)
{
html_summary(results, output_dir);
}
}
catch (std::exception const& e)
{
std::cerr << "Error running tests: " << e.what() << std::endl;
return 1;
}
testing::run_cleanup();

View file

@ -156,6 +156,10 @@ result_list runner::test_range(files_iterator begin, files_iterator end, std::re
result_list r = test_one(file, defaults, report);
std::move(r.begin(), r.end(), std::back_inserter(results));
}
catch (visual_tests::early_exit_error const&)
{
break;
}
catch (std::exception const& ex)
{
result r;