[Bps-public-commit] Prophet branch, master, updated. 2c14f0773d6f3db89fe75d85de77f093bc7ba803
spang at bestpractical.com
spang at bestpractical.com
Fri Aug 7 20:03:16 EDT 2009
The branch, master has been updated
via 2c14f0773d6f3db89fe75d85de77f093bc7ba803 (commit)
via 6a384695507674d6c4d22cb01a587e6203139014 (commit)
via e34e46f20fc5c1086abff1fd566c1245292fe59c (commit)
via 2feede973489d022bef71c64d8427fc1d650dc02 (commit)
via ba037e4e17f6a39b664200721f11eb623d3ca25b (commit)
via c28db72d3e002dbdc0a929ad6e7b71905c23e9a9 (commit)
via 3bd4f3c1ae39acfc91090a1292ba61a3b71dd787 (commit)
via c5a133a0c02340042139ccbfc1dc8d1442a6adc9 (commit)
via f0d19d0dd807063089084a6b4826f268597cb767 (commit)
via c9dd80d54037088e3dfca8757d524cd2e4c5eb1f (commit)
via ca9416ffb434ecf616e3d5d63ad35ef11074b516 (commit)
from 4351f80fbbca15a2d46aa0c41808edff9ee53494 (commit)
Summary of changes:
lib/Prophet/CLI/Command/Info.pm | 2 +-
lib/Prophet/CLI/Command/Settings.pm | 6 ++-
lib/Prophet/CLI/PublishCommand.pm | 15 ++++++-
lib/Prophet/FilesystemReplica.pm | 3 +-
lib/Prophet/Record.pm | 6 ++-
lib/Prophet/Replica/sqlite.pm | 20 +++++----
lib/Prophet/Test.pm | 13 +++---
lib/Prophet/Test/Participant.pm | 1 +
t/Settings/lib/App/Settings/Test.pm | 34 +++++++++++++++
t/Settings/t/database-settings-editor.t | 71 ++++++++++++++-----------------
t/Settings/t/sync-database-settings.t | 55 +++++++++++++----------
t/aliases.t | 1 +
t/publish-pull.t | 42 +++++++-----------
t/real-conflicting-merge.t | 43 ++++++++-----------
t/simple-conflicting-merge.t | 68 ++++++++++++++++-------------
15 files changed, 215 insertions(+), 165 deletions(-)
create mode 100644 t/Settings/lib/App/Settings/Test.pm
- Log -----------------------------------------------------------------
commit ca9416ffb434ecf616e3d5d63ad35ef11074b516
Author: Christine Spang <spang at bestpractical.com>
Date: Thu Aug 6 17:22:51 2009 +0100
Make $Prophet::Replica::PROP_CACHE an object attribute.
I am entirely unconvinced that $PROP_CACHE in the sqlite backend should be a
package variable rather than an object attribute. If you're instantiating
a new handle object, you really probably do want the cache to be empty. If
you want the cache to persist, use the same CLI/handle objects (like the
shell command does). IMHO, all that having a package variable here gets
you is subtle and hard-to-track-down bugs and weird behaviour when
testing.
diff --git a/lib/Prophet/Replica/sqlite.pm b/lib/Prophet/Replica/sqlite.pm
index 3ad6b28..af10010 100644
--- a/lib/Prophet/Replica/sqlite.pm
+++ b/lib/Prophet/Replica/sqlite.pm
@@ -96,7 +96,11 @@ has '+resolution_db_handle' => (
},
);
-our $PROP_CACHE;
+has 'prop_cache' => (
+ is => 'rw',
+ isa => 'HashRef',
+ default => sub { {} },
+);
use constant scheme => 'sqlite';
use constant userdata_dir => 'userdata';
@@ -405,7 +409,7 @@ sub _delete_record_props_from_db {
my %args = validate( @_, { uuid => 1 } );
$self->dbh->do("DELETE FROM record_props where uuid = ?", {}, $args{uuid});
- delete $PROP_CACHE->{$args{uuid}};
+ delete $self->prop_cache->{$args{uuid}};
}
@@ -759,7 +763,7 @@ sub set_record_props {
$self->begin_edit() unless ($inside_edit);
# clear the cache before computing the diffs. this is probably paranoid
- delete $PROP_CACHE->{$args{uuid}};
+ delete $self->prop_cache->{$args{uuid}};
my $old_props = $self->get_record_props( uuid => $args{'uuid'}, type => $args{'type'});
my %new_props = %$old_props;
@@ -775,7 +779,7 @@ sub set_record_props {
$self->_write_record_to_db( type => $args{'type'}, uuid => $args{'uuid'}, props => \%new_props);
# Clear the cache now that we've actually written out changed props
- delete $PROP_CACHE->{$args{uuid}};
+ delete $self->prop_cache->{$args{uuid}};
my $change = Prophet::Change->new( { record_type => $args{'type'}, record_uuid => $args{'uuid'}, change_type => 'update_file' });
$change->add_prop_change( name => $_, old => $old_props->{$_}, new => $args{props}->{$_}) for (keys %{$args{props}});
@@ -789,13 +793,13 @@ sub get_record_props {
my $self = shift;
my %args = ( uuid => undef, type => undef, @_ )
; # validate is slooow validate( @_, { uuid => 1, type => 1 } );
- unless ( exists $PROP_CACHE->{ $args{uuid} } ) {
+ unless ( exists $self->prop_cache->{ $args{uuid} } ) {
my $sth = $self->dbh->prepare("SELECT prop, value from record_props WHERE uuid = ?");
$sth->execute( $args{uuid} );
my $items = $sth->fetchall_arrayref;
- $PROP_CACHE->{ $args{uuid} } = {map {@$_} @$items};
+ $self->prop_cache->{ $args{uuid} } = {map {@$_} @$items};
}
- return $PROP_CACHE->{ $args{uuid} };
+ return $self->prop_cache->{ $args{uuid} };
}
sub record_exists {
@@ -837,7 +841,7 @@ sub list_records {
for my $uuid (keys %found) {
my $record = $args{record_class}->new( { app_handle => $self->app_handle, handle => $self, type => $args{type} } );
$record->_instantiate_from_hash( uuid => $uuid, luid => $found{$uuid}->{luid});
- #$PROP_CACHE->{$uuid} = $found{$uuid}->{props};
+ #$self->prop_cache->{$uuid} = $found{$uuid}->{props};
push @data, $record;
}
return \@data;
commit c9dd80d54037088e3dfca8757d524cd2e4c5eb1f
Author: Christine Spang <spang at bestpractical.com>
Date: Thu Aug 6 17:26:15 2009 +0100
Add some useful comments here
diff --git a/lib/Prophet/CLI/Command/Settings.pm b/lib/Prophet/CLI/Command/Settings.pm
index 03d21b4..c4edc3d 100644
--- a/lib/Prophet/CLI/Command/Settings.pm
+++ b/lib/Prophet/CLI/Command/Settings.pm
@@ -72,7 +72,9 @@ sub make_template {
my $content = '';
- # get all settings records
+ # get all settings records (the defaults, not the
+ # ones in the DB) -- current values from the DB are retrieved in
+ # _make_template_entry)
my $settings = $self->app_handle->database_settings;
for my $name ( keys %$settings ) {
my @metadata = @{ $settings->{$name} };
@@ -103,6 +105,8 @@ sub _make_template_entry {
"# uuid: "
. $setting->uuid . "\n"
. $setting->label . ": "
+ # this is what does the actual loading of settings
+ # in the database to override the defaults
. to_json( $setting->get,
{ canonical => 1, pretty => 0, utf8 => 1, allow_nonref => 0 } );
commit f0d19d0dd807063089084a6b4826f268597cb767
Author: Christine Spang <spang at bestpractical.com>
Date: Thu Aug 6 17:28:07 2009 +0100
Better method doc for Prophet::Record->load
diff --git a/lib/Prophet/Record.pm b/lib/Prophet/Record.pm
index 7778f9b..67ab36e 100644
--- a/lib/Prophet/Record.pm
+++ b/lib/Prophet/Record.pm
@@ -228,7 +228,11 @@ sub _create_record {
=head2 load { uuid => $UUID } or { luid => $UUID }
-Loads a Prophet record off disk by its uuid or luid.
+Given a UUID or LUID, look up the LUID or UUID (the opposite of what was
+given) in the database. Set this record's LUID and UUID attributes, and return
+the LUID or UUID (whichever wasn't given in the method call).
+
+Returns undef if the record doesn't exist in the database.
=cut
commit c5a133a0c02340042139ccbfc1dc8d1442a6adc9
Author: Christine Spang <spang at bestpractical.com>
Date: Thu Aug 6 17:30:04 2009 +0100
Move database-settings tests away from Test::Script::Run where possible.
diff --git a/t/Settings/lib/App/Settings/Test.pm b/t/Settings/lib/App/Settings/Test.pm
new file mode 100644
index 0000000..2fc423e
--- /dev/null
+++ b/t/Settings/lib/App/Settings/Test.pm
@@ -0,0 +1,34 @@
+package App::Settings::Test;
+use warnings;
+use strict;
+
+use base qw(Prophet::Test Exporter);
+
+use lib 't/Settings/lib';
+use App::Settings::CLI;
+
+our @EXPORT = qw/as_alice as_bob diag run_settings_command like ok
+repo_uri_for/;
+
+Prophet::Test->import;
+
+# don't use Prophet::Test::run_command since we want our app to be
+# App::Settings rather than Prophet::App
+sub run_settings_command {
+ my $output = '';
+ my $error = '';
+ open my $out_handle, '>', \$output;
+
+ # feed a persistent handle in to keep the prop cache between
+ # commands (clear the handle's cache if something not using
+ # this handle object changes props on disk; for example a
+ # subprocess using run_output_matches and friends)
+ App::Settings::CLI->new->invoke(
+ $out_handle, \$error, @_,
+ );
+
+ return wantarray ? ($output, $error) : $output;
+}
+
+1;
+
diff --git a/t/Settings/t/database-settings-editor.t b/t/Settings/t/database-settings-editor.t
index 896d6f8..56035df 100644
--- a/t/Settings/t/database-settings-editor.t
+++ b/t/Settings/t/database-settings-editor.t
@@ -1,45 +1,40 @@
#!/usr/bin/perl -w
-
+use warnings;
use strict;
-use Prophet::Test tests => 9;
+use lib 't/Settings/lib';
+
+use App::Settings::Test tests => 9;
use Prophet::Util;
-use File::Temp qw(tempdir);
use File::Spec;
+use Test::Script::Run;
no warnings 'once';
-$ENV{'PERL5LIB'} .= ':t/Settings/lib';
-
# test the CLI and interactive UIs for showing and updating settings
BEGIN {
- require File::Temp;
- $ENV{'PROPHET_REPO'} = File::Temp::tempdir( CLEANUP => 1 ) . '/_svb';
+ $ENV{'PROPHET_REPO'} = $Prophet::Test::REPO_BASE . '/_svb';
diag $ENV{'PROPHET_REPO'};
}
-run_ok( 'settings', [ 'init' ] );
-
-my $replica_uuid = replica_uuid;
+my $out = run_settings_command( 'init' );
+is( $out, "Initialized your new Prophet database.\n", 'replica init' );
# test noninteractive set
-run_output_matches( 'settings', [ 'settings', 'set', '--', 'statuses',
- '["new","open","stalled"]' ],
- [
- 'Trying to change statuses from ["new","open","stalled","closed"] to ["new","open","stalled"].',
- ' -> Changed.',
- ], [], "settings --set went ok",
+$out = run_settings_command(
+ 'settings', 'set', '--', 'statuses', '["new","open","stalled"]',
);
+my $expected = <<'END_OUTPUT';
+Trying to change statuses from ["new","open","stalled","closed"] to ["new","open","stalled"].
+ -> Changed.
+END_OUTPUT
+is( $out, $expected, "settings set went ok" );
-# check with settings --show
-my @valid_settings_output = Prophet::Util->slurp('t/data/settings-first.tmpl');
-chomp (@valid_settings_output);
+# check with settings show
+my $valid_settings_output = Prophet::Util->slurp('t/data/settings-first.tmpl');
-run_output_matches(
- 'settings',
- [ qw/settings show/ ],
- [ @valid_settings_output ], [], "changed settings output matches"
-);
+$out = run_settings_command( qw/settings/ );
+is( $out, $valid_settings_output, "changed settings output matches" );
# test settings (interactive editing)
@@ -50,25 +45,26 @@ diag ("interactive template status will be found in $filename");
Prophet::Test->set_editor_script("settings-editor.pl --first $filename");
# then edit the settings
+# (can't use run_settings_command with editor scripts because they don't play nicely
+# with output redirection)
run_output_matches( 'settings', [ 'settings', 'edit' ],
[
'Changed default_status from ["new"] to ["open"].',
'Setting with uuid "6FBD84A1-4568-48E7-B90C-F1A5B7BD8ECD" does not exist.',
], [], "interactive settings set went ok",);
+
# check the tempfile to see if the template presented to the editor was correct
chomp(my $template_ok = Prophet::Util->slurp($filename));
is($template_ok, 'ok!', "interactive template was correct");
# check the settings with settings --show
- at valid_settings_output = Prophet::Util->slurp('t/data/settings-second.tmpl');
-chomp (@valid_settings_output);
+$valid_settings_output = Prophet::Util->slurp('t/data/settings-second.tmpl');
-run_output_matches(
- 'settings',
- [ qw/settings show/ ],
- [ @valid_settings_output ], [], "changed settings output matches"
-);
+($out, my $error) = run_settings_command( qw/settings show/ );
+is( $out, $valid_settings_output, "changed settings output matches" );
+warn "going to print error of settings show";
+diag $error;
# test setting to invalid json
my $second_filename = File::Temp->new(
@@ -86,12 +82,9 @@ run_output_matches( 'settings', [ 'settings', 'edit' ],
chomp($template_ok = Prophet::Util->slurp($filename));
is($template_ok, 'ok!', "interactive template was correct");
-# check the settings with settings --show
- at valid_settings_output = Prophet::Util->slurp('t/data/settings-third.tmpl');
-chomp (@valid_settings_output);
+# check the settings with settings show
+$valid_settings_output = Prophet::Util->slurp('t/data/settings-third.tmpl');
-run_output_matches(
- 'settings',
- [ qw/settings --show/ ],
- [ @valid_settings_output ], [], "changed settings output matches"
-);
+# run_settings_command( 'settings' );
+$out = run_settings_command( qw/settings show/ );
+is( $out, $valid_settings_output, 'changed settings output matches' );
diff --git a/t/Settings/t/sync-database-settings.t b/t/Settings/t/sync-database-settings.t
index 5c1fbd1..9e80e27 100644
--- a/t/Settings/t/sync-database-settings.t
+++ b/t/Settings/t/sync-database-settings.t
@@ -1,39 +1,46 @@
#!/usr/bin/perl
-#
use warnings;
use strict;
-use Prophet::Test tests => 12;
-$ENV{'PERL5LIB'} .= ':t/Settings/lib';
-
+use lib 't/Settings/lib';
+use App::Settings::Test tests => 12;
as_alice {
- run_ok('settings', [qw(init)]);
- run_ok( 'settings', [qw(create --type Bug -- --status new --from alice )], "Created a record as alice" );
- run_output_matches( 'settings', [qw(search --type Bug --regex .)], [qr/new/], [], "Found our record" );
- my ($return, $stdout, $stderr) = run_script('settings', [qw(settings --show)]);
- like($stdout, qr/default_status: \["new"\]/, "the original milestone list is there");
- run_ok('settings', [qw(settings --set -- default_status ["open"])]);
- ($return, $stdout, $stderr) = run_script('settings', [qw(settings --show)]);
- like($stdout, qr/default_status: \["open"\]/, "the original milestone list is there");
+ ok( run_settings_command( qw(init) ), 'replica init' );
+ ok( run_settings_command( qw(create --type Bug -- --status new --from alice ) ),
+ 'Created a record as alice' );
+ my $output = run_settings_command( qw(search --type Bug --regex .) );
+ like( $output, qr/new/, 'Found our record' );
+ $output = run_settings_command( qw(settings show) );
+ like( $output, qr/default_status: \["new"\]/,
+ 'the original milestone list is there');
-};
-as_bob {
- run_ok( 'settings', [ 'clone', '--from', repo_uri_for('alice')], "Sync ran ok!" );
- my ($return, $stdout, $stderr) = run_script('settings', [qw(settings --show)]);
- like($stdout, qr/default_status: \["open"\]/, "the original milestone list is there");
- run_ok('settings', [qw(settings --set -- default_status ["stalled"])]);
- ($return, $stdout, $stderr) = run_script('settings', [qw(settings --show)]);
- like($stdout, qr/default_status: \["stalled"\]/, "the original milestone list is there");
+ ok( run_settings_command( qw(settings set -- default_status ["open"]) ),
+ 'set default_status to ["open"]' );
+ $output = run_settings_command( qw(settings --show) );
+ like( $output, qr/default_status: \["open"\]/,
+ 'the original milestone list is there' );
};
+as_bob {
+ ok( run_settings_command( 'clone', '--from', repo_uri_for('alice') ),
+ 'Sync ran ok!' );
+ my $stdout = run_settings_command( qw(settings show) );
+ like( $stdout, qr/default_status: \["open"\]/,
+ 'the original milestone list is there' );
+ ok( run_settings_command( qw(settings set -- default_status ["stalled"]) ),
+ 'set default_status to ["stalled"]' );
+ $stdout = run_settings_command( qw(settings show) );
+ like( $stdout, qr/default_status: \["stalled"\]/,
+ 'the original milestone list is there');
+};
as_alice {
- run_ok( 'settings', [ 'pull', '--from', repo_uri_for('bob') ], "Sync ran ok!" );
- my ($return, $stdout, $stderr) = run_script('settings', [qw(settings --show)]);
- like($stdout, qr/default_status: \["stalled"\]/, "the original milestone list is there");
-
+ ok( run_settings_command( 'pull', '--from', repo_uri_for('bob') ), 'Sync ran ok!' );
+ my $stdout = run_settings_command( qw(settings show) );
+ like( $stdout, qr/default_status: \["stalled"\]/,
+ 'the original milestone list is there' );
};
commit 3bd4f3c1ae39acfc91090a1292ba61a3b71dd787
Author: Christine Spang <spang at bestpractical.com>
Date: Thu Aug 6 17:48:32 2009 +0100
Move two more tests away from Test::Script::Run
diff --git a/t/real-conflicting-merge.t b/t/real-conflicting-merge.t
index 92976db..da2d8c5 100644
--- a/t/real-conflicting-merge.t
+++ b/t/real-conflicting-merge.t
@@ -31,36 +31,29 @@ as_bob {
like(run_command( 'update', '--type', 'Bug', '--uuid', $record_id, '--', '--status' => 'stalled'), qr/Bug .* updated/);
- run_output_matches(
- 'prophet',
- [ 'show', '--type', 'Bug', '--uuid', $record_id, '--batch' ],
- [
- qr/id: (\d+) \($record_id\)/,
- 'creator: alice at example.com',
- 'from: alice',
- 'original_replica: ' . replica_uuid_for('alice'),
- 'status: stalled',
- ], [],
- 'content is correct'
- );
+ my $alice_uuid = replica_uuid_for('alice');
+ my $expected = qr/id: (\d+) \($record_id\)
+creator: alice\@example.com
+from: alice
+original_replica: $alice_uuid
+status: stalled/;
+ like( run_command(
+ 'show', '--type', 'Bug', '--uuid', $record_id, '--batch' ),
+ $expected, 'content is correct' );
};
as_alice {
like(run_command('update', '--type', 'Bug', '--uuid', $record_id, '--', '--status' => 'open' ), qr/Bug .* updated/);
- run_output_matches(
- 'prophet',
- [ 'show', '--type', 'Bug', '--uuid', $record_id, '--batch' ],
- [
- qr/id: (\d+) \($record_id\)/,
- 'creator: alice at example.com',
- 'from: alice',
- 'original_replica: ' . replica_uuid_for('alice'),
- 'status: open',
- ], [],
- 'content is correct'
- );
-
+ my $alice_uuid = replica_uuid_for('alice');
+ my $expected = qr/id: (\d+) \($record_id\)
+creator: alice\@example.com
+from: alice
+original_replica: $alice_uuid
+status: open/;
+ like( run_command(
+ 'show', '--type', 'Bug', '--uuid', $record_id, '--batch' ),
+ $expected, 'content is correct' );
};
my ($alice, $bob, $alice_app, $bob_app);
diff --git a/t/simple-conflicting-merge.t b/t/simple-conflicting-merge.t
index 426813c..08598c3 100644
--- a/t/simple-conflicting-merge.t
+++ b/t/simple-conflicting-merge.t
@@ -9,9 +9,11 @@ use Test::Exception;
use_ok('Prophet::Replica');
as_alice {
- run_ok( 'prophet' , ['init']);
- run_ok( 'prophet', [qw(create --type Bug -- --status new --from alice )], "Created a record as alice" );
- run_output_matches( 'prophet', [qw(search --type Bug --regex .)], [qr/new/], [], "Found our record" );
+ ok( run_command( 'init' ), 'replica init' );
+ ok( run_command( qw(create --type Bug -- --status new --from alice ) ),
+ 'Created a record as alice' );
+ my $output = run_command( qw(search --type Bug --regex .) );
+ like( $output, qr/new/, 'Found our record' );
};
diag('Bob syncs from alice');
@@ -19,28 +21,31 @@ diag('Bob syncs from alice');
my $record_id;
as_bob {
- run_ok( 'prophet', [ 'clone', '--from', repo_uri_for('alice')], "Sync ran ok!" );
+ ok( run_command( 'clone', '--from', repo_uri_for('alice') ),
+ 'Sync ran ok!' );
# check our local replicas
- my ( $ret, $out, $err ) = run_script( 'prophet', [qw(search --type Bug --regex .)] );
+ my $out = run_command( qw(search --type Bug --regex .) );
like( $out, qr/new/, "We have the one record from alice" );
if ( $out =~ /'uuid': '(.*?)'/ ) {
$record_id = $1;
}
- run_ok( 'prophet', [ 'update', '--type', 'Bug', '--uuid', $record_id, '--', '--status' => 'stalled' ] );
- run_output_matches(
- 'prophet',
- [ 'show', '--batch', '--type', 'Bug', '--uuid', $record_id ],
- [
- qr/id: (\d+) \($record_id\)/,
- 'creator: alice at example.com',
- 'from: alice',
- 'original_replica: ' . replica_uuid_for('alice'),
- 'status: stalled',
- ], [],
- 'content is correct'
+ ok( run_command(
+ 'update', '--type', 'Bug', '--uuid', $record_id,
+ '--', '--status' => 'stalled',
+ ),
+ 'update record',
);
+ $out = run_command(
+ 'show', '--batch', '--type', 'Bug', '--uuid', $record_id );
+ my $alice_uuid = replica_uuid_for('alice');
+ my $expected = qr/id: (\d+) \($record_id\)
+creator: alice\@example.com
+from: alice
+original_replica: $alice_uuid
+status: stalled/;
+ like( $out, $expected, 'content is correct' );
};
@@ -51,21 +56,22 @@ as_alice { $alice_app = Prophet::CLI->new()->app_handle; $alice = $alice_app->ha
as_alice {
- run_ok( 'prophet', [ 'update', '--type', 'Bug', '--uuid', $record_id, '--', '--status' => 'stalled' ] );
- run_output_matches(
- 'prophet',
- ['show', '--type', 'Bug', '--uuid', $record_id, '--batch', ],
- [
- qr/id: (\d+) \($record_id\)/,
- 'creator: alice at example.com',
- 'from: alice',
- 'original_replica: ' . replica_uuid_for('alice'),
- 'status: stalled',
- ], [],
- 'content is correct'
+ ok( run_command(
+ 'update', '--type', 'Bug', '--uuid',
+ $record_id, '--', '--status' => 'stalled',
+ ),
+ 'update record as alice',
);
-
-
+ my $output = run_command(
+ 'show', '--type', 'Bug', '--uuid', $record_id, '--batch',
+ );
+ my $alice_uuid = replica_uuid_for('alice');
+ my $expected = qr/id: (\d+) \($record_id\)
+creator: alice\@example.com
+from: alice
+original_replica: $alice_uuid
+status: stalled/;
+ like( $output, $expected, 'content is correct' );
};
# This conflict, we can autoresolve
commit c28db72d3e002dbdc0a929ad6e7b71905c23e9a9
Author: Christine Spang <spang at bestpractical.com>
Date: Thu Aug 6 19:48:50 2009 +0100
Don't export Test::Exception and Test::Script::Run from Prophet::Test; just use them in tests when needed.
diff --git a/lib/Prophet/Test.pm b/lib/Prophet/Test.pm
index 43c4d76..dbceb8b 100644
--- a/lib/Prophet/Test.pm
+++ b/lib/Prophet/Test.pm
@@ -1,20 +1,19 @@
+package Prophet::Test;
use strict;
use warnings;
-package Prophet::Test;
use base qw/Test::More Exporter/;
-use Test::Script::Run ':all';
-our @EXPORT = qw/as_alice as_bob as_charlie as_david as_user run_ok repo_uri_for run_script run_output_matches run_output_matches_unordered replica_last_rev replica_uuid_for ok_added_revisions replica_uuid database_uuid database_uuid_for
- serialize_conflict serialize_changeset in_gladiator diag is_script_output
- run_command set_editor set_editor_script load_record last_script_stdout last_script_stderr
- last_script_exit_code
+our @EXPORT = qw/as_alice as_bob as_charlie as_david as_user
+ repo_uri_for replica_last_rev replica_uuid_for ok_added_revisions replica_uuid
+ database_uuid database_uuid_for serialize_conflict serialize_changeset
+ in_gladiator diag run_command set_editor set_editor_script load_record
+ last_script_stdout last_script_stderr last_script_exit_code
/;
use Cwd qw/getcwd/;
use File::Path 'rmtree';
use File::Spec;
use File::Temp qw/tempdir tempfile/;
-use Test::Exception;
use Params::Validate ':all';
use Prophet::Util;
diff --git a/lib/Prophet/Test/Participant.pm b/lib/Prophet/Test/Participant.pm
index 72d1ba4..82cbd2d 100644
--- a/lib/Prophet/Test/Participant.pm
+++ b/lib/Prophet/Test/Participant.pm
@@ -1,6 +1,7 @@
package Prophet::Test::Participant;
use Any::Moose;
use Prophet::Test;
+use Test::Exception;
has name => (
is => 'rw',
diff --git a/t/aliases.t b/t/aliases.t
index f97354e..d9c8847 100644
--- a/t/aliases.t
+++ b/t/aliases.t
@@ -4,6 +4,7 @@ use warnings;
use strict;
use Prophet::Test tests => 68;
use File::Temp qw/tempfile/;
+use Test::Script::Run;
$ENV{'PROPHET_APP_CONFIG'} = (tempfile(UNLINK => !$ENV{PROPHET_DEBUG}))[1];
diag("Using config file $ENV{PROPHET_APP_CONFIG}");
commit ba037e4e17f6a39b664200721f11eb623d3ca25b
Author: Christine Spang <spang at bestpractical.com>
Date: Fri Aug 7 16:04:27 2009 +0100
Fix confusing lack of space before filename in this log message.
diff --git a/lib/Prophet/FilesystemReplica.pm b/lib/Prophet/FilesystemReplica.pm
index ce2d182..66c22c2 100644
--- a/lib/Prophet/FilesystemReplica.pm
+++ b/lib/Prophet/FilesystemReplica.pm
@@ -98,7 +98,8 @@ sub _write_file {
sub read_changeset_index {
my $self = shift;
- $self->log_debug("Reading changeset index file" .$self->changeset_index);
+ $self->log_debug(
+ "Reading changeset index file '" .$self->changeset_index . "'" );
my $chgidx = $self->_read_file( $self->changeset_index );
return \$chgidx;
}
commit 2feede973489d022bef71c64d8427fc1d650dc02
Author: Christine Spang <spang at bestpractical.com>
Date: Fri Aug 7 17:40:56 2009 +0100
Fix typo in info command
diff --git a/lib/Prophet/CLI/Command/Info.pm b/lib/Prophet/CLI/Command/Info.pm
index b3960f0..18ff766 100644
--- a/lib/Prophet/CLI/Command/Info.pm
+++ b/lib/Prophet/CLI/Command/Info.pm
@@ -20,7 +20,7 @@ sub run {
print "Working on prophet database: ".$self->handle->url." (@{[ref($self->handle)]})".$/;
print "DB UUID: ".$self->handle->db_uuid.$/;
- print "Changets: ".$self->handle->latest_sequence_no.$/;
+ print "Changesets: ".$self->handle->latest_sequence_no.$/;
print "Known types: ".join(',', @{$self->handle->list_types} ).$/;
commit e34e46f20fc5c1086abff1fd566c1245292fe59c
Author: Christine Spang <spang at bestpractical.com>
Date: Sat Aug 8 00:17:45 2009 +0100
Cleanups for publish-pull.t
diff --git a/t/publish-pull.t b/t/publish-pull.t
index 0488810..734c40f 100644
--- a/t/publish-pull.t
+++ b/t/publish-pull.t
@@ -40,9 +40,7 @@ as_alice {
$expected = qr/new/;
like( $output, $expected, 'Found our record' );
- ok( run_command( qw(publish --to), $alice_published ),
- 'publish --to'
- );
+ ok( run_command( qw(publish --to), $alice_published ), 'publish --to' );
# check that publish-url config key has been created correctly
$config_contents = Prophet::Util->slurp($ENV{PROPHET_APP_CONFIG});
@@ -53,12 +51,11 @@ as_alice {
uuid = $Prophet::CLIContext::ID_REGEX
publish-url = \Q$alice_published\E
/, 'publish-url variable created correctly in config');
- $config_contents =~ /\[replica "(.*?)"\]/;
- my $replica_name = $1;
+ my ($replica_name) = ($config_contents =~ /\[replica "(.*?)"\]/);
# change name in config
my $new_config_contents = $config_contents;
- $new_config_contents =~ s/\Q$replica_name\E/new-name/;
+ $new_config_contents =~ s/\Q$replica_name\E/alice/;
Prophet::Util->write_file(
file => $ENV{PROPHET_APP_CONFIG},
content => $new_config_contents,
@@ -75,15 +72,15 @@ as_alice {
like($config_contents, qr/
\[core\]
config-format-version = \d+
-\[replica "new-name"\]
+\[replica "alice"\]
uuid = $Prophet::CLIContext::ID_REGEX
publish-url = \Q$new_published\E
-/, 'publish-url variable created correctly in config');
+/, 'publish-url variable changed correctly in config');
# check to make sure that publish doesn't fall back to using
# url, since that would never make sense
- $new_config_contents =~ /uuid = ($Prophet::CLIContext::ID_REGEX)/;
- my $uuid = $1;
+ my ($uuid)
+ = ($new_config_contents =~ /uuid = ($Prophet::CLIContext::ID_REGEX)/);
$new_published = tempdir( CLEANUP => ! $ENV{PROPHET_DEBUG} );
my $bogus_name = tempdir( CLEANUP => ! $ENV{PROPHET_DEBUG} );
Prophet::Util->write_file(
@@ -94,8 +91,6 @@ as_alice {
url = $new_published
EOF
);
- # diag "publishing to $new_published";
- # diag "bogus name is $bogus_name";
ok( run_command( qw(publish --to), $bogus_name ),
'publish to bogus name',
);
@@ -104,7 +99,7 @@ EOF
'did not fall back to url variable' );
};
-my $path =$alice_published;
+my $path = $alice_published;
as_bob {
$ENV{PROPHET_APP_CONFIG} = $bob_config;
@@ -135,8 +130,7 @@ as_alice {
ok($pullall_uuid, "got a uuid $pullall_uuid for the Pullall record");
ok( run_command( qw(publish --to), $alice_published ),
- 'publish as alice',
- );
+ "publish as alice to $alice_published" );
};
as_bob {
@@ -144,26 +138,24 @@ as_bob {
# change name in config
my $config_contents = Prophet::Util->slurp($ENV{PROPHET_APP_CONFIG});
- $config_contents =~ /\[replica "(.*?)"\]/;
- my $replica_name = $1;
+ my ($replica_name) = ( $config_contents =~ /\[replica "(.*?)"\]/ );
my $new_config_contents = $config_contents;
- $new_config_contents =~ s/\Q$replica_name\E/new-name/;
+ $new_config_contents =~ s/\Q$replica_name\E/alice/;
Prophet::Util->write_file(
file => $ENV{PROPHET_APP_CONFIG},
content => $new_config_contents,
);
- ok( run_command( 'pull', '--from', 'new-name' ), 'pull from name works');
- my $output
- = run_command( qw(search --type Pullall --regex .));
- my $expected = qr/new/;
- like( $output, $expected, 'Found our record' );
+
+ ok( run_command( 'pull', '--from', 'alice' ), 'pull from name');
+ my $output = run_command( qw(search --type Pullall --regex .));
+ like( $output, qr/new/, 'Found our record' );
$new_config_contents =~ s/url/pull-url/;
Prophet::Util->write_file(
file => $ENV{PROPHET_APP_CONFIG},
content => $new_config_contents,
);
- ok( run_command( 'pull', '--from', 'new-name' ),
+ ok( run_command( 'pull', '--from', 'alice' ),
'pull from name works with pull-url var',
);
@@ -172,7 +164,7 @@ as_bob {
file => $ENV{PROPHET_APP_CONFIG},
content => $new_config_contents,
);
- ok( run_command( 'pull', '--from', 'new-name' ),
+ ok( run_command( 'pull', '--from', 'alice' ),
'pull-url is preferred over url',
);
};
commit 6a384695507674d6c4d22cb01a587e6203139014
Author: Christine Spang <spang at bestpractical.com>
Date: Sat Aug 8 00:21:32 2009 +0100
Fix an edge case where publishing to the same directory twice in quick succession could result in a broken exported replica.
diff --git a/lib/Prophet/CLI/PublishCommand.pm b/lib/Prophet/CLI/PublishCommand.pm
index 9cea40c..d9655b6 100644
--- a/lib/Prophet/CLI/PublishCommand.pm
+++ b/lib/Prophet/CLI/PublishCommand.pm
@@ -18,10 +18,18 @@ sub publish_dir {
push @args, '--chmod=Da+rx,a+r';
push @args, '--verbose' if $self->context->has_arg('verbose');
+
+ # avoid edge cases when exporting replicas! still update files even
+ # if they have the same size and time.
+ # (latest-sequence-no is a file that can fall into this trap, since it's
+ # ~easy for it to have the same size as it was previously and in test
+ # cases we sometimes export to the same directory in quick succession)
+ push @args, '--ignore-times';
push @args, '--recursive', '--' , $args{from}, $args{to};
my $rsync = $ENV{RSYNC} || "rsync";
+
my $ret = system($rsync, @args);
if ($ret == -1) {
commit 2c14f0773d6f3db89fe75d85de77f093bc7ba803
Author: Christine Spang <spang at bestpractical.com>
Date: Sat Aug 8 00:25:06 2009 +0100
Wrap this exception message.
diff --git a/lib/Prophet/CLI/PublishCommand.pm b/lib/Prophet/CLI/PublishCommand.pm
index d9655b6..d5dd9d9 100644
--- a/lib/Prophet/CLI/PublishCommand.pm
+++ b/lib/Prophet/CLI/PublishCommand.pm
@@ -33,9 +33,12 @@ sub publish_dir {
my $ret = system($rsync, @args);
if ($ret == -1) {
- die "You must have 'rsync' installed to use this command.
+ die <<'END_DIE_MSG';
+You must have 'rsync' installed to use this command.
-If you have rsync but it's not in your path, set environment variable \$RSYNC to the absolute path of your rsync executable.\n";
+If you have rsync but it's not in your path, set environment variable \$RSYNC
+to the absolute path of your rsync executable.
+END_DIE_MSG
}
return $ret;
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list