lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master 6303f4a 5/5: Make a unit test more robust


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 6303f4a 5/5: Make a unit test more robust
Date: Tue, 11 May 2021 12:03:52 -0400 (EDT)

branch: master
commit 6303f4a26ea50d8585b4b67996465a053df2e01d
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Make a unit test more robust
    
    The lmi makefiles run unit tests in the directory where they're built.
    Therefore, the 'global_settings_test' binary has 'global_settings.o' as
    a prerequisite: the test cannot be run or even linked unless that file
    exists. Rewrote a test to remove that assumption, which had proved
    fragile--see:
      https://lists.nongnu.org/archive/html/lmi/2021-05/msg00011.html
---
 global_settings_test.cpp | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/global_settings_test.cpp b/global_settings_test.cpp
index d9f32ed..7d77ac9 100644
--- a/global_settings_test.cpp
+++ b/global_settings_test.cpp
@@ -66,11 +66,16 @@ void test_directory_exceptions()
 
     // Such string values must name directories, not normal files.
 
+    fs::path const p(__FILE__"_test_file");
+    fs::ofstream ofs(p);
+    ofs << p.string() << std::endl;
+    ofs.close();
     LMI_TEST_THROW
-        (global_settings::instance().set_data_directory("global_settings.o")
+        (global_settings::instance().set_data_directory(p.string())
         ,std::runtime_error
-        ,"Data directory 'global_settings.o' is not a directory."
+        ,"Data directory '" + p.string() + "' is not a directory."
         );
+    fs::remove(p);
 }
 
 int test_main(int, char*[])



reply via email to

[Prev in Thread] Current Thread [Next in Thread]