mirror of https://github.com/KLayout/klayout.git
Provide a new option -o for unit test runner which sends the log to a file. This way we don't capture qWarning in the XML JUnit logs.
This commit is contained in:
parent
7e7916a47a
commit
a66cd2a5fc
|
|
@ -544,9 +544,11 @@ main_cont (int &argc, char **argv)
|
||||||
bool debug_mode = false;
|
bool debug_mode = false;
|
||||||
bool continue_flag = false;
|
bool continue_flag = false;
|
||||||
int repeat = 1;
|
int repeat = 1;
|
||||||
|
std::string output;
|
||||||
|
|
||||||
tl::CommandLineOptions cmd;
|
tl::CommandLineOptions cmd;
|
||||||
cmd << tl::arg ("-a", &xml_format, "Provide XML output format (JUnit format)")
|
cmd << tl::arg ("-a", &xml_format, "Provide XML output format (JUnit format)")
|
||||||
|
<< tl::arg ("-o=log", &output, "Sends output to the given file")
|
||||||
<< tl::arg ("-l", &list_tests, "Lists tests and exits")
|
<< tl::arg ("-l", &list_tests, "Lists tests and exits")
|
||||||
<< tl::arg ("-e", &editable, "Uses editable mode")
|
<< tl::arg ("-e", &editable, "Uses editable mode")
|
||||||
<< tl::arg ("-ne", &non_editable, "Uses non-editable mode")
|
<< tl::arg ("-ne", &non_editable, "Uses non-editable mode")
|
||||||
|
|
@ -596,8 +598,18 @@ main_cont (int &argc, char **argv)
|
||||||
tl::set_continue_flag (continue_flag);
|
tl::set_continue_flag (continue_flag);
|
||||||
tl::set_debug_mode (debug_mode);
|
tl::set_debug_mode (debug_mode);
|
||||||
|
|
||||||
|
FILE *output_file = 0;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
if (! output.empty ()) {
|
||||||
|
output_file = fopen (output.c_str (), "w");
|
||||||
|
if (! output_file) {
|
||||||
|
throw tl::Exception (std::string ("Unable to open log file for writing :") + output);
|
||||||
|
}
|
||||||
|
console.send_to (output_file);
|
||||||
|
}
|
||||||
|
|
||||||
ut::ctrl << "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
|
ut::ctrl << "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
|
||||||
ut::ctrl << "<testsuites>";
|
ut::ctrl << "<testsuites>";
|
||||||
|
|
||||||
|
|
@ -652,8 +664,20 @@ main_cont (int &argc, char **argv)
|
||||||
|
|
||||||
ut::ctrl << "</testsuites>";
|
ut::ctrl << "</testsuites>";
|
||||||
|
|
||||||
|
if (output_file) {
|
||||||
|
console.send_to (stdout);
|
||||||
|
fclose (output_file);
|
||||||
|
}
|
||||||
|
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
|
||||||
ut::ctrl << "</testsuites>";
|
ut::ctrl << "</testsuites>";
|
||||||
|
|
||||||
|
if (output_file) {
|
||||||
|
console.send_to (stdout);
|
||||||
|
fclose (output_file);
|
||||||
|
}
|
||||||
|
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -197,10 +197,25 @@ TestConsole::TestConsole (FILE *file)
|
||||||
{
|
{
|
||||||
ms_instance = this;
|
ms_instance = this;
|
||||||
|
|
||||||
|
prepare_file ();
|
||||||
|
redirect ();
|
||||||
|
}
|
||||||
|
|
||||||
|
TestConsole::~TestConsole ()
|
||||||
|
{
|
||||||
|
restore ();
|
||||||
|
|
||||||
|
if (ms_instance == this) {
|
||||||
|
ms_instance = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestConsole::prepare_file ()
|
||||||
|
{
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
m_file_is_tty = false;
|
m_file_is_tty = false;
|
||||||
#else
|
#else
|
||||||
m_file_is_tty = isatty (fileno (file));
|
m_file_is_tty = isatty (fileno (m_file));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
|
|
@ -211,16 +226,15 @@ TestConsole::TestConsole (FILE *file)
|
||||||
m_rows = std::max (0, (int) ws.ws_row);
|
m_rows = std::max (0, (int) ws.ws_row);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
redirect ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TestConsole::~TestConsole ()
|
void
|
||||||
|
TestConsole::send_to (FILE *file)
|
||||||
{
|
{
|
||||||
restore ();
|
if (file != m_file) {
|
||||||
|
flush ();
|
||||||
if (ms_instance == this) {
|
m_file = file;
|
||||||
ms_instance = 0;
|
prepare_file ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,8 @@ public:
|
||||||
TestConsole (FILE *file);
|
TestConsole (FILE *file);
|
||||||
~TestConsole ();
|
~TestConsole ();
|
||||||
|
|
||||||
|
void send_to (FILE *file);
|
||||||
|
|
||||||
void write_str (const char *text, output_stream os);
|
void write_str (const char *text, output_stream os);
|
||||||
void raw_write (const char *text);
|
void raw_write (const char *text);
|
||||||
virtual void flush ();
|
virtual void flush ();
|
||||||
|
|
@ -85,6 +87,7 @@ private:
|
||||||
|
|
||||||
void redirect ();
|
void redirect ();
|
||||||
void restore ();
|
void restore ();
|
||||||
|
void prepare_file ();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue