[Bps-public-commit] Prophet branch, config-gitlike, updated. 64cc2ffd1ed6b5a907e3ae8cb4ef0e3d8e8e29d7
spang at bestpractical.com
spang at bestpractical.com
Fri Jun 26 07:08:15 EDT 2009
The branch, config-gitlike has been updated
via 64cc2ffd1ed6b5a907e3ae8cb4ef0e3d8e8e29d7 (commit)
from eb41224ca6bc47e1447b4b2fea44f181ebacaac8 (commit)
Summary of changes:
t/aliases.t | 26 ++++++++++++++++++++++++--
t/data/aliases.tmpl | 9 +++++++++
t/scripts/aliases-editor.pl | 24 ++++++++++++++++++++++++
t/scripts/settings-editor.pl | 4 +---
4 files changed, 58 insertions(+), 5 deletions(-)
create mode 100644 t/data/aliases.tmpl
create mode 100755 t/scripts/aliases-editor.pl
- Log -----------------------------------------------------------------
commit 64cc2ffd1ed6b5a907e3ae8cb4ef0e3d8e8e29d7
Author: Christine Spang <spang at mit.edu>
Date: Fri Jun 26 14:07:50 2009 +0300
Test interactive alias editor.
diff --git a/t/aliases.t b/t/aliases.t
index 6328184..b8f5c8a 100644
--- a/t/aliases.t
+++ b/t/aliases.t
@@ -2,7 +2,7 @@
#
use warnings;
use strict;
-use Prophet::Test tests => 30;
+use Prophet::Test tests => 32;
use File::Temp qw/tempfile/;
$ENV{'PROPHET_REPO'} = $Prophet::Test::REPO_BASE . '/repo-' . $$;
@@ -193,4 +193,26 @@ is( $content, <<EOF, 'content in config' );
pull --from http://www.example.com/ = pfe
EOF
-# TODO: need tests for interactive alias editing
+# tests for interactive alias editing
+my $filename = File::Temp->new(
+ TEMPLATE => File::Spec->catfile(File::Spec->tmpdir(), '/statusXXXXX') )->filename;
+diag ("interactive template status will be found in $filename");
+Prophet::Test->set_editor_script("aliases-editor.pl --first $filename");
+
+run_output_matches( 'prophet', [ 'aliases', 'edit' ],
+ [
+ "Added alias 'something different' = 'pull --local'",
+ "Changed alias 'foo' from 'bar baz'to 'sigh'",
+ "Deleted alias 'pull -l'",
+ ], [], 'aliases edit went ok',
+);
+
+# check with alias show
+my @valid_settings_output = Prophet::Util->slurp('t/data/aliases.tmpl');
+chomp (@valid_settings_output);
+
+run_output_matches(
+ 'prophet',
+ [ qw/alias show/ ],
+ [ @valid_settings_output ], [], "changed alias output matches"
+);
diff --git a/t/data/aliases.tmpl b/t/data/aliases.tmpl
new file mode 100644
index 0000000..0a20608
--- /dev/null
+++ b/t/data/aliases.tmpl
@@ -0,0 +1,9 @@
+Active aliases for the current repository (including user-wide and global
+aliases if not overridden):
+
+foo bar = bar
+foo = sigh
+something different = pull --local
+pull -a = pull --all
+pull --from http://www.example.com/ = pfe
+
diff --git a/t/scripts/aliases-editor.pl b/t/scripts/aliases-editor.pl
new file mode 100755
index 0000000..c7aaea5
--- /dev/null
+++ b/t/scripts/aliases-editor.pl
@@ -0,0 +1,24 @@
+#!perl -i
+use strict;
+use warnings;
+use Prophet::Test::Editor;
+
+# perl script to trick Proc::InvokeEditor with for the settings command
+
+my %tmpl_files = ( '--first' => 'aliases.tmpl',
+);
+
+Prophet::Test::Editor::edit(
+ tmpl_files => \%tmpl_files,
+ edit_callback => sub {
+ my %args = @_;
+ my $option = $args{option};
+
+ if ($option eq '--first') {
+ s/^pull -l/something different/; # both an add and a delete
+ s/(?<=foo = )bar baz/sigh/; # just change a value
+ }
+ print;
+ },
+ verify_callback => sub { },
+);
diff --git a/t/scripts/settings-editor.pl b/t/scripts/settings-editor.pl
index 6a6ad8a..ca5bd27 100755
--- a/t/scripts/settings-editor.pl
+++ b/t/scripts/settings-editor.pl
@@ -10,9 +10,7 @@ my %tmpl_files = ( '--first' => 'settings-first.tmpl',
);
Prophet::Test::Editor::edit(
- tmpl_files => { '--first' => 'settings-first.tmpl',
- '--second' => 'settings-second.tmpl',
- },
+ tmpl_files => \%tmpl_files,
edit_callback => sub {
my %args = @_;
my $option = $args{option};
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list