use_moose
only_autoclean
overwrite_modifications
+ dry_run
generated_classes
relationship_attrs
completed.> messages. Does not affect warnings (except for warnings related to
L</really_erase_my_files>.)
+=head2 dry_run
+
+If true, don't actually write out the generated files. This can only be
+used with static schema generation.
+
=head2 generate_pod
By default POD will be generated for columns and relationships, using database
if $self->{dump_overwrite};
$self->{dynamic} = ! $self->{dump_directory};
+
+ croak "dry_run can only be used with static schema generation"
+ if $self->dynamic and $self->dry_run;
+
$self->{temp_directory} ||= File::Temp::tempdir( 'dbicXXXX',
TMPDIR => 1,
CLEANUP => 1,
local $self->{quiet} = 1;
local $self->{dump_directory} = $self->{temp_directory};
local $self->{generated_classes} = [];
+ local $self->{dry_run} = 0;
$self->_reload_classes(\@tables);
$self->_load_relationships(\@tables);
# Reload without unloading first to preserve any symbols from external
# packages.
- $self->_reload_classes(\@tables, { unload => 0 });
+ $self->_reload_classes(\@tables, { unload => 0 }) unless $self->dry_run;
# Drop temporary cache
delete $self->{_cache};
sub _ensure_dump_subdirs {
my ($self, $class) = (@_);
+ return if $self->dry_run;
+
my @name_parts = split(/::/, $class);
pop @name_parts; # we don't care about the very last element,
# which is a filename
my $filename = $self->_get_dump_filename($class);
$self->_ensure_dump_subdirs($class);
- if (-f $filename && $self->really_erase_my_files) {
+ if (-f $filename && $self->really_erase_my_files && !$self->dry_run) {
warn "Deleting existing file '$filename' due to "
. "'really_erase_my_files' setting\n" unless $self->quiet;
unlink($filename);
if (-f $old_filename) {
$custom_content = ($self->_parse_generated_file ($old_filename))[4];
- unlink $old_filename;
+ unlink $old_filename unless $self->dry_run;
}
}
push @{$self->generated_classes}, $class;
+ return if $self->dry_run;
+
$text .= $self->_sig_comment(
$self->version_to_dump,
POSIX::strftime('%Y-%m-%d %H:%M:%S', localtime)
},
);
+# test dry-run mode
+$t->dump_test(
+ classname => 'DBICTest::DumpMore::DryRun',
+ options => {
+ dry_run => 1,
+ },
+);
+
+my $schema_file = $t->class_file('DBICTest::DumpMore::DryRun');
+ok( !-e $schema_file, "dry-run doesn't create file for schema class" );
+(my $schema_dir = $schema_file) =~ s/\.pm\z//;
+ok( !-e $schema_dir, "dry-run doesn't create subdirectory for schema namespace" );
+
done_testing;
# vim:et sts=4 sw=4 tw=0: