Skip to content

Commit

Permalink
Teach Change to use reworked_* directories.
Browse files Browse the repository at this point in the history
For reworked changes only, of course.
  • Loading branch information
theory committed Aug 2, 2015
1 parent 8f1461b commit 6c86506
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
18 changes: 15 additions & 3 deletions lib/App/Sqitch/Plan/Change.pm
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,11 @@ sub dependencies {

sub deploy_file {
my $self = shift;
$self->target->deploy_dir->file( $self->path_segments );
my $target = $self->target;
my $dest = $self->is_reworked
? $target->reworked_deploy_dir
: $target->deploy_dir;
$dest->file( $self->path_segments );
}

sub _deploy_hash {
Expand All @@ -218,12 +222,20 @@ sub _deploy_hash {

sub revert_file {
my $self = shift;
$self->target->revert_dir->file( $self->path_segments );
my $target = $self->target;
my $dest = $self->is_reworked
? $target->reworked_revert_dir
: $target->revert_dir;
$dest->file( $self->path_segments );
}

sub verify_file {
my $self = shift;
$self->target->verify_dir->file( $self->path_segments );
my $target = $self->target;
my $dest = $self->is_reworked
? $target->reworked_verify_dir
: $target->verify_dir;
$dest->file( $self->path_segments );
}

sub script_file {
Expand Down
17 changes: 10 additions & 7 deletions t/change.t
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ my $sqitch = App::Sqitch->new( options => {
engine => 'sqlite',
top_dir => dir('test-change')->stringify,
});
my $target = App::Sqitch::Target->new(sqitch => $sqitch);
my $target = App::Sqitch::Target->new(
sqitch => $sqitch,
reworked_dir => dir('reworked'),
);
my $plan = App::Sqitch::Plan->new(sqitch => $sqitch, target => $target);
make_path 'test-change';
END { remove_tree 'test-change' };
Expand Down Expand Up @@ -298,12 +301,12 @@ my @fn = ('yo', 'howdy@beta.sql');
$change2->add_rework_tags($tag2);
is_deeply [ $change2->path_segments ], \@fn,
'path_segments should include directories';
is $change2->deploy_file, $target->deploy_dir->file(@fn),
'The deploy file should include the suffix';
is $change2->revert_file, $target->revert_dir->file(@fn),
'The revert file should include the suffix';
is $change2->verify_file, $target->verify_dir->file(@fn),
'The verify file should include the suffix';
is $change2->deploy_file, $target->reworked_deploy_dir->file(@fn),
'Deploy file should be in rworked dir and include suffix';
is $change2->revert_file, $target->reworked_revert_dir->file(@fn),
'Revert file should be in rworked dir and include suffix';
is $change2->verify_file, $target->reworked_verify_dir->file(@fn),
'Verify file should be in rworked dir and include suffix';

##############################################################################
# Test open_script.
Expand Down
3 changes: 2 additions & 1 deletion t/engine.t
Original file line number Diff line number Diff line change
Expand Up @@ -2028,6 +2028,7 @@ is_deeply +MockOutput->get_info, [
# Try to revert just the last change with no prompt
MockOutput->ask_y_n_returns(1);
$engine->no_prompt(1);
my $rev_file = $dbchanges[-1]->revert_file; # Grab before deleting _rework_tags.
my $rtags = delete $dbchanges[-1]->{_rework_tags}; # These need to be invisible.
$offset_change = $dbchanges[-1];
push @resolved => $offset_change->id;
Expand All @@ -2038,7 +2039,7 @@ is_deeply $engine->seen, [
[change_offset_from_id => [$dbchanges[-1]->id, -1] ],
[deployed_changes_since => $dbchanges[-1]],
[check_revert_dependencies => [{ %{ $dbchanges[-1] }, _rework_tags => $rtags }] ],
[run_file => $dbchanges[-1]->revert_file ],
[run_file => $rev_file ],
[log_revert_change => { %{ $dbchanges[-1] }, _rework_tags => $rtags } ],
], 'Should have reverted one changes for @HEAD^';
is_deeply +MockOutput->get_ask_y_n, [], 'Should have no prompt';
Expand Down

0 comments on commit 6c86506

Please sign in to comment.