36size_t replaceFileText(
const wxString& aPath,
const wxString& aOld,
const wxString& aNew )
41 wxFFile input( aPath,
"rb" );
42 BOOST_REQUIRE( input.IsOpened() && input.ReadAll( &contents ) );
45 const size_t count = contents.Replace( aOld, aNew );
46 wxFFile output( aPath,
"wb" );
47 BOOST_REQUIRE( output.IsOpened() && output.Write( contents ) );
60 for(
const wxString& filename : { wxString(
"BusAndVectors.kicad_pro" ),
61 wxString(
"BusAndVectors.kicad_sch" ), wxString(
"LEDs.kicad_sch" ) } )
68 const wxString rootFile =
directory.PathStr() +
"/BusAndVectors.kicad_sch";
69 const wxString childFile =
directory.PathStr() +
"/LEDs.kicad_sch";
71 rootFile,
false,
false, &settings.
Prj(),
false, &
reporter ) );
79 childFile,
false,
false, &settings.
Prj(),
false, &
reporter ) );
80 BOOST_CHECK( !child );
81 BOOST_CHECK(
reporter.GetMessages().Contains(
"hierarchical subsheet" ) );
85 childFile,
false,
false, &settings.
Prj(),
false ) );
88 const KIID childId = child->GetTopLevelSheet( 0 )->m_Uuid;
96 childFile,
false,
false, &settings.
Prj(),
false, &
reporter ) );
103 BOOST_REQUIRE_GT( replaceFileText( childFile,
104 wxS(
"/4394464a-8613-4d36-8dd8-51c322850652/0ed71495-8674-4a6e-a1f9-3d74c1903959" ),
105 wxS(
"/42beb834-d08e-4ccf-b2ec-2a6c2b0cfb9c" ) ), 0 );
108 childFile,
false,
false, &settings.
Prj(),
false, &
reporter ) );
121 for(
const wxString& filename : { wxString(
"BusAndVectors.kicad_pro" ),
122 wxString(
"BusAndVectors.kicad_sch" ), wxString(
"LEDs.kicad_sch" ) } )
127 const wxString rootFile =
directory.PathStr() +
"/BusAndVectors.kicad_sch";
128 BOOST_REQUIRE_EQUAL( replaceFileText( rootFile,
129 wxS(
"(path \"/\"" ), wxS(
"(path \"/4394464a-8613-4d36-8dd8-51c322850652\"" ) ), 1 );
137 rootFile,
false,
false, &settings.
Prj(),
false, &
reporter ) );
138 BOOST_CHECK( !schematic );
139 BOOST_CHECK(
reporter.GetMessages().Contains(
"malformed root sheet instance path" ) );
143 rootFile,
false,
false, &settings.
Prj(),
false ) );
156 for(
const wxString& filename : { wxString(
"SVG-Test.kicad_pro" ), wxString(
"SVG-Test.kicad_sch" ),
157 wxString(
"toplevel2.kicad_sch" ), wxString(
"toplevel3.kicad_sch" ) } )
159 BOOST_REQUIRE( wxCopyFile( source +
"issue25198/" + filename,
160 directory.PathStr() +
"/" + filename ) );
166 directory.PathStr() +
"/SVG-Test.kicad_sch",
false,
false, &settings.
Prj(),
false, &
reporter ) );
172 BOOST_REQUIRE_EQUAL( replaceFileText(
directory.PathStr() +
"/toplevel2.kicad_sch",
173 wxS(
"(path \"/\"" ), wxS(
"(path \"/4394464a-8613-4d36-8dd8-51c322850652\"" ) ), 1 );
178 directory.PathStr() +
"/SVG-Test.kicad_sch",
false,
false, &settings.
Prj(),
false, &
reporter ) );
179 BOOST_CHECK( !flat );
180 BOOST_CHECK(
reporter.GetMessages().Contains(
"malformed root sheet instance path" ) );
183 const wxString oldFile =
directory.PathStr() +
"/NoConnectPinsConnectedByLine.kicad_sch";
184 BOOST_REQUIRE( wxCopyFile( source +
"NoConnectPinsConnectedByLine.kicad_sch", oldFile ) );
186 oldFile,
false,
false, &settings.
Prj(),
false, &
reporter ) );
188 BOOST_CHECK_LT( old->RootScreen()->GetFileFormatVersionAtLoad(), 20221110 );
static SCHEMATIC * LoadSchematic(const wxString &aFileName, bool aSetActive, bool aForceDefaultProject, PROJECT *aProject=nullptr, bool aCalculateConnectivity=true, REPORTER *aRootReporter=nullptr)
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
std::vector< TOP_LEVEL_SHEET_INFO > & GetTopLevelSheets()
virtual PROJECT_FILE & GetProjectFile() const
bool LoadProject(const wxString &aFullPath, bool aSetActive=true)
Load a project or sets up a new project with a specified path.
PROJECT & Prj() const
A helper while we are not MDI-capable – return the one and only project.
A wrapper for reporting to a wxString object.
std::string GetEeschemaTestDataDir()
Get the configured location of Eeschema test data.
Information about a top-level schematic sheet.
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
IbisParser parser & reporter
BOOST_CHECK_EQUAL(result, "25.4")