Merge branch 'master' into 2.2.0

- merge of 2.1.2 release being now the current released version in
  master.

Conflicts:
	CMakeLists.txt
	NEWS
	test/bug.1104.t
	test/run_all
This commit is contained in:
Federico Hernandez 2012-09-18 22:58:59 +02:00
commit a3242f7b5b
19 changed files with 175 additions and 79 deletions

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}

View file

@ -30,14 +30,16 @@ use strict;
use warnings;
use File::Copy;
use File::Path;
use Test::More tests => 18;
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.
@ -68,25 +70,47 @@ if (open my $fh, '>', '2.rc')
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
# 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 two 2>&1};
$output = qx{../src/task rc:1.rc add four 2>&1};
ok ($? == 0, 'Exit status check');
$output = qx{../src/task rc:1.rc two done 2>&1};
$output = qx{../src/task rc:1.rc four done 2>&1};
ok ($? == 0, 'Exit status check');
$output = qx{../src/task rc:2.rc 1 done 2>&1};
$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 everywhere
# 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};
@ -102,8 +126,18 @@ 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);
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' &&
@ -116,13 +150,20 @@ ok (! -r '1/pending.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', 'dropbox'], 0, 1);
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 (const std::string& e) {t.diag (e);}

View file

@ -2,7 +2,7 @@
if [ x"$1" = x"--verbose" ];
then
for i in *.t *.t.exe
for i in ${TESTBLOB}
do
echo '#' $i
./$i > test.log 2>&1
@ -22,26 +22,26 @@ else
VRAMSTEG=`which vramsteg`
BAR=0
if [ -x "$VRAMSTEG" ]; then
BAR=1
COUNT=0
TOTAL=`ls *.t | wc -l`
START=`$VRAMSTEG --now`
BAR=1
COUNT=0
TOTAL=`ls ${TESTBLOB} | wc -l`
START=`$VRAMSTEG --now`
fi
for i in *.t *.t.exe
for i in ${TESTBLOB}
do
echo '#' $i >>all.log
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
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
./$i >> all.log 2>&1
done
if [ $BAR -eq 1 ]; then
$VRAMSTEG --remove
$VRAMSTEG --remove
fi
date >> all.log