From b45a305df21a6e3b1e28361a96570aaca75875b8 Mon Sep 17 00:00:00 2001 From: Louis-Claude Canon Date: Fri, 15 Jun 2012 21:16:06 +0200 Subject: [PATCH] Enhancement - Output error, header, footnote and debug messages on standard error. --- ChangeLog | 1 + doc/man/taskrc.5.in | 3 +++ src/Context.cpp | 32 ++++++++++++++++---------------- src/TDB2.cpp | 6 +++--- src/commands/CmdCustom.cpp | 2 +- src/commands/CmdEdit.cpp | 2 +- src/commands/CmdMerge.cpp | 17 ++++++++++++++++- src/commands/CmdShell.cpp | 2 +- src/main.cpp | 2 +- test/basic.t | 2 +- test/bug.360.t | 8 ++++---- test/bug.605.t | 4 ++-- test/bug.708.t | 6 +++--- test/bug.886.t | 2 +- test/bug.899.t | 8 ++++---- test/bug.annotate.t | 6 +++--- test/delete.t | 4 ++-- test/dependencies.t | 14 +++++++------- test/feature.559.t | 6 +++--- test/import.t | 6 +++--- test/import.yaml.t | 6 +++--- test/nag.t | 12 ++++++------ test/project.t | 16 ++++++++-------- test/recur.until.t | 2 +- test/shadow.t | 8 ++++---- test/subproject.t | 2 +- test/undo.t | 2 +- test/wait.t | 2 +- 28 files changed, 101 insertions(+), 82 deletions(-) diff --git a/ChangeLog b/ChangeLog index 75fd468ed..cb0ff4827 100644 --- a/ChangeLog +++ b/ChangeLog @@ -31,6 +31,7 @@ Features + Possible to specify the date format when showing information about a task with 'dateformat.info'. + Bash script improvement (column names are now completed). + + Output error, header, footnote and debug messages on standard error. Bugs + Applied patch for bug #919, so the holidays listed on the 'calendar' report diff --git a/doc/man/taskrc.5.in b/doc/man/taskrc.5.in index 565ca12d0..de80c6817 100644 --- a/doc/man/taskrc.5.in +++ b/doc/man/taskrc.5.in @@ -273,6 +273,9 @@ Here are the shortcut equivalents: verbose=nothing verbose= +Those additional comments are sent to the standard error for header, footnote +and project. The others are sent to standard output. + .TP .B confirmation=yes May be "yes" or "no", and determines whether taskwarrior will ask for diff --git a/src/Context.cpp b/src/Context.cpp index dc1569379..938689805 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -208,9 +208,9 @@ int Context::initialize (int argc, const char** argv) std::vector ::iterator d; for (d = debugMessages.begin (); d != debugMessages.end (); ++d) if (color ()) - std::cout << colorizeDebug (*d) << "\n"; + std::cerr << colorizeDebug (*d) << "\n"; else - std::cout << *d << "\n"; + std::cerr << *d << "\n"; } // Dump all headers, controlled by 'header' verbosity token. @@ -219,9 +219,9 @@ int Context::initialize (int argc, const char** argv) std::vector ::iterator h; for (h = headers.begin (); h != headers.end (); ++h) if (color ()) - std::cout << colorizeHeader (*h) << "\n"; + std::cerr << colorizeHeader (*h) << "\n"; else - std::cout << *h << "\n"; + std::cerr << *h << "\n"; } // Dump all footnotes, controlled by 'footnote' verbosity token. @@ -230,9 +230,9 @@ int Context::initialize (int argc, const char** argv) std::vector ::iterator f; for (f = footnotes.begin (); f != footnotes.end (); ++f) if (color ()) - std::cout << colorizeFootnote (*f) << "\n"; + std::cerr << colorizeFootnote (*f) << "\n"; else - std::cout << *f << "\n"; + std::cerr << *f << "\n"; } // Dump all errors, non-maskable. @@ -242,9 +242,9 @@ int Context::initialize (int argc, const char** argv) std::vector ::iterator e; for (e = errors.begin (); e != errors.end (); ++e) if (color ()) - std::cout << colorizeFootnote (*e) << "\n"; + std::cerr << colorizeFootnote (*e) << "\n"; else - std::cout << *e << "\n"; + std::cerr << *e << "\n"; } timer_init.stop (); @@ -311,9 +311,9 @@ int Context::run () std::vector ::iterator d; for (d = debugMessages.begin (); d != debugMessages.end (); ++d) if (color ()) - std::cout << colorizeDebug (*d) << "\n"; + std::cerr << colorizeDebug (*d) << "\n"; else - std::cout << *d << "\n"; + std::cerr << *d << "\n"; } // Dump all headers, controlled by 'header' verbosity token. @@ -322,9 +322,9 @@ int Context::run () std::vector ::iterator h; for (h = headers.begin (); h != headers.end (); ++h) if (color ()) - std::cout << colorizeHeader (*h) << "\n"; + std::cerr << colorizeHeader (*h) << "\n"; else - std::cout << *h << "\n"; + std::cerr << *h << "\n"; } // Dump the report output. @@ -336,9 +336,9 @@ int Context::run () std::vector ::iterator f; for (f = footnotes.begin (); f != footnotes.end (); ++f) if (color ()) - std::cout << colorizeFootnote (*f) << "\n"; + std::cerr << colorizeFootnote (*f) << "\n"; else - std::cout << *f << "\n"; + std::cerr << *f << "\n"; } // Dump all errors, non-maskable. @@ -346,9 +346,9 @@ int Context::run () std::vector ::iterator e; for (e = errors.begin (); e != errors.end (); ++e) if (color ()) - std::cout << colorizeFootnote (*e) << "\n"; + std::cerr << colorizeFootnote (*e) << "\n"; else - std::cout << *e << "\n"; + std::cerr << *e << "\n"; hooks.trigger ("on-exit"); return rc; diff --git a/src/TDB2.cpp b/src/TDB2.cpp index 7480a402c..903aaba33 100644 --- a/src/TDB2.cpp +++ b/src/TDB2.cpp @@ -51,9 +51,9 @@ extern Context context; #define DEBUG_OUTPUT 0 #if DEBUG_OUTPUT > 0 - #define DEBUG_STR(str) std::cout << "DEBUG: " << str << "\n"; std::cout.flush() - #define DEBUG_STR_PART(str) std::cout << "DEBUG: " << str; std::cout.flush() - #define DEBUG_STR_END(str) std::cout << str << "\n"; std::cout.flush() + #define DEBUG_STR(str) std::cerr << "DEBUG: " << str << "\n"; std::cerr.flush() + #define DEBUG_STR_PART(str) std::cerr << "DEBUG: " << str; std::cerr.flush() + #define DEBUG_STR_END(str) std::cerr << str << "\n"; std::cerr.flush() #else #define DEBUG_STR(str) #define DEBUG_STR_PART(str) diff --git a/src/commands/CmdCustom.cpp b/src/commands/CmdCustom.cpp index 3dae34484..a4292b465 100644 --- a/src/commands/CmdCustom.cpp +++ b/src/commands/CmdCustom.cpp @@ -147,7 +147,6 @@ int CmdCustom::execute (std::string& output) if (maxlines) maxlines -= (context.verbose ("blank") ? 1 : 0) + table_header - + (context.verbose ("footnote") ? context.footnotes.size () : 0) + 1; // "X tasks shown ..." // Render. @@ -161,6 +160,7 @@ int CmdCustom::execute (std::string& output) << view.render (filtered, sequence) << optionalBlankLine (); + // Print the number of rendered tasks if (context.verbose ("affected")) { out << (filtered.size () == 1 diff --git a/src/commands/CmdEdit.cpp b/src/commands/CmdEdit.cpp index defba0a17..e827a5de2 100644 --- a/src/commands/CmdEdit.cpp +++ b/src/commands/CmdEdit.cpp @@ -691,7 +691,7 @@ ARE_THESE_REALLY_HARMFUL: if (oops) { - std::cout << STRING_ERROR_PREFIX << problem << "\n"; + std::cerr << STRING_ERROR_PREFIX << problem << "\n"; // Preserve the edits. before = after; diff --git a/src/commands/CmdMerge.cpp b/src/commands/CmdMerge.cpp index b0722a800..def012ad0 100644 --- a/src/commands/CmdMerge.cpp +++ b/src/commands/CmdMerge.cpp @@ -89,7 +89,22 @@ int CmdMerge::execute (std::string& output) else file = uri._path; - context.tdb2.merge (file); + // XXX the following function could indicate whether a modification was + // performed without an exception (by returning a boolean, within a status + // object or with a specific function) + try + { + context.tdb2.merge (file); + } + catch (std::string& e) { + if (e == STRING_TDB2_UP_TO_DATE) + { + output += e + "\n"; + return 0; + } + else + throw e; + } output += std::string (STRING_CMD_MERGE_COMPLETE) + "\n"; diff --git a/src/commands/CmdShell.cpp b/src/commands/CmdShell.cpp index 629939ee8..c3e5631db 100644 --- a/src/commands/CmdShell.cpp +++ b/src/commands/CmdShell.cpp @@ -113,7 +113,7 @@ int CmdShell::execute (std::string&) catch (std::string& error) { - std::cout << error << "\n"; + std::cerr << error << "\n"; } catch (...) diff --git a/src/main.cpp b/src/main.cpp index 6fde2827c..7eec0d93a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -76,7 +76,7 @@ int main (int argc, const char** argv) catch (std::string& error) { - std::cout << error << "\n"; + std::cerr << error << "\n"; status = -1; } diff --git a/test/basic.t b/test/basic.t index 125703c27..470dafd33 100755 --- a/test/basic.t +++ b/test/basic.t @@ -43,7 +43,7 @@ if (open my $fh, '>', 'basic.rc') my $version = slurp ('../../configure.ac'); # Test the usage command. -my $output = qx{../src/task rc:basic.rc}; +my $output = qx{../src/task rc:basic.rc 2>&1 >/dev/null}; like ($output, qr/You must specify a command or a task to modify./m, 'missing command and ID'); # Test the version command. diff --git a/test/bug.360.t b/test/bug.360.t index d92af3867..9ded5c1f0 100755 --- a/test/bug.360.t +++ b/test/bug.360.t @@ -45,25 +45,25 @@ qx{../src/task rc:bug.rc ls}; # Result: trying to add the project generates an error about removing # recurrence from a task. -my $output = qx{echo 'y' | ../src/task rc:bug.rc 1 modify project:bar}; +my $output = qx{echo 'y' | ../src/task rc:bug.rc 1 modify project:bar 2>&1 >/dev/null}; unlike ($output, qr/You cannot remove the recurrence from a recurring task./ms, 'No recurrence removal error'); # Now try to generate the error above via regular means - ie, is it actually # doing what it should? # TODO Removing recur: from a recurring task should also remove imask and parent. -$output = qx{../src/task rc:bug.rc 2 modify recur:}; +$output = qx{../src/task rc:bug.rc 2 modify recur: 2>&1 >/dev/null}; like ($output, qr/You cannot remove the recurrence from a recurring task./ms, 'Recurrence removal error'); # Prevent removal of the due date from a recurring task. # TODO Removing due: from a recurring task should also remove recur, imask and parent -$output = qx{../src/task rc:bug.rc 2 modify due:}; +$output = qx{../src/task rc:bug.rc 2 modify due: 2>&1 >/dev/null}; like ($output, qr/You cannot remove the due date from a recurring task./ms, 'Cannot remove due date from a recurring task'); # Allow removal of the due date from a non-recurring task. qx{../src/task rc:bug.rc add nonrecurring}; $output = qx{../src/task rc:bug.rc ls}; my ($id) = $output =~ /(\d+)\s+nonrecurring/; -$output = qx{../src/task rc:bug.rc $id modify due:}; +$output = qx{../src/task rc:bug.rc $id modify due: 2>&1 >/dev/null}; unlike ($output, qr/You cannot remove the due date from a recurring task./ms, 'Can remove due date from a non-recurring task'); $output = qx{../src/task rc:bug.rc diag}; diff --git a/test/bug.605.t b/test/bug.605.t index 702121532..fb15d1da1 100755 --- a/test/bug.605.t +++ b/test/bug.605.t @@ -45,12 +45,12 @@ if (open my $fh, '>', 'bug.rc') qx{../src/task rc:bug.rc add One project:p1}; # Delete the task and note the completion status of the project. -my $output = qx{echo 'y' | ../src/task rc:bug.rc 1 delete}; +my $output = qx{echo 'y' | ../src/task rc:bug.rc 1 delete 2>&1 >/dev/null}; like ($output, qr/is 0\% complete/ms, 'Empty project correctly reported as being 0% completed.'); # Add another task, complete it and note the completion status of hte project. qx{../src/task rc:bug.rc add Two project:p1}; -$output = qx{../src/task rc:bug.rc 2 done}; +$output = qx{../src/task rc:bug.rc 2 done 2>&1 >/dev/null}; like ($output, qr/is 100\% complete/ms, 'Empty project correctly reported as being 100% completed.'); # Cleanup. diff --git a/test/bug.708.t b/test/bug.708.t index 4bc7625cc..4e4ed9dae 100755 --- a/test/bug.708.t +++ b/test/bug.708.t @@ -55,16 +55,16 @@ qx{../src/task rc:bug.rc add Nine pro:p1}; qx{../src/task rc:bug.rc add Ten pro:p1}; # Complete three tasks and ensure pending and done counts are updated correctly. -my $output = qx{../src/task rc:bug.rc 1-3 do}; +my $output = qx{../src/task rc:bug.rc 1-3 do 2>&1 >/dev/null}; like ($output, qr/Project 'p1' is 30% complete \(7 of 10 tasks remaining\)\./ms, 'Project counts correct for a multiple done'); # Change three projects and ensure pending and done counts are updated correctly. -$output = qx{../src/task rc:bug.rc 4-6 modify pro:p2}; +$output = qx{../src/task rc:bug.rc 4-6 modify pro:p2 2>&1 >/dev/null}; like ($output, qr/Project 'p1' is 42% complete \(4 of 7 tasks remaining\)\./ms, 'Project counts correct for a multiple project reassignment part a'); like ($output, qr/Project 'p2' is 0% complete \(3 of 3 tasks remaining\)\./ms, 'Project counts correct for a multiple project reassignment part b'); # Delete three tasks and ensure pending and done counts are updated correctly. -$output = qx{../src/task rc:bug.rc 7-9 del}; +$output = qx{../src/task rc:bug.rc 7-9 del 2>&1 >/dev/null}; like ($output, qr/Project 'p1' is 75% complete \(1 of 4 tasks remaining\)\./ms, 'Project counts correct for a multiple delete'); # Cleanup. diff --git a/test/bug.886.t b/test/bug.886.t index 35a114e27..cb57c417a 100755 --- a/test/bug.886.t +++ b/test/bug.886.t @@ -42,7 +42,7 @@ if (open my $fh, '>', 'bug.rc') my $output = qx{../src/task rc:bug.rc add one due:sund}; like ($output, qr/Created task 1\./, 'sund --> valid date'); -$output = qx{../src/task rc:bug.rc add two due:donkey}; +$output = qx{../src/task rc:bug.rc add two due:donkey 2>&1 >/dev/null}; like ($output, qr/was not recognized\./, 'donkey --> invalid date'); # Cleanup. diff --git a/test/bug.899.t b/test/bug.899.t index edffd7c31..4bedb48f2 100755 --- a/test/bug.899.t +++ b/test/bug.899.t @@ -40,16 +40,16 @@ if (open my $fh, '>', 'bug.rc') } # Bug 899: task log does not behave correctly when logging into a project -my $output = qx{../src/task rc:bug.rc add one pro:A}; +my $output = qx{../src/task rc:bug.rc add one pro:A 2>&1 >/dev/null}; like ($output, qr/ 0% complete \(1 of 1 /, '1 of 1 tasks remaining - 0%'); -$output = qx{../src/task rc:bug.rc add two pro:A}; +$output = qx{../src/task rc:bug.rc add two pro:A 2>&1 >/dev/null}; like ($output, qr/ 0% complete \(2 of 2 /, '2 of 2 tasks remaining - 0%'); -$output = qx{../src/task rc:bug.rc 1 done}; +$output = qx{../src/task rc:bug.rc 1 done 2>&1 >/dev/null}; like ($output, qr/ 50% complete \(1 of 2 /, '1 of 2 tasks remaining - 50%'); -$output = qx{../src/task rc:bug.rc log three pro:A}; +$output = qx{../src/task rc:bug.rc log three pro:A 2>&1 >/dev/null}; like ($output, qr/ 66% complete \(1 of 3 /, '1 of 3 tasks remaining - 66%'); # Cleanup. diff --git a/test/bug.annotate.t b/test/bug.annotate.t index d29a224fe..1f9452dc7 100755 --- a/test/bug.annotate.t +++ b/test/bug.annotate.t @@ -40,14 +40,14 @@ if (open my $fh, '>', 'bug.rc') # Attempt a blank annotation. qx{../src/task rc:bug.rc add foo}; -my $output = qx{../src/task rc:bug.rc 1 annotate}; +my $output = qx{../src/task rc:bug.rc 1 annotate 2>&1 >/dev/null}; like ($output, qr/Additional text must be provided/, 'failed on blank annotation'); # Attempt an annotation without ID -$output = qx{echo "n" | ../src/task rc:bug.rc annotate bar}; +$output = qx{echo "n" | ../src/task rc:bug.rc annotate bar 2>&1 >/dev/null}; like ($output, qr/Command prevented from running/, 'Filter-less write command inhibited'); -$output = qx{echo "y" | ../src/task rc:bug.rc annotate bar}; +$output = qx{echo "y" | ../src/task rc:bug.rc annotate bar 2>&1 >/dev/null}; unlike ($output, qr/Command prevented from running/, 'Filter-less write command permitted'); # Cleanup. diff --git a/test/delete.t b/test/delete.t index 02f5999a2..44df4fe05 100755 --- a/test/delete.t +++ b/test/delete.t @@ -53,11 +53,11 @@ $output = qx{echo 'y' | ../src/task rc:delete.rc undo; ../src/task rc:delete.rc like ($output, qr/Status\s+Pending\n/, 'Pending'); ok (-r 'completed.data', 'completed.data created'); -$output = qx{../src/task rc:delete.rc 1 delete; ../src/task rc:delete.rc list}; +$output = qx{../src/task rc:delete.rc 1 delete; ../src/task rc:delete.rc list 2>&1 >/dev/null}; like ($output, qr/No matches./, 'No matches'); ok (-r 'completed.data', 'completed.data created'); -$output = qx{../src/task rc:delete.rc info 1}; +$output = qx{../src/task rc:delete.rc info 1 2>&1 >/dev/null}; like ($output, qr/No matches\./, 'No matches'); # 10 # Add a task, delete it, and modify on the fly. diff --git a/test/dependencies.t b/test/dependencies.t index 22519b36e..f071d89ed 100755 --- a/test/dependencies.t +++ b/test/dependencies.t @@ -49,15 +49,15 @@ qx{../src/task rc:dep.rc add One}; qx{../src/task rc:dep.rc add Two}; # [2] -my $output = qx{../src/task rc:dep.rc 1 modify dep:-2}; +my $output = qx{../src/task rc:dep.rc 1 modify dep:-2 2>&1 >/dev/null}; like ($output, qr/Could not delete a dependency on task 2 - not found\./, 'dependencies - remove nonexistent dependency'); # [3] -$output = qx{../src/task rc:dep.rc 1 modify dep:99}; +$output = qx{../src/task rc:dep.rc 1 modify dep:99 2>&1 >/dev/null}; like ($output, qr/Could not create a dependency on task 99 - not found\./, 'dependencies - add dependency for nonexistent task'); # [4] -$output = qx{../src/task rc:dep.rc 99 modify dep:1}; +$output = qx{../src/task rc:dep.rc 99 modify dep:1 2>&1 >/dev/null}; like ($output, qr/No tasks specified\./, 'dependencies - add dependency to nonexistent task'); # [5,6] t 1 dep:2; t info 1 => blocked by 2 @@ -71,16 +71,16 @@ unlike ($output, qr/This task blocked by/, 'dependencies - trivial like ($output, qr/This task is blocking\s+1 One\nUUID/, 'dependencies - trivial blocking'); # [9] t 1 dep:2 (again) -$output = qx{../src/task rc:dep.rc 1 modify dep:2}; +$output = qx{../src/task rc:dep.rc 1 modify dep:2 2>&1 >/dev/null}; like ($output, qr/Task 1 already depends on task 2\./, 'dependencies - add already existing dependency'); # [10,11] t 1 dep:1 => error -$output = qx{../src/task rc:dep.rc 1 modify dep:1}; +$output = qx{../src/task rc:dep.rc 1 modify dep:1 2>&1}; like ($output, qr/A task cannot be dependent on itself\./, 'dependencies - cannot depend on self'); unlike ($output, qr/Modified 1 task\./, 'dependencies - cannot depend on self'); # [12,13] t 1 dep:2; t 2 dep:1 => error -$output = qx{../src/task rc:dep.rc 2 modify dep:1}; +$output = qx{../src/task rc:dep.rc 2 modify dep:1 2>&1}; like ($output, qr/Circular dependency detected and disallowed\./, 'dependencies - trivial circular'); unlike ($output, qr/Modified 1 task\./, 'dependencies - trivial circular'); @@ -105,7 +105,7 @@ qx{../src/task rc:dep.rc add Five}; qx{../src/task rc:dep.rc 5 modify dep:4; ../src/task rc:dep.rc 4 modify dep:3; ../src/task rc:dep.rc 3 modify dep:2; ../src/task rc:dep.rc 2 modify dep:1}; # [17,18] 5 dep 4 dep 3 dep 2 dep 1 dep 5 => error -$output = qx{../src/task rc:dep.rc 1 modify dep:5}; +$output = qx{../src/task rc:dep.rc 1 modify dep:5 2>&1 >/dev/null}; like ($output, qr/Circular dependency detected and disallowed\./, 'dependencies - nontrivial circular'); unlike ($output, qr/Modified 1 task\./, 'dependencies - nontrivial circular'); diff --git a/test/feature.559.t b/test/feature.559.t index 53f68a8ec..19337d584 100755 --- a/test/feature.559.t +++ b/test/feature.559.t @@ -42,10 +42,10 @@ if (open my $fh, '>', 'bug.rc') # Feature 559: rc.exit.on.missing.db should cause exit if rc.data.location is missing. qx{../src/task rc:bug.rc add foo rc.debug:1}; -my $output = qx{../src/task rc:bug.rc list}; -unlike ($output, qr/Error.+does not exist/, 'No error on extant rc.data.location'); +my $output = qx{../src/task rc:bug.rc list 2>&1 >/dev/null}; +unlike ($output, qr/Error.+does not exist/, 'No error on existant rc.data.location'); -$output = qx{../src/task rc:bug.rc rc.data.location=donkey list}; +$output = qx{../src/task rc:bug.rc rc.data.location=donkey list 2>&1 >/dev/null}; like ($output, qr/Error.+does not exist/, 'Error on missing rc.data.location'); # Cleanup. diff --git a/test/import.t b/test/import.t index c240e6cf5..8196b73b5 100755 --- a/test/import.t +++ b/test/import.t @@ -51,7 +51,7 @@ EOF ok (-r 'import.txt', 'Created sample import data'); } -my $output = qx{../src/task rc:import.rc import import.txt}; +my $output = qx{../src/task rc:import.rc import import.txt 2>&1 >/dev/null}; like ($output, qr/Imported 3 tasks\./, 'no errors'); # Imported 3 tasks successfully. @@ -79,7 +79,7 @@ unlike ($output, qr/2.+B.+one/, 't2 missing'); like ($output, qr/2\/13\/2009.+two/, 't3 present'); # Make sure that a duplicate task cannot be imported. -$output = qx{../src/task rc:import.rc import import.txt}; +$output = qx{../src/task rc:import.rc import import.txt 2>&1 >/dev/null}; like ($output, qr/Cannot add task because the uuid .+ is not unique\./, 'error on duplicate uuid'); # Create import file. @@ -93,7 +93,7 @@ EOF ok (-r 'import2.txt', 'Created second sample import data'); } -$output = qx{../src/task rc:import.rc import import2.txt}; +$output = qx{../src/task rc:import.rc import import2.txt 2>&1 >/dev/null}; like ($output, qr/Imported 1 tasks\./, 'no errors'); # Imported 1 tasks successfully. diff --git a/test/import.yaml.t b/test/import.yaml.t index 04e961978..485aff815 100755 --- a/test/import.yaml.t +++ b/test/import.yaml.t @@ -73,7 +73,7 @@ EOF qx{../scripts/add-ons/import-yaml.pl import.json}; # Import the JSON. -my $output = qx{../src/task rc:import.rc import import.json}; +my $output = qx{../src/task rc:import.rc import import.json 2>&1 >/dev/null}; like ($output, qr/Imported 3 tasks\./, '3 tasks imported'); $output = qx{../src/task rc:import.rc list}; @@ -100,7 +100,7 @@ unlike ($output, qr/2.+B.+one/, 't2 missing'); like ($output, qr/9\/4\/2011.+two/, 't3 present'); # Make sure that a duplicate task cannot be imported. -$output = qx{../src/task rc:import.rc import import.json}; +$output = qx{../src/task rc:import.rc import import.json 2>&1 >/dev/null}; like ($output, qr/Cannot add task because the uuid '.{36}' is not unique\./, 'error on duplicate uuid'); # Create import file. @@ -125,7 +125,7 @@ EOF qx{../scripts/add-ons/import-yaml.pl import.json}; # Import the JSON. -$output = qx{../src/task rc:import.rc import import.json}; +$output = qx{../src/task rc:import.rc import import.json 2>&1 >/dev/null}; like ($output, qr/Imported 1 tasks\./, '1 task imported'); # Verify. diff --git a/test/nag.t b/test/nag.t index f564a6d4b..dacbe860f 100755 --- a/test/nag.t +++ b/test/nag.t @@ -47,12 +47,12 @@ my $setup = "../src/task rc:nag.rc add due:yesterday one;" . "../src/task rc:nag.rc add six;"; qx{$setup}; -like (qx{../src/task rc:nag.rc 6 do}, qr/NAG/, 'do pri: -> nag'); -like (qx{../src/task rc:nag.rc 5 do}, qr/NAG/, 'do pri:L -> nag'); -like (qx{../src/task rc:nag.rc 4 do}, qr/NAG/, 'do pri:M-> nag'); -like (qx{../src/task rc:nag.rc 3 do}, qr/NAG/, 'do pri:H-> nag'); -like (qx{../src/task rc:nag.rc 2 do}, qr/NAG/, 'do due:tomorrow -> nag'); -my $output = qx{../src/task rc:nag.rc 1 do}; +like (qx{../src/task rc:nag.rc 6 do 2>&1 >/dev/null}, qr/NAG/, 'do pri: -> nag'); +like (qx{../src/task rc:nag.rc 5 do 2>&1 >/dev/null}, qr/NAG/, 'do pri:L -> nag'); +like (qx{../src/task rc:nag.rc 4 do 2>&1 >/dev/null}, qr/NAG/, 'do pri:M-> nag'); +like (qx{../src/task rc:nag.rc 3 do 2>&1 >/dev/null}, qr/NAG/, 'do pri:H-> nag'); +like (qx{../src/task rc:nag.rc 2 do 2>&1 >/dev/null}, qr/NAG/, 'do due:tomorrow -> nag'); +my $output = qx{../src/task rc:nag.rc 1 do 2>&1 >/dev/null}; unlike ($output, qr/NAG/, 'do due:yesterday -> no nag'); # Cleanup. diff --git a/test/project.t b/test/project.t index 4ab6fcb46..9bb041ec8 100755 --- a/test/project.t +++ b/test/project.t @@ -40,30 +40,30 @@ if (open my $fh, '>', 'pro.rc') } # Test the project status numbers. -my $output = qx{../src/task rc:pro.rc add one pro:foo}; +my $output = qx{../src/task rc:pro.rc add one pro:foo 2>&1 >/dev/null}; like ($output, qr/The project 'foo' has changed\. Project 'foo' is 0% complete \(1 of 1 tasks remaining\)\./, 'add one'); -$output = qx{../src/task rc:pro.rc add two pro:'foo'}; +$output = qx{../src/task rc:pro.rc add two pro:'foo' 2>&1 >/dev/null}; like ($output, qr/The project 'foo' has changed\. Project 'foo' is 0% complete \(2 of 2 tasks remaining\)\./, 'add two'); -$output = qx{../src/task rc:pro.rc add three pro:'foo'}; +$output = qx{../src/task rc:pro.rc add three pro:'foo' 2>&1 >/dev/null}; like ($output, qr/The project 'foo' has changed\. Project 'foo' is 0% complete \(3 of 3 tasks remaining\)\./, 'add three'); -$output = qx{../src/task rc:pro.rc add four pro:'foo'}; +$output = qx{../src/task rc:pro.rc add four pro:'foo' 2>&1 >/dev/null}; like ($output, qr/The project 'foo' has changed\. Project 'foo' is 0% complete \(4 of 4 tasks remaining\)\./, 'add four'); -$output = qx{../src/task rc:pro.rc 1 done}; +$output = qx{../src/task rc:pro.rc 1 done 2>&1 >/dev/null}; like ($output, qr/Project 'foo' is 25% complete \(3 of 4 tasks remaining\)\./, 'done one'); -$output = qx{../src/task rc:pro.rc 2 delete}; +$output = qx{../src/task rc:pro.rc 2 delete 2>&1 >/dev/null}; like ($output, qr/The project 'foo' has changed\. Project 'foo' is 33% complete \(2 of 3 tasks remaining\)\./, 'delete two'); -$output = qx{../src/task rc:pro.rc 3 modify pro:bar}; +$output = qx{../src/task rc:pro.rc 3 modify pro:bar 2>&1 >/dev/null}; like ($output, qr/The project 'foo' has changed\. Project 'foo' is 50% complete \(1 of 2 tasks remaining\)\./, 'change project'); like ($output, qr/The project 'bar' has changed\. Project 'bar' is 0% complete \(1 of 1 tasks remaining\)\./, 'change project'); # Test projects with spaces in them. -$output = qx{../src/task rc:pro.rc 3 modify pro:\\"foo bar\\"}; +$output = qx{../src/task rc:pro.rc 3 modify pro:\\"foo bar\\" 2>&1 >/dev/null}; like ($output, qr/The project 'foo bar' has changed\./, 'project with spaces'); # Cleanup. diff --git a/test/recur.until.t b/test/recur.until.t index d1e84b282..c627a362c 100755 --- a/test/recur.until.t +++ b/test/recur.until.t @@ -52,7 +52,7 @@ qx{../src/task rc:recur.rc 2 do}; qx{../src/task rc:recur.rc 3 do}; qx{../src/task rc:recur.rc 4 do}; qx{../src/task rc:recur.rc 5 do}; -$output = qx{../src/task rc:recur.rc list}; +$output = qx{../src/task rc:recur.rc list 2>&1 >/dev/null}; like ($output, qr/and was deleted/, 'Parent task deleted'); $output = qx{../src/task rc:recur.rc diag}; diff --git a/test/shadow.t b/test/shadow.t index 13f11adef..8150db3a4 100755 --- a/test/shadow.t +++ b/test/shadow.t @@ -42,16 +42,16 @@ if (open my $fh, '>', 'shadow.rc') ok (-r 'shadow.rc', 'Created shadow.rc'); } -my $output = qx{../src/task rc:shadow.rc add one}; +my $output = qx{../src/task rc:shadow.rc add one 2>&1 >/dev/null}; like ($output, qr/\[Shadow file '\.\/shadow\.txt' updated\.\]/, 'shadow file updated on add'); -$output = qx{../src/task rc:shadow.rc list}; +$output = qx{../src/task rc:shadow.rc list 2>&1 >/dev/null}; unlike ($output, qr/\[Shadow file '\.\/shadow\.txt' updated\.\]/, 'shadow file not updated on list'); -$output = qx{../src/task rc:shadow.rc 1 delete}; +$output = qx{../src/task rc:shadow.rc 1 delete 2>&1 >/dev/null}; like ($output, qr/\[Shadow file '\.\/shadow\.txt' updated\.\]/, 'shadow file updated on delete'); -$output = qx{../src/task rc:shadow.rc list}; +$output = qx{../src/task rc:shadow.rc list 2>&1 >/dev/null}; unlike ($output, qr/\[Shadow file '\.\/shadow\.txt' updated\.\]/, 'shadow file not updated on list'); # Inspect the shadow file. diff --git a/test/subproject.t b/test/subproject.t index c6059eb6e..81df4a28c 100755 --- a/test/subproject.t +++ b/test/subproject.t @@ -59,7 +59,7 @@ like ($output, qr/\bab\s*$/m, 'abc,ab,a,b | a -> ab'); $output = qx{../src/task rc:sp.rc list project:abc}; like ($output, qr/\babc\s*$/m, 'abc,ab,a,b | a -> abc'); -$output = qx{../src/task rc:sp.rc list project:abcd}; +$output = qx{../src/task rc:sp.rc list project:abcd 2>&1 >/dev/null}; like ($output, qr/No matches./, 'abc,ab,a,b | abcd -> nul'); # Cleanup. diff --git a/test/undo.t b/test/undo.t index 062f05eb7..cda982cf7 100755 --- a/test/undo.t +++ b/test/undo.t @@ -53,7 +53,7 @@ $output = qx{../src/task rc:undo.rc undo; ../src/task rc:undo.rc info 1}; ok (-r 'completed.data', 'completed.data created'); like ($output, qr/Status\s+Pending\n/, 'Pending'); -$output = qx{../src/task rc:undo.rc 1 do; ../src/task rc:undo.rc list}; +$output = qx{../src/task rc:undo.rc 1 do; ../src/task rc:undo.rc list 2>&1 >/dev/null}; like ($output, qr/No matches/, 'No matches'); # Cleanup. diff --git a/test/wait.t b/test/wait.t index 3f8f975a6..370f8a314 100755 --- a/test/wait.t +++ b/test/wait.t @@ -74,7 +74,7 @@ unlike ($output, qr/tomorrow/ms, 'waiting task invisible'); $output = qx{../src/task rc:wait.rc all status:waiting wait:tomorrow}; like ($output, qr/tomorrow/ms, 'waiting task visible when specifically queried'); -$output = qx{../src/task rc:wait.rc add Complain due:today wait:tomorrow}; +$output = qx{../src/task rc:wait.rc add Complain due:today wait:tomorrow 2>&1 >/dev/null}; like ($output, qr/Warning: You have specified that the 'wait' date is after the 'due' date\./, 'warning on wait after due'); # Cleanup.