24#define BOOST_TEST_NO_MAIN
26#include <wx/cmdline.h>
27#include <wx/stdstream.h>
28#include <wx/wfstream.h>
37#include <boost/test/included/unit_test.hpp>
39using namespace boost::unit_test;
43bool runSingleTest(
REPORTER* aReporter, wxString
name, wxString testDirPath )
49 wxString fn( testDirPath );
50 fn = fn.Append(
"/" );
51 fn = fn.Append(
name );
52 fn = fn.Append(
"/pns" );
55 wxFileName fname( fn );
57 aReporter->
Report( wxString::Format(
"Running test '%s' from '%s'",
name, fname.GetFullPath() ),
62 if( !logFile.
Load( fname, aReporter ) )
65 wxString::Format(
"Failed to load test '%s' from '%s'",
name, fname.GetFullPath() ),
76int main(
int argc,
char* argv[] )
80 int passed = 0, failed = 0;
82 for(
auto casename : testCases )
84 if( runSingleTest( &reporter, casename, cl_parser.GetParam( 0 ) ) )
91 wxString::Format(
"SUMMARY: %d/%d tests cases PASSED", passed,
92 (
int) testCases.size() ),
96 return failed ? -1 : 0;
153 BOOST_TEST_FAIL(
"replay results inconsistent with reference reslts" );
166 std::vector<PNS_TEST_CASE*> testCases;
168 wxFileName fnameList( absPath +
"tests.lst" );
169 wxTextFile fp( fnameList.GetFullPath() );
174 wxString::Format(
"Failed to load test list from '%s'.", fnameList.GetFullPath() );
175 BOOST_TEST_ERROR( str.c_str().AsChar() );
179 std::vector<wxString> lines;
183 lines.push_back( fp.GetFirstLine() );
187 auto l = fp.GetNextLine();
190 lines.push_back( l );
197 for(
auto l : lines )
199 wxString fn( absPath );
200 fn = fn.Append( wxT(
"/" ) );
202 fn = fn.Append( wxT(
"/pns" ) );
204 testCases.push_back(
new PNS_TEST_CASE( l.ToStdString(), fn.ToStdString() ) );
207 wxString str = wxString::Format(
"Loaded %d test cases from '%s'.", (
int) testCases.size(),
208 fnameList.GetFullPath() );
210 BOOST_TEST_MESSAGE( str.c_str().AsChar() );
217 test_suite* pnsTestSuite = BOOST_TEST_SUITE(
"pns_regressions" );
221 for(
auto& c : testCases )
227 framework::master_test_suite().add( pnsTestSuite );
231int main(
int argc,
char* argv[] )
General utilities for PCB file IO for QA programs.
KI_TEST::CONSOLE_LOG * m_Log
KI_TEST::CONSOLE_MSG_REPORTER * m_Reporter
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
bool Load(const wxFileName &logFileName, REPORTER *aRpt)
bool CompareResults(PNS_LOG_FILE *aLog)
void ReplayLog(PNS_LOG_FILE *aLog, int aStartEventIndex=0, int aFrom=0, int aTo=-1, bool aUpdateExpectedResult=false)
void SetReporter(REPORTER *aReporter)
A pure virtual class used to derive REPORTER objects from.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
std::string GetPcbnewTestDataDir()
Utility which returns a path to the data directory where the test board files are stored.
std::vector< PNS_TEST_CASE * > createTestCases()
static test_suite * init_pns_test_suite(int argc, char *argv[])
std::string GetName() const
std::string GetDataPath() const
PNS_TEST_CASE(std::string name, std::string path)
static void RunTest(PNS_TEST_CASE *aTestData)
static FIXTURE_LOGGER m_logger