20#include <boost/test/unit_test.hpp>
26#include <wx/filename.h>
50 wxFileName projectDir;
51 projectDir.AssignDir( wxFileName::GetTempDir() );
52 projectDir.AppendDir( wxS(
"kicad_qa_resolve_project" ) );
58 wxFileName
expected( projectDir.GetPath(), wxS(
"final.zip" ) );
74 fn.AssignDir( wxFileName::GetTempDir() );
75 fn.AppendDir( wxString::Format( wxS(
"kicad_qa_%s_%p" ), aTag,
this ) );
77 BOOST_REQUIRE( wxFileName::Mkdir( fn.GetPath(), wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) );
83 if( !
path.IsEmpty() && wxFileName::DirExists(
path ) )
84 wxFileName::Rmdir(
path, wxPATH_RMDIR_RECURSIVE );
104 wxString srcDir = base.
path + wxFileName::GetPathSeparator() + wxS(
"src" );
105 BOOST_REQUIRE( wxFileName::Mkdir( srcDir, wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) );
107 wxString srcFile = srcDir + wxFileName::GetPathSeparator() + wxS(
"payload.txt" );
111 f.Write( wxS(
"hello" ) );
115 wxString nestedDir = base.
path + wxFileName::GetPathSeparator() + wxS(
"level1" )
116 + wxFileName::GetPathSeparator() + wxS(
"level2" );
117 wxString outPath = nestedDir + wxFileName::GetPathSeparator() + wxS(
"archive.zip" );
124 std::vector<wxString> noOverwriteList;
125 std::vector<JOB_OUTPUT> outputs;
126 std::optional<wxString> resolved;
128 bool ok = archive.
HandleOutputs( srcDir,
nullptr, noOverwriteList, outputs, resolved );
130 BOOST_CHECK_MESSAGE( ok,
"Archive job should succeed with a nested destination path." );
131 BOOST_CHECK_MESSAGE( wxFileName::DirExists( nestedDir ),
132 "Nested parent directory should have been created." );
134 BOOST_CHECK( wxFileName::FileExists( resolved.value() ) );
146 wxString srcDir = base.
path + wxFileName::GetPathSeparator() + wxS(
"src" );
147 BOOST_REQUIRE( wxFileName::Mkdir( srcDir, wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) );
149 wxString srcFile = srcDir + wxFileName::GetPathSeparator() + wxS(
"payload.txt" );
153 f.Write( wxS(
"hello" ) );
156 wxString outPath = base.
path + wxFileName::GetPathSeparator() + wxS(
"archive.zip" );
161 std::vector<wxString> noOverwriteList;
162 std::vector<JOB_OUTPUT> outputs;
163 std::optional<wxString> resolved;
165 bool ok = archive.
HandleOutputs( srcDir,
nullptr, noOverwriteList, outputs, resolved );
169 BOOST_CHECK( wxFileName::FileExists( resolved.value() ) );
bool HandleOutputs(const wxString &aBaseTempPath, PROJECT *aProject, const std::vector< wxString > &aPathsWithOverwriteDisallowed, const std::vector< JOB_OUTPUT > &aOutputsToHandle, std::optional< wxString > &aResolvedOutputPath) override
void SetOutputPath(const wxString &aPath)
static wxString ResolveOutputPath(const wxString &aPath, const PROJECT *aProject)
Expand variables and a leading '~' in a destination path, then anchor a relative result at the projec...
const wxString GetProjectFullName() const override
Return the full path and name of the project.
TEST_PROJECT(const wxString &aPath)
Scoped temporary directory used by the tests below.
ScopedTempDir(const wxString &aTag)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_CHECK(res.column_datatype(0)==SQL_NUMERIC||res.column_datatype(0)==SQL_DECIMAL)
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(RelativeDestinationResolvesAgainstProject)
A relative destination must land in the project directory, not the working directory,...
VECTOR3I expected(15, 30, 45)