30 using namespace basis;
43 #define DEBUG_TEST_DIRECTORY_TREE
46 #define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger::get(), s)
56 int test_directory_tree::execute()
77 astring path = environment::get(
"FEISTY_MEOW_APEX");
89 #ifdef DEBUG_TEST_DIRECTORY_TREE
90 log(
astring(
"Scanning directory tree at \"") +
path +
"\"");
91 log(
astring(
"Using pattern-match \"") + pattern +
"\"");
95 ASSERT_TRUE(dir.good(),
"directory_tree construction should succeed and be readable.");
97 dir_tree_iterator *ted = dir.start(directory_tree::prefix);
104 while (directory_tree::current(*ted, curr,
files)) {
106 directory_tree::depth(*ted, depth);
107 #ifdef DEBUG_TEST_DIRECTORY_TREE
108 log(string_manipulation::indentation(depth * 2) +
astring(
"[") + curr.
raw() +
"]");
112 for (
int i = 0; i <
files.length(); i++) names +=
files[i] +
" ";
116 #ifdef DEBUG_TEST_DIRECTORY_TREE
122 directory_tree::next(*ted);
125 directory_tree::throw_out(ted);
142 ASSERT_TRUE(dir.good(),
"the directory should be readable for self-compare");
147 ASSERT_TRUE(dir2.good(),
"the directory should read the second time fine too");
149 LOG(
"comparing the two trees.");
151 directory_tree::compare_trees(dir, dir2, diffs, file_info::EQUAL_CHECKSUM_TIMESTAMP_FILESIZE);
164 ASSERT_TRUE(dir.good(),
"the directory should be readable for checksums");
169 ASSERT_TRUE(dir2.good(),
"checksummer should be able to read second time also");
179 directory_tree::compare_trees(dir, dir2, diffs, file_info::EQUAL_CHECKSUM_TIMESTAMP_FILESIZE);
182 ASSERT_FALSE(diffs.
elements(),
"no checksummer differences should be seen for identical directories");
192 ASSERT_TRUE(dir.good(),
"packer directory should be read");
198 int size_packed = dir.packed_size();
199 dir.pack(packed_form);
204 ASSERT_TRUE(dir2.
unpack(packed_form),
"second tree can be unpacked from the first");
208 directory_tree::compare_trees(dir, dir2, diffs, file_info::EQUAL_CHECKSUM_TIMESTAMP_FILESIZE);
213 directory_tree::compare_trees(dir2, dir, diffs, file_info::EQUAL_CHECKSUM_TIMESTAMP_FILESIZE);
219 LOG(
"reading tree to recreate");
221 ASSERT_TRUE(dir.good(),
"makedirs test directory reading");
222 filename tmpdir(environment::get(
"FEISTY_MEOW_GENERATED_STORE") +
"/zz_balfazzaral");
223 LOG(
astring(
"will write to tmp in ") + tmpdir);
227 LOG(
"what happened with that? did it work? merely rhetorical, since we need more code here.");
240 launch_process::run(
"/bin/rm",
astring(
"-rf ") + tmpdir.raw(), launch_process::AWAIT_APP_EXIT, kid);
241 ASSERT_FALSE(kid,
"removing temporary files after test");
256 return final_report();
The application_shell is a base object for console programs.
int length() const
Returns the current reported length of the allocated C array.
Provides a dynamically resizable ASCII character string.
const char * s() const
synonym for observe. the 's' stands for "string", if that helps.
int length() const
Returns the current length of the string.
A very common template for a dynamic array of bytes.
Outcomes describe the state of completion for an operation.
An object that traverses directory trees and provides a view of all files.
virtual bool unpack(basis::byte_array &packed_form)
unpacks the directory_tree from a byte_array.
basis::astring text_form(int max_lines=MAXINT32) const
max_lines is the maximum number of lines to print into the string.
Provides operations commonly needed on file names.
const basis::astring & raw() const
returns the astring that we're holding onto for the path.
int elements() const
the maximum number of elements currently allowed in this amorph.
An array of strings with some additional helpful methods.
#define DEFINE_CLASS_NAME(objname)
Defines the name of a class by providing a couple standard methods.
#define FUNCDEF(func_in)
FUNCDEF sets the name of a function (and plugs it into the callstack).
Provides macros that implement the 'main' program of an application.
#define HOOPLE_MAIN(obj_name, obj_args)
options that should work for most unix and linux apps.
Implements an application lock to ensure only one is running at once.
The guards collection helps in testing preconditions and reporting errors.
unsigned int un_int
Abbreviated name for unsigned integers.
A platform independent way to obtain the timestamp of a file.
A logger that sends to the console screen using the standard output device.
An extension to floating point primitives providing approximate equality.
None split_lines(str unsplit_line)
A dynamic container class that holds any kind of object via pointers.
Useful support functions for unit testing, especially within hoople.
#define ASSERT_EQUAL(a, b, test_name)
#define ASSERT_TRUE(a, test_name)
#define ASSERT_FALSE(a, test_name)