#!/usr/bin/perl use strict; use warnings; my $directory = shift(@ARGV); (defined($directory)) || die "You must specify a directory to create a smoke test for\nusage: create_smoke_test \n"; sub map_dir { my ($dir, $dir_func, $file_func, $depth) = @_; $depth ||= 0; map { if (-d $_ && !/CVS/) { $dir_func->($_, $depth + 1); map_dir($_, $dir_func, $file_func, $depth + 1); } elsif (-f $_ && /\.pm/) { $file_func->($_, $depth); } } sort { ((-d $a) ? 1 : (-d $b) ? -1 : ($a cmp $b)) } <$dir/*>; } sub handle_dir { my ($dir, $depth) = @_; $depth ||= 1; $dir =~ s/^$directory\///; print("\n" . ("\t" x $depth) . "# $dir\n"); } sub handle_file { my ($file, $depth) = @_; $depth ||= 1; $file =~ s/^$directory\///; my ($module_name) = ($file =~ /(.*?)\.pm/); $module_name =~ s/\//\:\:/g; print(("\t" x $depth) . "use_ok('$module_name');\n"); } print <