Compare commits

...

22 Commits

Author SHA1 Message Date
Federico Hernandez
1e3176ed70 Version number and release date for 2.1.2 2012-09-18 21:07:43 +02:00
Pietro Cerutti
1c5068edb2 Bug
- Fixed bug where shadow files are not properly created when there is a missing
  .taskrc file.

Signed-off-by: Paul Beckingham <paul@beckingham.net>
2012-09-18 07:50:55 -04:00
Federico Hernandez
eb09f4da9a Unit tests
- removed special characters in the logging output that
  disturbed the correct counting of ok unit tests when
  using flod.
2012-09-15 00:20:00 +02:00
Federico Hernandez
112d0d8771 Unit tests
- portability to help flod
2012-09-12 00:00:54 +02:00
Federico Hernandez
31bbc0ea2f Unit testing
- verbose unit testing to help flod tinderbox in displaying the results.
2012-09-11 22:38:40 +02:00
Paul Beckingham
8cd43ce2b2 Chase warning due to the opaque type time_t in printf
Signed-off-by: Paul Beckingham <paul@beckingham.net>

Conflicts:
	src/Duration.cpp
2012-09-11 20:58:16 +02:00
Johannes Schlatow
bbd8a9556e Merge branch '2.1.2' of tasktools.org:task into 2.1.2 2012-09-10 23:42:30 +02:00
Johannes Schlatow
68c1ca3f69 Bug #1104
Fixed the bug where the sort order of transactions with equal timestamps
 was not stable, i.e. due to the lack of a total order, different merges
 produced different sortings and hence messed up transactions which
 have already been merged.
2012-09-10 22:53:44 +02:00
Paul Beckingham
d868294d90 Unit Tests
- Corrected FreeBSD rx unit tests.

Conflicts:
	test/rx.t.cpp
2012-09-10 22:41:34 +02:00
Paul Beckingham
36e3317907 Prebuild
- Removed obsolete WIN32 reference that causes lots of verbose warnings
  from cmake.
2012-09-10 22:40:51 +02:00
Federico Hernandez
da37c08dbd Documentation
- bumped information in related files to 2.1.2
2012-09-10 21:45:49 +02:00
Federico Hernandez
89a7f2a459 Unit tests
- run_all should also look for *.t.exe files on cygwin
2012-09-10 21:07:05 +02:00
Johannes Schlatow
98da8ddcb8 Bug #1104
Added unit test.

 Implemented a quick fix for the issue with a broken branch-off algorithm
 which disregarded the transaction boundaries in the undo.data file.
2012-09-10 20:33:32 +02:00
Federico Hernandez
cf634a22c9 Bumped version number to 2.1.2 2012-09-10 20:27:05 +02:00
taskwarrior
4400a6f6ca Added SHA1 of tagged release commit 2012-07-25 01:34:38 +02:00
Federico Hernandez
46c5f8b826 Bumped version number to 2.1.1 in cheat sheet 2012-07-24 23:58:21 +02:00
Federico Hernandez
254d5c6fd7 Version number and release date for 2.1.1 2012-07-24 23:41:11 +02:00
Louis-Claude Canon
c71146611c Bug #1036
- Remove the test that prevents 'until' attributes to be modified for
  non-recurring tasks (thanks to Stéphane Pezennec).
- Unit test.

Signed-off-by: Paul Beckingham <paul@beckingham.net>
2012-07-24 16:55:59 -04:00
Scott Kostyshak
99849e55b4 Documentation
- Man page corrections.

Signed-off-by: Paul Beckingham <paul@beckingham.net>
2012-07-24 16:28:07 -04:00
Paul Beckingham
c247cf11ad Documentation
- Added #734 to ChangeLog.
2012-07-24 08:31:55 -04:00
Paul Beckingham
28e66a28aa Bug
- Fixed bug that caused miplaced commas in JSON export (thanks to greenskeleton).
2012-07-23 23:31:45 -04:00
Federico Hernandez
98fbd28501 Added SHA1 of tagged release commit 2012-07-23 22:59:42 +02:00
29 changed files with 463 additions and 146 deletions

View File

@@ -152,4 +152,5 @@ suggestions:
Stanley G
Marek Vitek
Rene Vergara
Stéphane Pezennec

View File

@@ -1,5 +1,4 @@
cmake_minimum_required (VERSION 2.8)
set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required
include (CheckFunctionExists)
include (CheckStructHasMember)
@@ -7,7 +6,7 @@ include (CheckStructHasMember)
set (HAVE_CMAKE true)
project (task)
set (PROJECT_VERSION "2.1.0")
set (PROJECT_VERSION "2.1.2")
SET (TASK_MAN1DIR share/man/man1 CACHE STRING "Installation directory for man pages, section 1")
SET (TASK_MAN5DIR share/man/man5 CACHE STRING "Installation directory for man pages, section 5")

