88 wxString tempDir = wxFileName::GetTempDir() + wxFileName::GetPathSeparator()
89 + wxS(
"kicad_test_glob_" ) + wxString::Format( wxS(
"%d" ), (
int) getpid() );
91 BOOST_REQUIRE( wxFileName::Mkdir( tempDir, wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) );
95 wxString path1 = tempDir + wxFileName::GetPathSeparator() + wxS(
"file_a.txt" );
96 wxString path2 = tempDir + wxFileName::GetPathSeparator() + wxS(
"file_b.txt" );
98 file1.Create( path1 );
99 file1.Write( wxS(
"content_a" ) );
102 file2.Create( path2 );
103 file2.Write( wxS(
"content_b" ) );
108 wxString cmd = wxString::Format( wxS(
"dir /b \"%s\\*.txt\"" ), tempDir );
110 wxString cmd = wxString::Format( wxS(
"ls %s/*.txt" ), tempDir );
118 "Glob should expand to include file_a.txt, got: " +
output );
120 "Glob should expand to include file_b.txt, got: " +
output );
122 wxRemoveFile( path1 );
123 wxRemoveFile( path2 );
204 wxString baseDir = wxFileName::GetTempDir() + wxFileName::GetPathSeparator()
205 + wxS(
"kicad test 24226 " ) + wxString::Format( wxS(
"%d" ), (
int) getpid() );
207 BOOST_REQUIRE( wxFileName::Mkdir( baseDir, wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) );
209 wxString sentinel = wxS(
"SENTINEL_24226" );
214 wxString argPath = baseDir + wxFileName::GetPathSeparator() + wxS(
"script input.txt" );
223 wxString scriptPath = baseDir + wxFileName::GetPathSeparator() + wxS(
"print sentinel.bat" );
225 BOOST_REQUIRE( script.Write( wxS(
"@echo off\r\nif \"%~1\"==\"" ) + argPath + wxS(
"\" echo " )
226 + sentinel + wxS(
"\r\n" ) ) );
229 wxString cmd = wxS(
"\"" ) + scriptPath + wxS(
"\" \"" ) + argPath + wxS(
"\"" );
232 wxString scriptPath = baseDir + wxFileName::GetPathSeparator() + wxS(
"print sentinel.sh" );
234 BOOST_REQUIRE( script.Write( wxS(
"#!/bin/sh\n[ \"$1\" = \"" ) + argPath + wxS(
"\" ] && echo " )
235 + sentinel + wxS(
"\n" ) ) );
237 BOOST_REQUIRE( wxFileName( scriptPath ).SetPermissions( wxPOSIX_USER_READ | wxPOSIX_USER_WRITE
238 | wxPOSIX_USER_EXECUTE ) );
240 wxString cmd = wxS(
"\"" ) + scriptPath + wxS(
"\" \"" ) + argPath + wxS(
"\"" );
248 "Quoted absolute paths with spaces should reach the interpreter intact, "
251 wxRemoveFile( argPath );
252 wxRemoveFile( scriptPath );
int ExecuteCommandThroughShell(const wxString &aCommand, wxProcess *aProcess)
Run a user-supplied command line through the platform shell so glob expansion, pipes,...
wxString result
Test unit parsing edge cases and error handling.
BOOST_CHECK_EQUAL(result, "25.4")