From 7fbe124fe0d794bceb37852a9398edf26de25b41 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 16 Jul 2011 15:33:09 -0400 Subject: [PATCH] Unit Tests - Added proper handling for when no command or filter is specified, and no rc.default.command exists. - Improved wording on above error message. - Fixed typo in previous commit (managed to check in code before the build completed, and ultimately failed). - Now reports errors that occur during initialization at the same level of verbosity as during command execution. --- src/Arguments.cpp | 2 +- src/Context.cpp | 21 +++++++++++++++++++++ src/Task.cpp | 2 +- src/en-US.h | 4 ++-- test/basic.t | 2 +- test/sorting.t | 7 ------- 6 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/Arguments.cpp b/src/Arguments.cpp index 38f88ab68..873ea278f 100644 --- a/src/Arguments.cpp +++ b/src/Arguments.cpp @@ -683,7 +683,7 @@ void Arguments::inject_defaults () if (defaultCommand != "") { capture_first (defaultCommand); - context.header ("[task " + trim (defaultCommand) + "]"); + context.header ("[" + combine () + "]"); } else throw std::string (STRING_TRIVIAL_INPUT); diff --git a/src/Context.cpp b/src/Context.cpp index 39c8b691f..daf6c5874 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -174,6 +174,27 @@ int Context::initialize (int argc, const char** argv) std::cout << *d << "\n"; } + // Dump all headers, controlled by 'header' verbosity token. + if (rc && verbose ("header")) + { + std::vector ::iterator h; + for (h = headers.begin (); h != headers.end (); ++h) + if (color ()) + std::cout << colorizeHeader (*h) << "\n"; + else + std::cout << *h << "\n"; + } + + // Dump all footnotes, controlled by 'footnote' verbosity token. + if (rc && verbose ("footnote")) + { + std::vector ::iterator f; + for (f = footnotes.begin (); f != footnotes.end (); ++f) + if (color ()) + std::cout << colorizeFootnote (*f) << "\n"; + else + std::cout << *f << "\n"; + } return rc; } diff --git a/src/Task.cpp b/src/Task.cpp index db5086c50..a108f6784 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -955,7 +955,7 @@ void Task::validate () const if (has ("priority")) { - std::string priority - get ("priority"); + std::string priority = get ("priority"); if (priority != "H" && priority != "M" && priority != "L") diff --git a/src/en-US.h b/src/en-US.h index 998a02f92..93771eff6 100644 --- a/src/en-US.h +++ b/src/en-US.h @@ -339,8 +339,8 @@ #define STRING_UNKNOWN_ERROR "Unknown error." #define STRING_NO_HOME "Could not read home directory from the passwd file." #define STRING_TAGS_NO_COMMAS "Tags are not permitted to contain commas." -#define STRING_TRIVIAL_INPUT "You must specify a command, or a task ID to modify." -#define STRING_ASSUME_INFO "No command specified - assuming 'information'" +#define STRING_TRIVIAL_INPUT "You must specify a command or a task to modify." +#define STRING_ASSUME_INFO "No command specified - assuming 'information'." #define STRING_INFINITE_LOOP "Terminated substitution because more than {1} changes were made - infinite loop protection." // Feedback diff --git a/test/basic.t b/test/basic.t index 495aa4a88..158740fc0 100755 --- a/test/basic.t +++ b/test/basic.t @@ -44,7 +44,7 @@ my $version = slurp ('../../configure.ac'); # Test the usage command. my $output = qx{../src/task rc:basic.rc}; -like ($output, qr/You must specify a command, or a task ID to modify/m, 'missing command and ID'); +like ($output, qr/You must specify a command or a task to modify./m, 'missing command and ID'); # Test the version command. $output = qx{../src/task rc:basic.rc version}; diff --git a/test/sorting.t b/test/sorting.t index 0b13b69f8..04db5a22c 100755 --- a/test/sorting.t +++ b/test/sorting.t @@ -39,7 +39,6 @@ if (open my $fh, '>', 'sorting.rc') } # Test assorted sort orders. - qx{../src/task rc:sorting.rc add zero}; qx{../src/task rc:sorting.rc add priority:H project:A due:yesterday one}; qx{../src/task rc:sorting.rc add priority:M project:B due:today two}; @@ -49,12 +48,6 @@ qx{../src/task rc:sorting.rc add priority:H project:C due:today four}; qx{../src/task rc:sorting.rc start 2}; qx{../src/task rc:sorting.rc start 4}; -# pri:H pro:C due:today four -# pri:H pro:A * due:yesterday one -# pri:M pro:B due:today two -# pri:L pro:C * due:tomorrow three -# zero - my %tests = ( # Single sort column.