26#include <wx/filename.h>
43 std::filesystem::path dir = std::filesystem::temp_directory_path( ec )
44 / (
"kicad_qa_scratch_doc_live_" + std::to_string( wxGetProcessId() ) );
46 std::filesystem::remove_all( dir, ec );
47 std::filesystem::create_directories( dir, ec );
49 std::filesystem::path proPath = dir /
"live.kicad_pro";
50 std::filesystem::path schPath = dir /
"live.kicad_sch";
53 std::ofstream proFile( proPath );
54 proFile << R
"({ "meta": { "filename": "live.kicad_pro", "version": 3 } })";
55 std::ofstream schFile( schPath );
56 schFile << "(kicad_sch)";
62 struct ACTIVE_PROJECT_RESET
65 std::filesystem::path dir;
67 ~ACTIVE_PROJECT_RESET()
69 std::error_code ignored;
71 std::filesystem::remove_all( dir, ignored );
85 mgr, wxString( schPath.string() ),
86 [&handed, &scratchPath](
PROJECT* aProject )
89 scratchPath = aProject->GetProjectFullName();
90 return std::make_unique<int>( 1 );
96 BOOST_CHECK_MESSAGE( handed != live,
"the live project was handed to the loader" );
98 BOOST_CHECK( scratchPath.StartsWith( wxFileName::GetTempDir() ) );
113 std::filesystem::path dir = std::filesystem::temp_directory_path( ec )
114 / (
"kicad_qa_scratch_doc_other_" + std::to_string( wxGetProcessId() ) );
116 std::filesystem::remove_all( dir, ec );
117 std::filesystem::create_directories( dir, ec );
119 std::filesystem::path schPath = dir /
"other.kicad_sch";
122 std::ofstream schFile( schPath );
123 schFile <<
"(kicad_sch)";
130 wxString proPath = wxString( ( dir /
"other.kicad_pro" ).
string() );
135 mgr, wxString( schPath.string() ),
139 return std::make_unique<int>( 1 );
149 std::filesystem::remove_all( dir, ec );
virtual SETTINGS_MANAGER & GetSettingsManager() const
Container for project specific data.
PROJECT * GetProject(const wxString &aFullPath) const
Retrieve a loaded project by name.
PROJECT & Prj() const
A helper while we are not MDI-capable – return the one and only project.
bool LoadProject(const wxString &aFullPath, bool aSetActive=true, bool aOverrideLock=false)
Load a project or sets up a new project with a specified path.
PGM_BASE & Pgm()
The global program "get" accessor.
SCRATCH_DOC< DOC > LoadScratchDoc(SETTINGS_MANAGER &aMgr, const wxString &aDocPath, Loader aLoader, ClearFn aClearFn)
Construct a SCRATCH_DOC by loading a project non-active and then handing it to the caller's document ...
Move-only RAII wrapper for "load a KiCad document into a non-active scratch PROJECT and clean up afte...
bool ownsProject
True when this load created the project (LoadScratchDoc found the path not yet in the SettingsManager...
std::unique_ptr< DOC > doc
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_CHECK(res.column_datatype(0)==SQL_NUMERIC||res.column_datatype(0)==SQL_DECIMAL)
BOOST_REQUIRE_EQUAL(rows.size(), 1)
BOOST_CHECK_EQUAL(std::any_cast< std::string >(rows[0].at("val")), "12345678901234567.89")
BOOST_REQUIRE(res.columns()==1)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(LivePathGetsItsOwnScratchProject)