# # # patch "mtn-tester" # from [6d8d533e38eb4956eeac8c13578ea67ac7461013] # to [5058f0ee4edb5c61843b0ac11bcacf77fa4184a6] # ============================================================ --- mtn-tester 6d8d533e38eb4956eeac8c13578ea67ac7461013 +++ mtn-tester 5058f0ee4edb5c61843b0ac11bcacf77fa4184a6 @@ -1,9 +1,14 @@ -#!/usr/bin/perl -w +#!/usr/bin/perl +# - You may need to comment the next line out or change it to where +# you have the Monotone::AutomateStdio library installed. + use lib "/home/aecoope/perl"; use strict; use integer; +use warnings; + use Carp qw(cluck); use File::Basename; use POSIX qw(strftime); @@ -27,16 +32,6 @@ my($data, @list, $mtn); -Monotone::AutomateStdio->register_error_handler - (MTN_SEVERITY_ALL, - sub - { - my($severity, $message) = @_; - printf(STDERR "\n\n====================\nPROBLEM (%s): %s\n", - $severity, $message); - cluck(); #die() if ($severity eq "error"); - }); - my @test_list = ({fn => \&Monotone::AutomateStdio::ancestors, desc => "ancestors", @@ -308,7 +303,8 @@ my @test_list = feat => MTN_GET_DB_VARIABLES, type => RECORD_LIST, prec => sub { - print("Adding test variables.\n"); + my @list; + print("Adding test variables.\n"); $mtn->set_db_variable("test-vars", "var1", "hello"); $mtn->set_db_variable("test-vars", "var2", "good bye"); $mtn->set_db_variable("TST-vars", @@ -578,8 +574,68 @@ my @test_list = "805c482bc9bb80cd393be7d3ba01a65377d91d9c", "afd43cf2ce01fa4513fb1673eae47be3b48008f6"]}); +print < tokens in the source code for pointers as to + what may need to change. + +4) Do not come complaining to me when you use this script and it trashes + something. You should always make backup copies anyway. :-). + +Ctrl-C now if you do not like the above! + +Tony Cooper. + +[Press to start the tests] +EOF +readline(STDIN); + +# - Enter your key id in the line below. + $mtn = Monotone::AutomateStdio->new(["--key" => "address@hidden"]); +$data = undef; +if ($mtn->can(MTN_DB_GET)) +{ + $data = undef if (! $mtn->db_get(\$data, "database", "default-server")); +} +else +{ + my @list; + $mtn->get_db_variables(address@hidden, "database"); + foreach my $entry (@list) + { + if ($entry->{name} eq "default-server") + { + $data = $entry->{value}; + last; + } + } +} +die("Your test database will sync to `" . $data . "' - this is unsafe") + if (defined($data)); + +Monotone::AutomateStdio->register_error_handler + (MTN_SEVERITY_ALL, + sub + { + my($severity, $message) = @_; + printf(STDERR "\n\n====================\nPROBLEM (%s): %s\n", + $severity, $message); + cluck(); + }); + foreach my $test (@test_list) { if (! exists($test->{feat}) || $mtn->can($test->{feat})) @@ -620,7 +676,6 @@ foreach my $test (@test_list) else { print(Dumper(\%hash)); - } } elsif ($test->{type} == RECORD_LIST) @@ -633,7 +688,6 @@ foreach my $test (@test_list) else { print($data); - } printf(" ---------- Structured Data ----------\n"); if (! $test->{fn}($mtn, address@hidden, @{$test->{args}})) @@ -643,7 +697,6 @@ foreach my $test (@test_list) else { print(Dumper(address@hidden)); - } } elsif ($test->{type} == VARIABLE) @@ -655,7 +708,6 @@ foreach my $test (@test_list) else { print("Variable = `" . $data . "'\n"); - } } elsif ($test->{type} == CODE)