diff --git a/src/export.cpp b/src/export.cpp index 29a3d94b1..d7e8e1606 100644 --- a/src/export.cpp +++ b/src/export.cpp @@ -80,6 +80,9 @@ int handleExportCSV (std::string &outs) outs = out.str (); context.hooks.trigger ("post-export-command"); + + // Prevent messages from cluttering the export output. + context.headers.clear (); } return rc; @@ -214,6 +217,9 @@ int handleExportiCal (std::string &outs) outs = out.str (); context.hooks.trigger ("post-export-command"); + + // Prevent messages from cluttering the export output. + context.headers.clear (); } return rc; @@ -249,6 +255,9 @@ int handleExportYAML (std::string &outs) outs = out.str (); context.hooks.trigger ("post-export-command"); + + // Prevent messages from cluttering the export output. + context.headers.clear (); } return rc; diff --git a/src/tests/export.yaml.t b/src/tests/export.yaml.t index 6ce6d49c5..0a5466e45 100755 --- a/src/tests/export.yaml.t +++ b/src/tests/export.yaml.t @@ -28,7 +28,7 @@ use strict; use warnings; -use Test::More tests => 22; +use Test::More tests => 21; # Create the rc file. if (open my $fh, '>', 'export.rc') @@ -50,23 +50,22 @@ if (open my $fh, '<', './export.txt') close $fh; } -like ($lines[0], qr/^Using alternate .+$/, 'export.yaml line 0'); -like ($lines[1], qr/^\%YAML 1\.1$/, 'export.yaml line 1'); -like ($lines[2], qr/^---$/, 'export.yaml line 2'); -like ($lines[3], qr/^ task:$/, 'export.yaml line 3'); -like ($lines[4], qr/^ description: one$/, 'export.yaml line 4'); -like ($lines[5], qr/^ entry: \d+$/, 'export.yaml line 5'); -like ($lines[6], qr/^ priority: H$/, 'export.yaml line 6'); -like ($lines[7], qr/^ project: A$/, 'export.yaml line 7'); -like ($lines[8], qr/^ status: pending$/, 'export.yaml line 8'); -like ($lines[9], qr/^ uuid: .+$/, 'export.yaml line 9'); -like ($lines[10], qr/^ task:$/, 'export.yaml line 10'); -like ($lines[11], qr/^ description: two$/, 'export.yaml line 11'); -like ($lines[12], qr/^ entry: \d+$/, 'export.yaml line 12'); -like ($lines[13], qr/^ status: pending$/, 'export.yaml line 13'); -like ($lines[14], qr/^ tags: tag1,tag2$/, 'export.yaml line 14'); -like ($lines[15], qr/^ uuid: .+$/, 'export.yaml line 15'); -like ($lines[16], qr/^\.\.\.$/, 'export.yaml line 16'); +like ($lines[0], qr/^\%YAML 1\.1$/, 'export.yaml line 1'); +like ($lines[1], qr/^---$/, 'export.yaml line 2'); +like ($lines[2], qr/^ task:$/, 'export.yaml line 3'); +like ($lines[3], qr/^ description: one$/, 'export.yaml line 4'); +like ($lines[4], qr/^ entry: \d+$/, 'export.yaml line 5'); +like ($lines[5], qr/^ priority: H$/, 'export.yaml line 6'); +like ($lines[6], qr/^ project: A$/, 'export.yaml line 7'); +like ($lines[7], qr/^ status: pending$/, 'export.yaml line 8'); +like ($lines[8], qr/^ uuid: .+$/, 'export.yaml line 9'); +like ($lines[9], qr/^ task:$/, 'export.yaml line 10'); +like ($lines[10], qr/^ description: two$/, 'export.yaml line 11'); +like ($lines[11], qr/^ entry: \d+$/, 'export.yaml line 12'); +like ($lines[12], qr/^ status: pending$/, 'export.yaml line 13'); +like ($lines[13], qr/^ tags: tag1,tag2$/, 'export.yaml line 14'); +like ($lines[14], qr/^ uuid: .+$/, 'export.yaml line 15'); +like ($lines[15], qr/^\.\.\.$/, 'export.yaml line 16'); # Cleanup. unlink 'export.txt'; diff --git a/src/tests/roundtrip.t b/src/tests/roundtrip.t new file mode 100755 index 000000000..79a3be630 --- /dev/null +++ b/src/tests/roundtrip.t @@ -0,0 +1,82 @@ +#! /usr/bin/perl +################################################################################ +## task - a command line task list manager. +## +## Copyright 2006 - 2010, Paul Beckingham. +## All rights reserved. +## +## This program is free software; you can redistribute it and/or modify it under +## the terms of the GNU General Public License as published by the Free Software +## Foundation; either version 2 of the License, or (at your option) any later +## version. +## +## This program is distributed in the hope that it will be useful, but WITHOUT +## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +## details. +## +## You should have received a copy of the GNU General Public License along with +## this program; if not, write to the +## +## Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, +## Boston, MA +## 02110-1301 +## USA +## +################################################################################ + +use strict; +use warnings; +use Test::More tests => 7; + +# Create the rc file. +if (open my $fh, '>', 'roundtrip.rc') +{ + print $fh "data.location=.\n", + "confirmation=no\n"; + close $fh; + ok (-r 'roundtrip.rc', 'Created roundtrip.rc'); +} + +# Add two tasks. +qx{../task rc:roundtrip.rc add priority:H project:A one}; +qx{../task rc:roundtrip.rc add +tag1 +tag2 two}; + +# trip 1. +qx{../task rc:roundtrip.rc export.yaml > ./roundtrip.txt}; +qx{../task rc:roundtrip.rc 1,2 delete}; +qx{../task rc:roundtrip.rc ls}; +qx{../task rc:roundtrip.rc import ./roundtrip.txt}; + +# trip 2. +qx{../task rc:roundtrip.rc export.yaml > ./roundtrip.txt}; +qx{../task rc:roundtrip.rc 1,2 delete}; +qx{../task rc:roundtrip.rc ls}; +qx{../task rc:roundtrip.rc import ./roundtrip.txt}; + +# Exammine. + +# ID Project Pri Added Started Due Recur Countdown Age Deps Tags Description +# -- ------- --- -------- ------- --- ----- --------- --- ---- --------- --------- +# 1 A H 8/7/2010 - one +# 2 8/7/2010 - tag1 tag2 two +my $output = qx{../task rc:roundtrip.rc long}; +like ($output, qr/1.+A.+H.+\d+\/\d+\/\d+.+(?:-|\d+).+one/, '2 round trips task 1 identical'); +like ($output, qr/2.+\d+\/\d+\/\d+.+(?:-|\d+).+tag1\stag2\stwo/, '2 round trips task 2 identical'); + +# Cleanup. +unlink 'roundtrip.txt'; +ok (!-r 'roundtrip.txt', 'Removed roundtrip.txt'); + +unlink 'pending.data'; +ok (!-r 'pending.data', 'Removed pending.data'); + +unlink 'undo.data'; +ok (!-r 'undo.data', 'Removed undo.data'); + +unlink 'roundtrip.rc'; +ok (!-r 'roundtrip.rc', 'Removed roundtrip.rc'); + +exit 0; +