Commit 64370f87 authored by Paul's avatar Paul
Browse files

Show program name

parent 4e14ec8e
...@@ -14,26 +14,27 @@ ...@@ -14,26 +14,27 @@
#include "test.hpp" #include "test.hpp"
#include "verify.hpp" #include "verify.hpp"
auto& handlers() #ifdef __clang__
{ #pragma clang diagnostic push
static std::array<std::function<void()>, 2> x = {}; #pragma clang diagnostic ignored "-Wglobal-constructors"
return x; #endif
}
struct auto_print struct auto_print
{ {
static std::array<std::function<void()>, 2> handlers;
migraph::program& p; migraph::program& p;
int index; int index;
auto_print(migraph::program& pp, int i) : p(pp), index(i) auto_print(migraph::program& pp, int i) : p(pp), index(i)
{ {
handlers()[index] = [this] { std::cout << p << std::endl; }; handlers[index] = [this] { std::cout << p << std::endl; };
} }
~auto_print() ~auto_print()
{ {
handlers()[index] = [] {}; handlers[index] = [] {};
} }
}; };
std::array<std::function<void()>, 2> auto_print::handlers = {};
template <class V> template <class V>
migraph::argument run_cpu() migraph::argument run_cpu()
...@@ -71,15 +72,17 @@ template <class V> ...@@ -71,15 +72,17 @@ template <class V>
void verify_program() void verify_program()
{ {
std::set_terminate(+[] { std::set_terminate(+[] {
std::cout << "FAILED: " << migraph::get_type_name<V>() << std::endl;
try try
{ {
std::rethrow_exception(std::current_exception()); std::rethrow_exception(std::current_exception());
} }
catch(const std::exception& e) catch(const std::exception& e)
{ {
std::cout << "what(): " << e.what() << std::endl; std::cout << " what(): " << e.what() << std::endl;
} }
for(auto&& handle : handlers()) std::cout << std::endl;
for(auto&& handle : auto_print::handlers)
handle(); handle();
}); });
auto cpu_arg = run_cpu<V>(); auto cpu_arg = run_cpu<V>();
...@@ -90,6 +93,7 @@ void verify_program() ...@@ -90,6 +93,7 @@ void verify_program()
std::cout << "FAILED: " << migraph::get_type_name<V>() << std::endl; std::cout << "FAILED: " << migraph::get_type_name<V>() << std::endl;
} }
}); });
std::set_terminate(nullptr);
} }
struct test_literals struct test_literals
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment