generate_testing_configuration.pl 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use File::Basename qw{dirname};
  5. use Cwd qw{abs_path};
  6. my $gitdir = abs_path( dirname( __FILE__ ) . "/.." );
  7. unshift @INC, "$gitdir/lib";
  8. print "Please input the provider name you are attempting to test: ";
  9. chomp( my $input = <STDIN> );
  10. my $module_name = $input;
  11. if( $input eq 'SLACK' ) {
  12. $module_name = 'Slack';
  13. }
  14. my $package = "Cpanel::iContact::Provider::Schema::$module_name";
  15. my $ret = eval "require $package";
  16. die "Couldn't load $package! Check input or file permissions" if !$ret;
  17. my $settings_hr = $package->get_settings();
  18. my $file_name_prefix = lc( $input );
  19. open( my $fh, ">", "$gitdir/.${file_name_prefix}testrc" );
  20. foreach my $key ( keys( %$settings_hr ) ) {
  21. print "Please input the '", $settings_hr->{$key}{'label'}, "' ($key): ";
  22. print $fh "$key: " . <STDIN>;
  23. }
  24. close( $fh );
  25. my $provepath = 'prove';
  26. # Figure out if cPanel perl & prove exist. If so, use it, as it'll have a better chance of working.
  27. if( -f '/usr/local/cpanel/3rdparty/bin/perl' ) {
  28. print "Checking cPanel Perl version...\n";
  29. my $cpperl_ver = `/usr/local/cpanel/3rdparty/bin/perl -e 'print substr( \$], 0, 1 ) . substr( \$], 3, 2 );'`;
  30. print "Looks like perl $cpperl_ver.\n";
  31. $provepath = "/usr/local/cpanel/3rdparty/perl/$cpperl_ver/bin/prove";
  32. }
  33. print STDOUT (
  34. "Done writing to $gitdir/.${file_name_prefix}testrc.\n",
  35. "The functional test in t/ should now work when ran like so:\n",
  36. "AUTHOR_TESTS=1 $provepath $gitdir/t/Cpanel-iContact-Provider-$module_name.t\n"
  37. );
  38. 0;