diff --git a/.monadid b/.monadid index 9d868bdfc5c2e920abbbcde6953c465415f8446a..d251e011c2472bd84dd67b405a1a8dfc091f9221 100644 --- a/.monadid +++ b/.monadid @@ -1,4 +1,4 @@ monad identification file This file is used for monad directory identification Built by toole1 on linux4.ews.illinois.edu -Build Date: Thu Sep 22 14:43:51 CDT 2011 +Build Date: Sat Sep 24 01:37:06 CDT 2011 diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100755 index 0000000000000000000000000000000000000000..815e70785ebe413316c679399d4725f5f7f5150b --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,32 @@ +monad is released under the University of Illinois/NCSA Open Source License, +reproduced below: + +Copyright (c) 2011 Jack Toole. All rights reserved. + +Developed by: Jack Toole <jack@toole1.com> + University of Illinois at Urbana-Champaign + http://code.toole1.com + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal with the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimers. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimers in the + documentation and/or other materials provided with the distribution. + 3. Neither the names of <NAME OF DEVELOPMENT GROUP>, <NAME OF + INSTITUTION>, nor the names of its contributors may be used to endorse + or promote products derived from this Software without specific prior + written permission. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +WITH THE SOFTWARE. diff --git a/Makefile b/Makefile index 1c77d3f6dcb8d3faba1c7672b90a63b0cd8a5250..4012d3d957f7f22f96eaefc9c0e0c344d8e72f54 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ README.cg: README.txt LICENSE.cg: LICENSE.txt $(CONVERT_TXT_TO_CG) LICENSE.txt > LICENSE.cg -.cpp.o: $(wildcard *.h) +%.o : %.cpp $(wildcard *.h) $(CC) $(CFLAGS) -c $(@:.o=.cpp) -o $@ .PHONY: clean diff --git a/monad b/monad index dd28530d7aff33690fa64a0daec856c9702ffcd9..ff39a8b9628cff36d0d4440e36a0ce1febc4fcb7 100755 Binary files a/monad and b/monad differ diff --git a/monad.cpp b/monad.cpp index 13c8a515c5054f86e485afe180caeaa0ba6dbb56..00d8dfd56a2d472eded6a5345699610faff349b2 100755 --- a/monad.cpp +++ b/monad.cpp @@ -353,7 +353,7 @@ string monad::updateFolder(const string & folder, bool link) { string get = getFolder(folder, link); if (opts::update) - exec(-1, "svn","up", get.c_str()); + exec(/*-1,*/ "svn","up", get.c_str()); return get; } @@ -415,7 +415,7 @@ string monad::getFolder(const string & folder, bool link) string svndir = config[svn_config_name][0] + svn_subdir + folder; // TODO (toole1): Won't work if user needs to type password - int svnstatus = exec(-1, "svn","co",svndir.c_str()); + int svnstatus = exec(/*-1,*/ "svn","co",svndir.c_str()); if (svnstatus == 0) return target + "/"; } diff --git a/monad_shared.cpp b/monad_shared.cpp index eb9a908719f82d92239699f7e405a6b8c7125575..09d9be91431ed4f9e17e7cee07efdc882fa98388 100755 --- a/monad_shared.cpp +++ b/monad_shared.cpp @@ -34,7 +34,6 @@ void printInfo() << endl; } - namespace output { @@ -119,9 +118,9 @@ void detailed_info(const unit_test & curr_test) const string & output = curr_test.output; if (curr_test.passed()) - std::cout << "Result: passed" << endl; + std::cout << "Result: " << passed_string() << endl; else - std::cout << "Result: FAILED: " << error << endl; + std::cout << "Result: " << failed_string() << ": " << error << endl; if (curr_test.time < 0) cout << "Took unknown time ("; @@ -144,6 +143,16 @@ void detailed_info(const unit_test & curr_test) cout << endl; } +string passed_string() +{ + return colorize::make_color(colorize::GREEN, "passed"); +} + +string failed_string() +{ + return colorize::make_color(colorize::RED , "FAILED"); +} + } // namespace output } // namespace monad_shared diff --git a/monad_shared.h b/monad_shared.h index 78236b03097ac2df7995af5a20c9e143293676fb..d94e0515a7f0ac00d83a2323e6821d9699d477b9 100755 --- a/monad_shared.h +++ b/monad_shared.h @@ -31,11 +31,9 @@ namespace monad_shared long time; int32_t points; int32_t valgrind_flags; - int8_t mp_part; bool is_valgrind; - unit_test(int8_t MPpart_, - const char * name_, + unit_test(const char * name_, unit_test::function func_, int32_t points_, long timeout_, @@ -48,7 +46,6 @@ namespace monad_shared time(-1), points(points_), valgrind_flags(-1), - mp_part(MPpart_), is_valgrind(is_valgrind_) { } bool passed() const @@ -65,7 +62,10 @@ namespace monad_shared void warning(const std::string & message); void testname(const unit_test & curr_test, int32_t max_testname_len, int32_t max_points_len); void detailed_info(const unit_test & curr_test); + std::string passed_string(); + std::string failed_string(); } // namespace output + } #endif // MONAD_SHARED diff --git a/proxy.cpp b/proxy.cpp index 50932f0d66c6cc6ffa8c13fe4a39f8baaa8290b3..7069ff334c32ffc9484843e0106421a118994e76 100755 --- a/proxy.cpp +++ b/proxy.cpp @@ -38,7 +38,7 @@ namespace proxy namespace opts { - bool verbose = false; + bool verbose = true; bool redirect_test_output = true; } @@ -76,15 +76,14 @@ int main(int argc, char ** argv) namespace proxy { // class add_unit_test -add_unit_test::add_unit_test(int8_t MPpart, const char * name, unit_test::function func, +add_unit_test::add_unit_test(const char * name, unit_test::function func, int32_t points_in_part, int32_t points_in_total, long timeout, bool is_valgrind) { - assertMPpart(MPpart, name); lazy_init_global_tests(); int32_t points = get_points(points_in_total, points_in_part); // Add to global tests vector - global_tests->push_back(unit_test(MPpart, name, func, points, timeout, is_valgrind)); + global_tests->push_back(unit_test(name, func, points, timeout, is_valgrind)); } @@ -95,19 +94,6 @@ void add_unit_test::lazy_init_global_tests() global_tests = new std::vector<unit_test>; } -// Check that test was legal to compile -void add_unit_test::assertMPpart(int8_t MPpart, const char * name) -{ - if (!MP_PART(MPpart)) - { - std::cerr << "Internal Error: unit tests should be surrounded by" << std::endl - << "#if MP_PART(partNumber) ... #endif" << std::endl - << name << "()" << " is defined for part " << (int)MPpart - << " but compiled for part " << MP_PART_NUMBER << std::endl; - exit(-2); - } -} - // Discriminate which points value to add int32_t add_unit_test::get_points(int32_t points_in_total, int32_t points_in_part) @@ -385,9 +371,9 @@ void RunTests::output_detailed_tests_info(int32_t score) void RunTests::output_single_test_passfail(const unit_test & curr_test) { if (curr_test.passed()) - std::cout << "passed" << endl; + std::cout << output::passed_string() << endl; else - std::cout << "FAILED: " << curr_test.errormsg << endl; + std::cout << output::failed_string() << ": " << curr_test.errormsg << endl; } test_execution::test_execution(unit_test & _test, RunTimeEnvironment & env, bool enable_valgrind_call) diff --git a/proxy.h b/proxy.h index 9440f2b114e777a80538e91e323bf04328d717ef..35e7eff20df4d1b2a51f03e6ac18997b043009e9 100755 --- a/proxy.h +++ b/proxy.h @@ -32,13 +32,12 @@ namespace proxy class add_unit_test { public: - add_unit_test(int8_t MPpart, const char * name, unit_test::function func, + add_unit_test(const char * name, unit_test::function func, int32_t points_in_part, int32_t points_in_total, long timeout, bool is_valgrind); private: void lazy_init_global_tests(); - void assertMPpart(int8_t MPpart, const char * name); int32_t get_points(int32_t points_in_total, int32_t points_in_part); }; @@ -166,28 +165,28 @@ using std::cout; using std::cerr; using std::endl; -#define UNIT_TEST(MPpart,func,pointsInPart,pointsInTotal,timeout) \ - proxy::unit_test::return_type \ - func(proxy::unit_test & this_test); \ - proxy::add_unit_test \ - func##_adder(MPpart, #func, func, pointsInPart, \ +#define UNIT_TEST(func,pointsInPart,pointsInTotal,timeout) \ + proxy::unit_test::return_type \ + func(proxy::unit_test & this_test); \ + proxy::add_unit_test \ + func##_adder(#func, func, pointsInPart, \ pointsInTotal, timeout, false); \ - proxy::unit_test::return_type \ + proxy::unit_test::return_type \ func(proxy::unit_test & this_test) -#define VALGRIND_TEST(MPpart,func,pointsInPart,pointsInTotal,timeout) \ - proxy::unit_test::return_type \ - func(proxy::unit_test & this_test); \ - proxy::add_unit_test \ - func##_adder(MPpart, #func, func, pointsInPart, \ +#define VALGRIND_TEST(func,pointsInPart,pointsInTotal,timeout) \ + proxy::unit_test::return_type \ + func(proxy::unit_test & this_test); \ + proxy::add_unit_test \ + func##_adder(#func, func, pointsInPart, \ pointsInTotal, timeout, true); \ - proxy::unit_test::return_type \ + proxy::unit_test::return_type \ func(proxy::unit_test & this_test) -#define OUTPUT_CHECK(func) \ +#define OUTPUT_CHECK(func) \ bool output_check_##func(const std::string & output, const std::string & expected); \ - proxy::add_output_check \ - output_check_##func##_adder(#func, output_check_##func); \ + proxy::add_output_check \ + output_check_##func##_adder(#func, output_check_##func); \ bool output_check_##func(const std::string & output, const std::string & expected) #define STRINGIFY1(p) #p @@ -197,10 +196,10 @@ using std::endl; #define PASS return monad_shared::unit_test::pass_string; -#define ASSERT(expr) if (!(expr)) \ +#define ASSERT(expr) if (!(expr)) \ FAIL("Assertion (" #expr ") failed") -#define ASSERT_OUTPUT(checkFunc, str) \ +#define ASSERT_OUTPUT(checkFunc, str) \ *this_test.checkstream << #checkFunc << str; namespace proxy { diff --git a/util.cpp b/util.cpp index c540542b80961ac1aa66d6e924f9e2679085892e..e32ac36d4b2b33a5ef3e36e0e930f3237f49e805 100644 --- a/util.cpp +++ b/util.cpp @@ -783,5 +783,15 @@ vector<string> tokenize(const string & str, char delim) return args; } +namespace colorize +{ +const char * BLACK = "\033[39m"; +const char * GREEN = "\033[32m"; +const char * RED = "\033[31m"; +const bool is_color_enabled = isatty(STDOUT_FILENO); + + +} + } // namespace util diff --git a/util.h b/util.h index 718b241c79df3f095d02b044836e86a1e9c087fc..62bba542f1fe87631f668579001c338a3ab31587 100644 --- a/util.h +++ b/util.h @@ -188,6 +188,21 @@ void exit_if_error_output(const char * file, int32_t line, StrType message); EXIT_IF_ERROR2, \ EXIT_IF_ERROR1, 0) (__VA_ARGS__) +// Colorization +namespace colorize +{ + extern const char * BLACK; + extern const char * GREEN; + extern const char * RED; + + extern const bool is_color_enabled; + + inline string make_color(const char * color, const string & str) + { + return (is_color_enabled ? color + str + BLACK : str); + } +} // namespace colorize + // INLINE IMPLEMENTATIONS // Originally by radu @@ -267,4 +282,4 @@ Collection<T> transform(C collection, UnaryOperator op) } // namespace util -#endif +#endif // UTIL_H