]> git.saurik.com Git - wxWidgets.git/commitdiff
small changes to make the test run fine on wxMSW, too;
authorFrancesco Montorsi <f18m_cpp217828@yahoo.it>
Mon, 23 Mar 2009 16:49:20 +0000 (16:49 +0000)
committerFrancesco Montorsi <f18m_cpp217828@yahoo.it>
Mon, 23 Mar 2009 16:49:20 +0000 (16:49 +0000)
do not use stdout as variable name as VC9 doesn't like it

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59787 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

tests/exec/exec.cpp

index 566ca7204407d96594be5f0b708b9caccd1d51b2..b0f152ac3d253a3e0dd1242553f593162a9c4515 100644 (file)
@@ -79,12 +79,19 @@ void ExecTestCase::TestExecute()
     // test asynch exec
     long pid = wxExecute(ASYNC_COMMAND, wxEXEC_ASYNC);
     CPPUNIT_ASSERT( pid != 0 );
-    CPPUNIT_ASSERT( wxKill(pid) == 0 );
+
+    // NOTE: under Windows the first wxKill() invocation with wxSIGTERM
+    //       may fail if the system is fast and the ASYNC_COMMAND app
+    //       doesn't manage to create its HWND before our wxKill() is
+    //       executed; in that case we "fall back" to the second invocation 
+    //       with wxSIGKILL (which should always succeed)
+    CPPUNIT_ASSERT( wxKill(pid, wxSIGTERM) == 0 ||
+                    wxKill(pid, wxSIGKILL) == 0 );
 
     // test running COMMAND again, but this time with redirection:
-    wxArrayString stdout;
-    CPPUNIT_ASSERT( wxExecute(COMMAND, stdout, wxEXEC_SYNC) == 0 );
-    CPPUNIT_ASSERT( stdout[0] == "hi" );
+    wxArrayString stdout_arr;
+    CPPUNIT_ASSERT( wxExecute(COMMAND, stdout_arr, wxEXEC_SYNC) == 0 );
+    CPPUNIT_ASSERT( stdout_arr[0] == "hi" );
 }
 
 void ExecTestCase::TestProcess()
@@ -97,7 +104,8 @@ void ExecTestCase::TestProcess()
     // we're not going to process the wxEVT_END_PROCESS event,
     // so the proc instance will auto-delete itself after we kill
     // the asynch process:
-    CPPUNIT_ASSERT( wxKill(pid) == 0 );
+    CPPUNIT_ASSERT( wxKill(pid, wxSIGTERM) == 0 ||
+                    wxKill(pid, wxSIGKILL) == 0 );
 
     
     // test wxExecute with wxProcess and REDIRECTION
@@ -105,11 +113,12 @@ void ExecTestCase::TestProcess()
     proc2->Redirect();
     CPPUNIT_ASSERT( wxExecute(COMMAND, wxEXEC_SYNC, proc2) == 0 );
     
-    wxStringOutputStream stdout;
+    wxStringOutputStream stdout_stream;
     CPPUNIT_ASSERT( proc2->GetInputStream() );
-    CPPUNIT_ASSERT( proc2->GetInputStream()->Read(stdout).GetLastError() == wxSTREAM_EOF );
+    CPPUNIT_ASSERT_EQUAL( wxSTREAM_EOF,
+        proc2->GetInputStream()->Read(stdout_stream).GetLastError() );
     
-    wxString str(stdout.GetString());
+    wxString str(stdout_stream.GetString());
     CPPUNIT_ASSERT_EQUAL( "hi", str.Trim() );
 }