[Libreoffice-commits] .: sal/qa

Caolán McNamara caolan at kemper.freedesktop.org
Tue Feb 22 13:14:21 PST 2011


 sal/qa/osl/process/osl_process.cxx       |   26 +++++++++-----------------
 sal/qa/osl/process/osl_process_child.cxx |    6 +++---
 2 files changed, 12 insertions(+), 20 deletions(-)

New commits:
commit d83d6212f93d792d0d024de1c20a75ff3e839955
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Feb 22 21:13:06 2011 +0000

    Account for the possibilty of a newline in an env variable
    
    So, lets getline on '\0' and keep it simple.

diff --git a/sal/qa/osl/process/osl_process.cxx b/sal/qa/osl/process/osl_process.cxx
index 22f82e4..dc9a8e3 100644
--- a/sal/qa/osl/process/osl_process.cxx
+++ b/sal/qa/osl/process/osl_process.cxx
@@ -378,6 +378,7 @@ class Test_osl_executeProcess : public CppUnit::TestFixture
 {
     const OUString env_param_;
 
+    OUString     temp_file_url_;
     OUString     temp_file_path_;
     rtl_uString* parameters_[2];
     int          parameters_count_;
@@ -402,14 +403,18 @@ public:
     //------------------------------------------------
     virtual void setUp()
     {
-        temp_file_path_ = create_temp_file();
+        temp_file_path_ = create_temp_file(temp_file_url_);
         parameters_[1]  = temp_file_path_.pData;
     }
 
+    virtual void tearDown()
+    {
+        osl::File::remove(temp_file_url_);
+    }
+
     //------------------------------------------------
-    OUString create_temp_file()
+    OUString create_temp_file(OUString &temp_file_url)
     {
-        OUString temp_file_url;
         FileBase::RC rc = FileBase::createTempFile(0, 0, &temp_file_url);
         CPPUNIT_ASSERT_MESSAGE("createTempFile failed", FileBase::E_None == rc);
 
@@ -434,20 +439,11 @@ public:
         );
 
         std::string line;
-        while (std::getline(file, line))
+        while (std::getline(file, line, '\0'))
             env_container->push_back(line);
     }
 
     //------------------------------------------------
-    void dump_env(const string_container_t& env, OUString file_name)
-    {
-        OString fname = OUStringToOString(file_name, osl_getThreadTextEncoding());
-        std::ofstream file(fname.getStr());
-        std::ostream_iterator<std::string> oi(file, "\n");
-        std::copy(env.begin(), env.end(), oi);
-    }
-
-    //------------------------------------------------
     // environment of the child process that was
     // started. The child process writes his
     // environment into a file
@@ -677,9 +673,6 @@ public:
     }
 
     CPPUNIT_TEST_SUITE(Test_osl_executeProcess);
-    //TODO: very odd, these pass locally for me, but fail on tinderbox,
-    //disable until I can reproduce the failure
-#if 0
     //TODO: Repair these under windows.
 #ifndef WNT
     CPPUNIT_TEST(osl_execProc_parent_equals_child_environment);
@@ -689,7 +682,6 @@ public:
     // CPPUNIT_TEST(osl_execProc_test_batch);
     ///TODO: Repair test (or tested function ;-) - test fails.
     // CPPUNIT_TEST(osl_execProc_exe_name_in_argument_list);
-#endif
     CPPUNIT_TEST_SUITE_END();
 };
 
diff --git a/sal/qa/osl/process/osl_process_child.cxx b/sal/qa/osl/process/osl_process_child.cxx
index 124fcd1..0417874 100644
--- a/sal/qa/osl/process/osl_process_child.cxx
+++ b/sal/qa/osl/process/osl_process_child.cxx
@@ -89,7 +89,7 @@ void w_to_a(LPCTSTR _strW, LPSTR strA, DWORD size)
         while (size_t l = _tcslen(reinterpret_cast<wchar_t*>(p)))
         {
             w_to_a(p, buffer, sizeof(buffer));
-            file << buffer << std::endl;
+            file << buffer << '\0';
             p += l + 1;
         }
         FreeEnvironmentStrings(env);
@@ -100,8 +100,8 @@ void w_to_a(LPCTSTR _strW, LPSTR strA, DWORD size)
     void dump_env(char* file_path)
     {
         std::ofstream file(file_path);
-        for (int i = 0; NULL != environ[i]; i++)
-            file << environ[i] << std::endl;
+        for (int i = 0; NULL != environ[i]; ++i)
+            file << environ[i] << '\0';
     }
 #endif
 


More information about the Libreoffice-commits mailing list