View File

@@ -1,7 +1,23 @@
------ current release ---------------------------
2.1.0 (2012-07-23)
2.1.2 (2012-09-18)
Bugs
+ Bug fix release regarding #1104, which causes duplicate UUIDs during
the merge command.
+ Fixed bug where shadow files are not properly created when there is a missing
.taskrc file (thanks to Pietro Cerutti).
------ old releases ------------------------------
2.1.1 (2012-07-24) 46c5f8b826838ce96d9df7fcd3039de3c43483dd
Bugs
+ Fixed bug that caused miplaced commas in JSON export (thanks to greenskeleton).
+ Fixed bug #1036, which prevents 'until' attributes to be modified for
non-recurring tasks (thanks to Stéphane Pezennec).
2.1.0 (2012-07-23) a413331c9450b48065f94639e7ab0455eaa74293
Features
+ Feature #164, #325, #339, #435, #553, #554, #975, User Defined Attributes.
@@ -41,6 +57,8 @@ Features
+ Color error messages with a specific configuration variable 'color.error'.
Bugs
+ Fixed bug #734, which allows a sequence of IDs to work when modifying the
attribute "depends" (thanks to Andreas Kalex).
+ Applied patch for bug #919, so the holidays listed on the 'calendar' report
are sorted (thanks to Jörg Plate).
+ Fixed bug #954, which caused bulk deletions when using a UUID filter term and
@@ -116,8 +134,6 @@ Bugs
+ Fixed bug #1032, which prevented negative urgency coefficients from working
for projects and tags.
------ old releases ------------------------------
2.0.0 (2012-03-17) 03799eba9f230e48c4fa6d6ebddabe91bef7998f
# Untracked Features, biggest first.

33
NEWS
View File

@@ -1,34 +1,21 @@
New Features in taskwarrior 2.1.0
New bug fixes in taskwarrior 2.1.2
- The new 'project.indented' format is available and used in the 'projects'
and 'summary' commands.
- Support for the 'scheduled' date for a task, which represent the earliest
opportunity to work on a task.
- All tasks may now be given an 'until' date, after which they will expire
and are deleted.
- Improved UTF8 handling for wide characters.
- User defined attributes.
- Partial UUIDs must now be at least 14 characters, up from 9. This
disambiguates a commonly date format.
- Important bug fix release regarding duplicate UUIDs during the merge command.
Please refer to the ChangeLog file for full details. There are too many to
list here.
New features in taskwarrior 2.1.2
New commands in taskwarrior 2.1.0
- None
- New 'ready' report that lists tasks ready for work, sorted by urgency.
- New 'udas' command shows UDA details and warnings.
- New '_udas' helper command lists UDA names for completion purposes.
New commands in taskwarrior 2.1.2
New configuration options in taskwarrior 2.1.0
- None
- urgency.scheduled.coefficient
- urgency.uda.<name>.coefficient
- color.scheduled
- color.blocking
New configuration options in taskwarrior 2.1.2
Newly deprecated features in taskwarrior 2.1.0
- None
Newly deprecated features in taskwarrior 2.1.2
- None

View File

@@ -39,7 +39,6 @@ Override PACKAGE_LANGUAGE, then
#cmakedefine NETBSD
#cmakedefine HAIKU
#cmakedefine SOLARIS
#cmakedefine WIN32
#cmakedefine UNKNOWN
/* Found the lua library */

View File

@@ -1,4 +1,4 @@
.TH task-color 5 2012-07-23 "${PACKAGE_STRING}" "User Manuals"
.TH task-color 5 2012-09-18 "${PACKAGE_STRING}" "User Manuals"
.SH NAME
task-color \- A color tutorial for the taskwarrior command line todo manager.

View File

@@ -1,4 +1,4 @@
.TH task-faq 5 2012-07-23 "${PACKAGE_STRING}" "User Manuals"
.TH task-faq 5 2012-09-18 "${PACKAGE_STRING}" "User Manuals"
.SH NAME
task-faq \- A FAQ for the task(1) command line todo manager.

View File

@@ -1,4 +1,4 @@
.TH task-sync 5 2012-07-23 "${PACKAGE_STRING}" "User Manuals"
.TH task-sync 5 2012-09-18 "${PACKAGE_STRING}" "User Manuals"
.SH NAME
task-sync \- A tutorial for the task(1) data synchronization capabilities.

View File

@@ -1,4 +1,4 @@
.TH task-tutorial 5 2012-07-23 "${PACKAGE_STRING}" "User Manuals"
.TH task-tutorial 5 2012-09-18 "${PACKAGE_STRING}" "User Manuals"
.SH NAME
task-tutorial \- A tutorial for the task(1) command line todo manager.

