20#include <boost/test/unit_test.hpp>
38namespace fs = std::filesystem;
41struct RECORD_OUTPUT_FIXTURE
43 RECORD_OUTPUT_FIXTURE() :
44 m_destDir( wxS(
"kicad_jobs_runner_record" ) ),
45 m_jobset( wxString::FromUTF8( ( m_destDir.Path() /
"record.kicad_jobset" ).string().c_str() ) )
47 m_execute =
new JOB_SPECIAL_EXECUTE();
48 m_execute->m_command = wxS(
"echo recorded" );
49 m_execute->m_recordOutput =
true;
50 m_execute->SetConfiguredOutputPath( wxS(
"data/" ) );
52 m_jobset.AddNewJob( wxS(
"special_execute" ), m_execute );
53 m_job = &m_jobset.GetJobs().front();
55 JOBSET_DESTINATION* destination = m_jobset.AddNewDestination( JOBSET_DESTINATION_T::FOLDER );
56 destination->
m_only = { m_job->m_id };
60 bool Run( WX_STRING_REPORTER& aReporter )
62 JOBS_RUNNER runner(
nullptr, &m_jobset,
nullptr, aReporter,
nullptr );
64 return runner.RunJobsForDestination( &m_jobset.GetDestinations().front() );
67 KI_TEST::SCOPED_TEMP_DIR m_destDir;
69 JOBSET_JOB* m_job =
nullptr;
70 JOB_SPECIAL_EXECUTE* m_execute =
nullptr;
75BOOST_FIXTURE_TEST_SUITE( JobsRunnerRecordOutput, RECORD_OUTPUT_FIXTURE )
84 fs::path logFile = m_destDir.Path() /
"out" /
"data" / ( m_job->m_id.ToStdString() +
".log" );
87 std::ifstream log( logFile );
89 std::getline( log, line );
97 m_execute->SetConfiguredOutputPath( wxEmptyString );
102 BOOST_CHECK( fs::is_regular_file( m_destDir.Path() /
"out" / ( m_job->m_id.ToStdString() +
".log" ) ) );
103 BOOST_CHECK_MESSAGE( m_execute->GetConfiguredOutputPath().IsEmpty(), m_execute->GetConfiguredOutputPath() );
110 fs::path blocker = m_destDir.Path() /
"blocker";
111 std::ofstream( blocker ).put(
'x' );
113 wxString logPath = wxString::FromUTF8( ( blocker /
"run.log" ).
string().c_str() );
114 m_execute->SetConfiguredOutputPath( logPath );
119 BOOST_CHECK_MESSAGE(
reporter.GetMessages().Contains( logPath ),
reporter.GetMessages() );
127 m_execute->SetConfiguredOutputPath( wxS(
"/dev/full" ) );
135 BOOST_CHECK_MESSAGE(
reporter.GetMessages().Contains( wxS(
"/dev/full" ) ),
reporter.GetMessages() );
virtual void FromJson(const nlohmann::json &j)=0
A wrapper for reporting to a wxString object.
std::shared_ptr< JOBS_OUTPUT_HANDLER > m_outputHandler
std::vector< wxString > m_only
Transient property, not stored for now.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_CHECK(res.column_datatype(0)==SQL_NUMERIC||res.column_datatype(0)==SQL_DECIMAL)
BOOST_REQUIRE(res.columns()==1)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(ExecuteCommandRecordOutputIntoFolder)
IbisParser parser & reporter