7 eval { use Pod::Usage };
9 plan skip_all => "Pod::Usage must be installed to run these tests";
15 use t::common qw( new_fh );
19 my $PROG = File::Spec->catfile( qw( utils upgrade_db.pl ) );
21 my $short = get_pod( $PROG, 0 );
22 my $long = get_pod( $PROG, 1 );
24 is( run_prog( $PROG ), "Missing required parameters.\n$long", "Failed no params" );
25 is( run_prog( $PROG, '-input foo' ), "Missing required parameters.\n$long", "Failed only -input" );
26 is( run_prog( $PROG, '-output foo' ), "Missing required parameters.\n$long", "Failed only -output" );
28 run_prog( $PROG, '-input foo', '-output foo' ),
29 "Cannot use the same filename for both input and output.\n$short",
34 run_prog( $PROG, '-input foo', '-output bar' ),
35 "'foo' is not a file.\n$short",
36 "Failed input does not exist",
39 my (undef, $input_filename) = new_fh();
40 my (undef, $output_filename) = new_fh();
43 run_prog( $PROG, "-input $input_filename", "-output $output_filename" ),
44 "'$input_filename' is not a DBM::Deep file.\n$short",
45 "Input is not a DBM::Deep file",
48 # All files are of the form:
49 # $db->{foo} = [ 1 .. 3 ];
57 my @output_versions = (
58 '0.91', '0.92', '0.93', '0.94', '0.95', '0.96', '0.97', '0.98',
59 '0.981', '0.982', '0.983',
60 '0.99_01', '0.99_02', '0.99_03', '0.99_04',
64 foreach my $input_filename (
66 File::Spec->catfile( qw( t etc ), "db-$_" )
69 foreach my $v ( @output_versions ) {
70 #print "$input_filename => $output_filename ($v)\n";
71 my $output = run_prog(
73 "-input $input_filename",
74 "-output $output_filename",
78 if ( $input_filename =~ /_/ ) {
80 $output, "'$input_filename' is a dev release and not supported.\n$short",
81 "Input file is a dev release - not supported",
89 $output, "-version '$v' is a dev release and not supported.\n$short",
90 "Output version is a dev release - not supported",
96 # Now, read the output file with the right version.
97 ok( !$output, "A successful run produces no output" );
98 die "$output\n" if $output;
102 push @INC, File::Spec->catdir( 'utils', 'lib' );
103 eval "use DBM::Deep::09830";
104 $db = DBM::Deep::09830->new( $output_filename );
106 elsif ( $v =~ /^1/ ) {
108 eval "use DBM::Deep";
109 $db = DBM::Deep->new( $output_filename );
112 die "How did we get here?!\n";
115 ok( $db, "Writing to version $v made a file" );
122 "We can read the output file",
127 ################################################################################
130 #print "Launching '@_'\n";
131 #XXX This needs to be made OS-portable
132 open( my $fh, '-|', "@_ 2>&1" ) or die "Cannot launch '@_': $!\n";
133 return join '', <$fh>;
138 #XXX This needs retro'ed to 5.6.0
139 open( my $fh, '>', \my $pod ) or die "Cannot open in-memory filehandle: $!\n";
144 -exitval => 'NOEXIT',