View File

@@ -1,4 +1,4 @@
.TH task 1 2012-07-23 "${PACKAGE_STRING}" "User Manuals"
.TH task 1 2012-09-18 "${PACKAGE_STRING}" "User Manuals"
.SH NAME
task \- A command line todo manager.
@@ -18,13 +18,11 @@ At the core, taskwarrior is a list processing program. You add text and
additional related parameters and redisplay the information in a nice way. It
turns into a todo list program when you add due dates and recurrence. It turns
into an organized todo list program when you add priorities, tags (one word
descriptors), project groups, etc. Taskwarrior turns into an organized to do
list program when you modify the configuration file to have the output displayed
the way you want to see it.
descriptors), project groups, etc.
.SH FILTER
The <filter> consists of zero or more search criteria that select tasks. For
example, to list all tasks belonging to the 'Home' project:
example, to list all pending tasks belonging to the 'Home' project:
task project:Home list

View File

@@ -1,4 +1,4 @@
.TH taskrc 5 2012-07-23 "${PACKAGE_STRING}" "User Manuals"
.TH taskrc 5 2012-09-18 "${PACKAGE_STRING}" "User Manuals"
.SH NAME
taskrc \- Configuration file for the task(1) command
@@ -280,7 +280,7 @@ and project. The others are sent to standard output.
.B confirmation=yes
May be "yes" or "no", and determines whether taskwarrior will ask for
confirmation before deleting a task, performing bulk changes, or the undo
command. The default value is "yes". Consider leaving this setting as "no",
command. The default value is "yes". Consider leaving this setting as "yes",
for safety.
.TP
@@ -1196,8 +1196,7 @@ An optional value to a report limiting the number of displayed tasks in the
generated report. Deprecated.
.TP
Taskwarrior comes with a number of predefined reports in its default
configuration file. These reports are:
Taskwarrior comes with a number of predefined reports, which are:
.TP
.B next
@@ -1205,7 +1204,7 @@ Lists the most important tasks.
.TP
.B long
Lists all tasks and all data, matching the specified criteria.
Lists all pending tasks and all data, matching the specified criteria.
.TP
.B list

Binary file not shown.

Binary file not shown.

View File

@@ -503,6 +503,7 @@ void Context::shadow ()
{
std::string file_name = config.get ("shadow.file");
std::string command = config.get ("shadow.command");
std::string rcfile = rc_file;
// A missing shadow file command uses the default command instead.
if (command == "")
@@ -534,13 +535,14 @@ void Context::shadow ()
// Compose the command. Put the rc overrides up front, so that they may
// be overridden by rc.shadow.command.
command = program +
" rc.detection:off" + // No need to determine terminal size
" rc.color:off" + // Color off by default
" rc.gc:off " + // GC off, to reduce headaches
command + // User specified command
" >" + // Capture
shadow_file._data; // User specified file
command = program +
" rc.detection:off" + // No need to determine terminal size
" rc.color:off" + // Color off by default
" rc.gc:off " + // GC off, to reduce headaches
" rc:" + rcfile + " " + // Use specified rc file
command + // User specified command
" >" + // Capture
shadow_file._data; // User specified file
debug ("Running shadow command: " + command);
system (command.c_str ());

View File

@@ -308,7 +308,7 @@ std::string Duration::formatPrecise () const
std::string Duration::formatSeconds () const
{
char formatted[24];
sprintf (formatted, "%s%ldsec", (_negative ? "-" : ""), _secs);
sprintf (formatted, "%s%llusec", (_negative ? "-" : ""), (unsigned long long)_secs);
return std::string (formatted);
}

View File

@@ -759,6 +759,10 @@ void TDB2::merge (const std::string& mergeFile)
break;
}
}
else
{
undo_lines.push_back (lline + "\n");
}
// Add some color.
Color colorAdded (context.config.get ("color.sync.added"));
@@ -768,10 +772,12 @@ void TDB2::merge (const std::string& mergeFile)
// at this point we can assume: (lline==rline) || (lit == l.end())
// thus we search for the first non-equal lines or the EOF
bool found = false;
for ( ; (lit != l.end ()) && (rit != r.end ()); ++lit, ++rit)
for (std::vector<std::string>::const_iterator tmp_lit = lit, tmp_rit = rit;
(tmp_lit != l.end ()) && (tmp_rit != r.end ());
++tmp_lit, ++tmp_rit)
{
lline = *lit;
rline = *rit;
lline = *tmp_lit;
rline = *tmp_rit;
// found first non-matching lines?
if (lline.compare (rline) != 0)
@@ -779,13 +785,28 @@ void TDB2::merge (const std::string& mergeFile)
found = true;
break;
}
else
else if (tmp_lit->substr (0, 3) == "---")
{
// push the line to the new undo.data
undo_lines.push_back (lline + "\n");
while (lit != tmp_lit)
{
++lit;
++rit;
undo_lines.push_back(*lit + "\n");
}
// at this point, all iterators (tmp_{lit,rit}, lit and rit) are at the same line
}
}
if (!found)
{
// set iterators to r.end() or l.end() if they are point to the last line
if (++rit != r.end())
--rit;
if (++lit != l.end())
--lit;
}
///////////////////////////////////////
// branch-off point found:
if (found)
@@ -1003,8 +1024,8 @@ void TDB2::merge (const std::string& mergeFile)
mods.splice (mods.begin (), rmods);
DEBUG_STR ("sorting taskmod list");
mods.sort ();
mods_history.sort ();
mods.sort (compareTaskmod);
mods_history.sort (compareTaskmod);
}
else if (rit == r.end ())
{
@@ -1211,7 +1232,7 @@ void TDB2::merge (const std::string& mergeFile)
// at this point undo contains the lines up to the branch-off point
// now we merge mods (new modifications from mergefile)
// with lmods (part of old undo.data)
lmods.sort();
lmods.sort(compareTaskmod);
mods.merge (lmods);
mods.merge (mods_history);
@@ -1883,3 +1904,4 @@ void TDB2::dump ()
}
////////////////////////////////////////////////////////////////////////////////
// vim: ts=2 et sw=2

View File

@@ -33,22 +33,38 @@
#include <assert.h>
#include <Taskmod.h>
unsigned long Taskmod::curSequenceNumber = 0;
bool compareTaskmod (Taskmod first, Taskmod second)
{
if (first._timestamp == second._timestamp)
{
return first._sequenceNumber < second._sequenceNumber;
}
else
{
return first._timestamp < second._timestamp;
}
}
////////////////////////////////////////////////////////////////////////////////
Taskmod::Taskmod ()
{
_timestamp = 0;
_bAfterSet = false;
_bBeforeSet = false;
_sequenceNumber = curSequenceNumber++;
}
////////////////////////////////////////////////////////////////////////////////
Taskmod::Taskmod (const Taskmod& other)
{
this->_before = other._before;
this->_after = other._after;
this->_timestamp = other._timestamp;
this->_bAfterSet = other._bAfterSet;
this->_bBeforeSet = other._bBeforeSet;
this->_before = other._before;
this->_after = other._after;
this->_timestamp = other._timestamp;
this->_bAfterSet = other._bAfterSet;
this->_bBeforeSet = other._bBeforeSet;
this->_sequenceNumber = other._sequenceNumber;
}
////////////////////////////////////////////////////////////////////////////////
@@ -87,11 +103,12 @@ Taskmod& Taskmod::operator= (const Taskmod& other)
{
if (this != &other)
{
this->_before = other._before;
this->_after = other._after;
this->_timestamp = other._timestamp;
this->_bAfterSet = other._bAfterSet;
this->_bBeforeSet = other._bBeforeSet;
this->_before = other._before;
this->_after = other._after;
this->_timestamp = other._timestamp;
this->_bAfterSet = other._bAfterSet;
this->_bBeforeSet = other._bBeforeSet;
this->_sequenceNumber = other._sequenceNumber;
}
return *this;
@@ -100,9 +117,10 @@ Taskmod& Taskmod::operator= (const Taskmod& other)
////////////////////////////////////////////////////////////////////////////////
void Taskmod::reset (long timestamp)
{
this->_bAfterSet = false;
this->_bBeforeSet = false;
this->_timestamp = timestamp;
this->_bAfterSet = false;
this->_bBeforeSet = false;
this->_timestamp = timestamp;
this->_sequenceNumber = curSequenceNumber++;
}
////////////////////////////////////////////////////////////////////////////////
@@ -177,6 +195,12 @@ void Taskmod::setTimestamp (long timestamp)
this->_timestamp = timestamp;
}
////////////////////////////////////////////////////////////////////////////////
void Taskmod::incSequenceNumber ()
{
this->_sequenceNumber++;
}
////////////////////////////////////////////////////////////////////////////////
Task& Taskmod::getAfter ()
{
@@ -195,6 +219,12 @@ long Taskmod::getTimestamp () const
return _timestamp;
}
////////////////////////////////////////////////////////////////////////////////
unsigned long Taskmod::getSequenceNumber () const
{
return _sequenceNumber;
}
////////////////////////////////////////////////////////////////////////////////
std::string Taskmod::getTimeStr () const
{

View File

@@ -33,6 +33,8 @@
#include <Task.h>
class Taskmod {
friend bool compareTaskmod (Taskmod first, Taskmod second);
public:
Taskmod ();
Taskmod (const Taskmod& other);
@@ -59,11 +61,13 @@ public:
void setAfter (const Task& after);
void setBefore (const Task& before);
void setTimestamp (long timestamp);
void incSequenceNumber ();
// getter
Task& getAfter ();
Task& getBefore ();
long getTimestamp () const;
unsigned long getSequenceNumber () const;
std::string getTimeStr () const;
protected:
@@ -72,7 +76,12 @@ protected:
long _timestamp;
bool _bAfterSet;
bool _bBeforeSet;
unsigned long _sequenceNumber;
static unsigned long curSequenceNumber;
};
bool compareTaskmod (Taskmod first, Taskmod second);
#endif

View File

@@ -66,14 +66,15 @@ int CmdExport::execute (std::string& output)
std::vector <Task>::iterator task;
for (task = filtered.begin (); task != filtered.end (); ++task)
{
output += task->composeJSON (true);
if (task != filtered.begin ())
output += ",";
output += ",\n";
output += "\n";
output += task->composeJSON (true);
}
if (filtered.size ())
output += "\n";
if (json_array)
output += "]\n";

View File

@@ -83,11 +83,6 @@ int CmdModify::execute (std::string& output)
!before.has ("due"))
throw std::string (STRING_CMD_MODIFY_NO_DUE);
if (task->has ("until") &&
!task->has ("recur") &&
!before.has ("recur"))
throw std::string (STRING_CMD_MODIFY_UNTIL);
if (before.has ("recur") &&
before.has ("due") &&
(!task->has ("due") ||

View File

@@ -448,7 +448,6 @@
#define STRING_CMD_MODIFY_USAGE1 "Modifies the existing task with provided arguments."
#define STRING_CMD_MODIFY_NO_DUE "You cannot specify a recurring task without a due date."
#define STRING_CMD_MODIFY_UNTIL "You cannot specify an until date for a non-recurring task."
#define STRING_CMD_MODIFY_REM_DUE "You cannot remove the due date from a recurring task."
#define STRING_CMD_MODIFY_REC_ALWAYS "You cannot remove the recurrence from a recurring task."
#define STRING_CMD_MODIFY_TASK "Modifying task {1} '{2}'."

1
test/.gitignore vendored
View File

@@ -26,3 +26,4 @@ view.t
json_test
run_all

View File

@@ -10,7 +10,17 @@ set (test_SRCS autocomplete.t color.t config.t date.t directory.t dom.t
duration.t file.t i18n.t json.t list.t nibbler.t path.t rx.t
t.t t2.t taskmod.t tdb2.t text.t uri.t util.t view.t json_test)
add_custom_target (test ./run_all DEPENDS ${test_SRCS} task_executable
message ("-- Configuring run_all")
set (TESTBLOB "*.t")
if (CYGWIN)
set (TESTBLOB "*.t *.t.exe")
endif (CYGWIN)
configure_file (
${CMAKE_SOURCE_DIR}/test/run_all.in
${CMAKE_SOURCE_DIR}/test/run_all)
add_custom_target (test ./run_all --verbose
DEPENDS ${test_SRCS} task_executable
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/test)
add_custom_target (build_tests DEPENDS ${test_SRCS}

63
test/bug.1036.t Executable file
View File

@@ -0,0 +1,63 @@
#! /usr/bin/perl
################################################################################
## taskwarrior - a command line task list manager.
##
## Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
##
## Permission is hereby granted, free of charge, to any person obtaining a copy
## of this software and associated documentation files (the "Software"), to deal
## in 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:
##
## The above copyright notice and this permission notice shall be included
## in all copies or substantial portions of the Software.
##
## 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 AUTHORS 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 IN THE
## SOFTWARE.
##
## http://www.opensource.org/licenses/mit-license.php
##
################################################################################
use strict;
use warnings;
use Test::More tests => 4;
# Create the rc file.
if (open my $fh, '>', 'bug.rc')
{
print $fh "data.location=.\n";
close $fh;
ok (-r 'bug.rc', 'Created bug.rc');
}
# Bug #1036: prevents 'until' attributes to be modified for non-recurring
# tasks.
# Check that until attribute may be modified
qx{../src/task rc:bug.rc add test 2>&1};
my $output = qx{../src/task rc:bug.rc 1 mod until:1/1/2020 2>&1};
like ($output, qr/^Modifying task 1 'test'.$/ms, '"until" attribute added');
qx{../src/task rc:bug.rc add test until:1/1/2020 2>&1};
$output = qx{../src/task rc:bug.rc 1 mod /test/Test/ 2>&1};
like ($output, qr/^Modifying task 1 'Test'.$/ms, 'Task with "until" attribute modified');
# Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data synch.key bug.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'synch.key' &&
! -r 'bug.rc', 'Cleanup');
exit 0;

169
test/bug.1104.t Executable file
View File

@@ -0,0 +1,169 @@
#! /usr/bin/env perl
################################################################################
## taskwarrior - a command line task list manager.
##
## Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
##
## Permission is hereby granted, free of charge, to any person obtaining a copy
## of this software and associated documentation files (the "Software"), to deal
## in 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:
##
## The above copyright notice and this permission notice shall be included
## in all copies or substantial portions of the Software.
##
## 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 AUTHORS 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 IN THE
## SOFTWARE.
##
## http://www.opensource.org/licenses/mit-license.php
##
################################################################################
use strict;
use warnings;
use File::Copy;
use File::Path;
use Test::More tests => 28;
mkdir("1", 0755);
mkdir("2", 0755);
mkdir("3", 0755);
mkdir("dropbox", 0755);
ok (-e "1", 'Created directory 1/');
ok (-e "2", 'Created directory 2/');
ok (-e "3", 'Created directory 3/');
ok (-e "dropbox", 'Created directory dropbox/');
# Create the rc file.
if (open my $fh, '>', '1.rc')
{
print $fh "data.location=1/\n";
print $fh "confirmation=no\n";
print $fh "merge.autopush=yes\n";
print $fh "merge.default.uri=./dropbox/\n";
print $fh "push.default.uri=./dropbox/\n";
print $fh "pull.default.uri=./dropbox/\n";
close $fh;
ok (-r '1.rc', 'Created 1.rc');
}
# Create the rc file.
if (open my $fh, '>', '2.rc')
{
print $fh "data.location=2/\n";
print $fh "confirmation=no\n";
print $fh "merge.autopush=yes\n";
print $fh "merge.default.uri=./dropbox/\n";
print $fh "push.default.uri=./dropbox/\n";
print $fh "pull.default.uri=./dropbox/\n";
close $fh;
ok (-r '2.rc', 'Created 2.rc');
}
# Create the rc file.
if (open my $fh, '>', '3.rc')
{
print $fh "data.location=3/\n";
print $fh "confirmation=no\n";
print $fh "merge.autopush=yes\n";
print $fh "merge.default.uri=./dropbox/\n";
print $fh "push.default.uri=./dropbox/\n";
print $fh "pull.default.uri=./dropbox/\n";
close $fh;
ok (-r '3.rc', 'Created 3.rc');
}
# Once-only push from 1 --> dropbox
my $output = qx{../src/task rc:1.rc add one 2>&1};
ok ($? == 0, 'Exit status check');
$output = qx{../src/task rc:1.rc add two 2>&1};
ok ($? == 0, 'Exit status check');
$output = qx{../src/task rc:1.rc add three 2>&1};
ok ($? == 0, 'Exit status check');
$output = qx{../src/task rc:1.rc push 2>&1};
ok ($? == 0, 'Exit status check');
# Merges to 2 and 3
$output = qx{../src/task rc:2.rc merge 2>&1};
ok ($? == 0, 'Exit status check');
$output = qx{../src/task rc:3.rc merge 2>&1};
ok ($? == 0, 'Exit status check');
# Make a different change in both locations
$output = qx{../src/task rc:1.rc add four 2>&1};
ok ($? == 0, 'Exit status check');
$output = qx{../src/task rc:1.rc four done 2>&1};
ok ($? == 0, 'Exit status check');
$output = qx{../src/task rc:2.rc one done 2>&1};
ok ($? == 0, 'Exit status check');
$output = qx{../src/task rc:3.rc three delete 2>&1};
ok ($? == 0, 'Exit status check');
# Merges 1 and 2
$output = qx{../src/task rc:1.rc merge 2>&1};
ok ($? == 0, 'Exit status check');
$output = qx{../src/task rc:2.rc merge 2>&1};
ok ($? == 0, 'Exit status check');
# see if undo.data is corrupt
$output = qx{cat 2/undo.data};
unlike ($output, qr/time 0/, "undo.data corrupt");
# merge again in order to stimulate duplications
$output = qx{../src/task rc:1.rc merge 2>&1};
ok ($? == 0, 'Exit status check');
$output = qx{../src/task rc:1.rc diag 2>&1};
unlike ($output, qr/Found duplicate/, "Found duplicate");
# Merges 3
$output = qx{../src/task rc:3.rc merge 2>&1};
ok ($? == 0, 'Exit status check');
unlike ($output, qr/Retaining/, "Must not retain changes");
# Merges 1
$output = qx{../src/task rc:1.rc merge 2>&1};
ok ($? == 0, 'Exit status check');
unlike ($output, qr/Retaining/, "Must not retain changes");
# Cleanup.
unlink qw(1.rc 1/pending.data 1/completed.data 1/undo.data 1/backlog.data 1/synch.key 2/pending.data 2/completed.data 2/undo.data 2.rc 2/backlog.data 2/synch.key dropbox/completed.data dropbox/pending.data dropbox/undo.data 3/pending.data 3/undo.data 3/completed.data 3/backlog.data 3/synch.key 3.rc);
ok (! -r '1/pending.data' &&
! -r '1/completed.data' &&
! -r '1/undo.data' &&
! -r '1/backlog.data' &&
! -r '1/synch.key' &&
! -r '1.rc' &&
! -r '2/pending.data' &&
! -r '2/completed.data' &&
! -r '2/undo.data' &&
! -r '2/backlog.data' &&
! -r '2/synch.key' &&
! -r '2.rc' &&
! -r '3/pending.data' &&
! -r '3/completed.data' &&
! -r '3/undo.data' &&
! -r '3/backlog.data' &&
! -r '3/synch.key' &&
! -r '3.rc' &&
! -r 'dropbox/pending.data' &&
! -r 'dropbox/completed.data' &&
! -r 'dropbox/undo.data' , 'Cleanup');
rmtree (['1', '2', '3', 'dropbox'], 0, 1);
ok (! -e '1' &&
! -e '2' &&
! -e '3' &&
! -e 'dropbox', 'Removed directories');
exit 0;

View File

@@ -142,37 +142,37 @@ int main (int argc, char** argv)
try
{
// Regular unit tests.
t.is (json::encode ("1\b2"), "1\\b2", "json::encode \\b -> \\\\b");
t.is (json::decode ("1\\b2"), "1\b2", "json::decode \\\\b -> \\b");
t.is (json::encode ("1\b2"), "1\\b2", "json::encode slashslashb -> slashslashslashslashb");
t.is (json::decode ("1\\b2"), "1\b2", "json::decode slashslashslashslashb -> slashslashb");
t.is (json::encode ("1\n2"), "1\\n2", "json::encode \\n -> \\\\n");
t.is (json::decode ("1\\n2"), "1\n2", "json::decode \\\\n -> \\n");
t.is (json::encode ("1\n2"), "1\\n2", "json::encode slashslashn -> slashslashslashslashn");
t.is (json::decode ("1\\n2"), "1\n2", "json::decode slashslashslashslashn -> slashslashn");
t.is (json::encode ("1\r2"), "1\\r2", "json::encode \\r -> \\\\r");
t.is (json::decode ("1\\r2"), "1\r2", "json::decode \\\\r -> \\r");
t.is (json::encode ("1\r2"), "1\\r2", "json::encode slashslashr -> slashslashslashslashr");
t.is (json::decode ("1\\r2"), "1\r2", "json::decode slashslashslashslashr -> slashslashr");
t.is (json::encode ("1\t2"), "1\\t2", "json::encode \\t -> \\\\t");
t.is (json::decode ("1\\t2"), "1\t2", "json::decode \\\\t -> \\t");
t.is (json::encode ("1\t2"), "1\\t2", "json::encode slashslasht -> slashslashslashslasht");
t.is (json::decode ("1\\t2"), "1\t2", "json::decode slashslashslashslasht -> slashslasht");
t.is (json::encode ("1\\2"), "1\\\\2", "json::encode \\ -> \\\\");
t.is (json::decode ("1\\\\2"), "1\\2", "json::decode \\\\ -> \\");
t.is (json::encode ("1\\2"), "1\\\\2", "json::encode slashslash -> slashslashslashslash");
t.is (json::decode ("1\\\\2"), "1\\2", "json::decode slashslashslashslash -> slashslash");
t.is (json::encode ("1\x2"), "1\x2", "json::encode \\x -> \\x (NOP)");
t.is (json::decode ("1\x2"), "1\x2", "json::decode \\x -> \\x (NOP)");
t.is (json::encode ("1\x2"), "1\x2", "json::encode slashslashx -> slashslashx(NOP)");
t.is (json::decode ("1\x2"), "1\x2", "json::decode slashslashx -> slashslashx(NOP)");
t.is (json::encode ("1€2"), "1€2", "json::encode € -> €");
t.is (json::decode ("1\\u20ac2"), "1€2", "json::decode \\u20ac -> €");
t.is (json::decode ("1\\u20ac2"), "1€2", "json::decode slashslashu20ac -> €");
std::string encoded = json::encode ("one\\");
t.is (encoded, "one\\\\", "json::encode one\\\\ -> one\\\\\\\\");
t.is ((int)encoded.length (), 5, "json::encode one\\\\ -> length 5");
t.is (encoded[0], 'o', "json::encode one\\\\[0] -> o");
t.is (encoded[1], 'n', "json::encode one\\\\[1] -> n");
t.is (encoded[2], 'e', "json::encode one\\\\[2] -> e");
t.is (encoded[3], '\\', "json::encode one\\\\[3] -> \\");
t.is (encoded[4], '\\', "json::encode one\\\\[4] -> \\");
t.is (encoded, "one\\\\", "json::encode oneslashslashslashslash -> oneslashslashslashslashslashslashslashslash");
t.is ((int)encoded.length (), 5, "json::encode oneslashslashslashslash -> length 5");
t.is (encoded[0], 'o', "json::encode oneslashslashslashslash[0] -> o");
t.is (encoded[1], 'n', "json::encode oneslashslashslashslash[1] -> n");
t.is (encoded[2], 'e', "json::encode oneslashslashslashslash[2] -> e");
t.is (encoded[3], '\\', "json::encode oneslashslashslashslash[3] -> slashslash");
t.is (encoded[4], '\\', "json::encode oneslashslashslashslash[4] -> slashslash");
t.is (json::decode (encoded), "one\\", "json::decode one\\\\\\\\ -> one\\\\");
t.is (json::decode (encoded), "one\\", "json::decode oneslashslashslashslashslashslashslashslash -> oneslashslashslashslash");
}
catch (std::string& e) {t.diag (e);}

View File

@@ -1,39 +0,0 @@
#! /bin/bash
date > all.log
STARTEPOCH=`perl -e 'print time'`
VRAMSTEG=/usr/local/bin/vramsteg
BAR=0
if [ -x $VRAMSTEG ]; then
BAR=1
COUNT=0
TOTAL=$(ls *.t | wc -l)
START=$($VRAMSTEG --now)
fi
for i in *.t
do
echo '#' $i >>all.log
if [ $BAR == 1 ]; then
$VRAMSTEG --label 'All tests' --min 0 --max $TOTAL --current $COUNT --percentage --start $START --estimate
COUNT=$[COUNT + 1]
fi
./$i >> all.log 2>&1
done
if [ $BAR == 1 ]; then
$VRAMSTEG --remove
fi
date >> all.log
ENDEPOCH=`perl -e 'print time'`
RUNTIME=$(($ENDEPOCH - $STARTEPOCH))
printf "Pass: %5d\n" $(grep -c ^ok all.log)
printf "Fail: %5d\n" $(grep -c ^not all.log)
printf "Skipped: %5d\n" $(grep -c ^skip all.log)
printf "Runtime: %5d seconds\n" $RUNTIME

56
test/run_all.in Executable file
View File

@@ -0,0 +1,56 @@
#! /bin/sh
if [ x"$1" = x"--verbose" ];
then
for i in ${TESTBLOB}
do
echo '#' $i
./$i > test.log 2>&1
while read LINE
do
echo $LINE
done < test.log
rm test.log
done
else
date > all.log
# Perl is used here to get the time in seconds
# because 'date +%s' isn't supported on Solaris.
STARTEPOCH=`perl -e 'print time'`
VRAMSTEG=`which vramsteg`
BAR=0
if [ -x "$VRAMSTEG" ]; then
BAR=1
COUNT=0
TOTAL=`ls ${TESTBLOB} | wc -l`
START=`$VRAMSTEG --now`
fi
for i in ${TESTBLOB}
do
echo '#' $i >>all.log
if [ $BAR -eq 1 ]; then
$VRAMSTEG --label 'All tests' --min 0 --max $TOTAL --current $COUNT --percentage --start $START --estimate
COUNT=`expr $COUNT + 1`
fi
./$i >> all.log 2>&1
done
if [ $BAR -eq 1 ]; then
$VRAMSTEG --remove
fi
date >> all.log
ENDEPOCH=`perl -e 'print time'`
RUNTIME=`expr $ENDEPOCH - $STARTEPOCH`
printf "Pass: %5d\n" `grep -c '^ok' all.log`
printf "Fail: %5d\n" `grep -c '^not' all.log`
printf "Skipped: %5d\n" `grep -c '^skip' all.log`
printf "Runtime: %5d seconds\n" $RUNTIME
fi

View File

@@ -88,7 +88,7 @@ int main (int argc, char** argv)
ut.ok (r9.match (start, end, text), "e there are matches");
ut.is (start.size (), (size_t) 6, "e == 6 matches");
#ifdef DARWIN
#if defined(DARWIN) || defined(CYGWIN) || defined(FREEBSD)
text = "this is the end.";
ut.pass (text + " =~ /\\bthe/");
ut.pass (text + " =~ /the\\b/");