getting through tests on mac
[feisty_meow.git] / nucleus / library / tests_filesystem / test_directory_tree.cpp
index c1894aca4b28c8ed96db97076f4eeb60c7e3d96b..7897831bf0b3b916db6188a009368d13826a3ff9 100644 (file)
 * Please send any updates to: fred@gruntose.com                               *
 */
 
+#include <application/hoople_main.h>
 #include <basis/functions.h>
 #include <basis/guards.h>
-#include <structures/string_array.h>
-#include <application/hoople_main.h>
-#include <loggers/critical_events.h>
-#include <loggers/program_wide_logger.h>
 #include <filesystem/directory_tree.h>
 #include <filesystem/filename.h>
 #include <filesystem/filename_list.h>
+#include <loggers/critical_events.h>
+#include <loggers/program_wide_logger.h>
+#include <processes/launch_process.h>
 #include <structures/static_memory_gremlin.h>
+#include <structures/string_array.h>
 #include <textual/string_manipulation.h>
 #include <unit_test/unit_base.h>
 
@@ -30,6 +31,7 @@ using namespace basis;
 using namespace mathematics;
 using namespace filesystem;
 using namespace loggers;
+using namespace processes;
 using namespace structures;
 using namespace textual;
 using namespace timely;
@@ -52,7 +54,7 @@ int test_directory_tree::execute()
 {
   FUNCDEF("execute");
 
-  astring path = "/usr/include";
+  astring path = "/usr/lib";
 #ifdef __WIN32__
   // default path for windoze uses an area that should always exist.
   path = environment::get("COMMONPROGRAMFILES");
@@ -122,10 +124,10 @@ int test_directory_tree::execute()
     directory_tree dir2(path, pattern.s());
     ASSERT_TRUE(dir2.good(), "the directory should read the second time fine too");
 
-//    LOG("comparing the two trees.");
+    LOG("comparing the two trees.");
     filename_list diffs;
     directory_tree::compare_trees(dir, dir2, diffs, file_info::EQUAL_CHECKSUM_TIMESTAMP_FILESIZE);
-//LOG(diffs.text_form());
+LOG(diffs.text_form());
 
     ASSERT_FALSE(diffs.elements(), "there should be no differences comparing identical dirs");
   }
@@ -190,6 +192,36 @@ int test_directory_tree::execute()
     ASSERT_FALSE(diffs.elements(), "no differences for reverse compare identical dirs");
   }
 
+  {
+    // sixth test: see if the make_directories function works.
+LOG("reading tree to recreate");
+    directory_tree dir(path, pattern.s());
+    ASSERT_TRUE(dir.good(), "makedirs test directory reading");
+    filename tmpdir(environment::get("FEISTY_MEOW_GENERATED_STORE") + "/zz_balfazzaral");
+    LOG(astring("will write to tmp in ") + tmpdir);
+    basis::outcome result = dir.make_directories(tmpdir.raw());
+    ASSERT_EQUAL(result.value(), common::OKAY, "makedirs should succeed");
+    
+
+LOG("what happened with that?  did it work?");
+
+//hmmm: compare the directories with what we expect to be made;
+//      do a dirtree iterator on the path, and make sure each of those exists in the target place.
+
+
+    // clean up the output directory.
+//this won't do it; it's a directory!
+//    bool worked = tmpdir.recursive_unlink();    
+//    ASSERT_TRUE(worked, "removing temporary files after test");
+
+//hmmm: plug in real recursive delete here instead.
+basis::un_int kid;
+launch_process::run("/bin/rm", astring("-rf ") + tmpdir.raw(), launch_process::AWAIT_APP_EXIT, kid);
+ASSERT_FALSE(kid, "removing temporary files after test");
+
+  }
+
+
 // nth test:
 // combine the results of the second test with a comparison like in the
 // third test.  delete all of those temporary files that were added.