{"id":31,"date":"2005-11-14T02:56:16","date_gmt":"2005-11-14T07:56:16","guid":{"rendered":"http:\/\/www.chrisdolan.net\/talk\/?p=31"},"modified":"2005-11-14T03:03:27","modified_gmt":"2005-11-14T08:03:27","slug":"private-regression-tests","status":"publish","type":"post","link":"https:\/\/chrisdolan.net\/talk\/2005\/11\/14\/private-regression-tests\/","title":{"rendered":"Private Regression Tests"},"content":{"rendered":"<p><\/p>\n\n<h2><\/h2>\n\n<p><\/p>\n\n<p><\/p>\n\n<h2><\/h2>\n\n<p><\/p>\n\n<p><\/p>\n\n<h2><\/h2>\n\n<p><\/p>\n\n<ol>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ol>\n\n<p><\/p>\n\n<h3><\/h3>\n\n<p><\/p>\n\n<p><\/p>\n\n<p><\/p>\n\n<p><\/p>\n\n<p><\/p>\n\n<pre><code>use warnings;\nuse strict;\nuse Test::More;\nuse Test::Spelling;\nset_spell_cmd('aspell -l');\nadd_stopwords(&lt;DATA&gt;);\nall_pod_files_spelling_ok();\n__DATA__\nCGI\nCPAN\nGPL\nDolan\nSTDIN\nSTDOUT\n<\/code><\/pre>\n\n<p><\/p>\n\n<p><\/p>\n\n<p><\/p>\n\n<p><\/p>\n\n<pre><code>% perl Build test test_files=t\/00_local_spelling.t verbose=1\n...\n#   Failed test 'POD spelling for blib\/lib\/Perl\/Critic\/Config.pm'\nnot ok 3 - POD spelling for blib\/lib\/Perl\/Critic\/Config.pm\n#   in \/Users\/chris\/perl\/lib\/perl5\/site_perl\/Test\/Spelling.pm at line 72.\n# Errors:\n#     PBP\n#     PERLCRITIC\n#     Thalhammer\n#     inlucde\n#     ommit\n...\nFailed 1\/1 test scripts, 0.00% okay. 55\/56 subtests failed, 1.79% okay.\n<\/code><\/pre>\n\n<p><\/p>\n\n<p><\/p>\n\n<p><\/p>\n\n<pre><code>...\n__DATA__\nCGI\nCPAN\nGPL\nDolan\nSTDIN\nSTDOUT\nThalhammer\n<\/code><\/pre>\n\n<p><\/p>\n\n<pre><code>...\n1;\n__END__\n\n=pod\n\n=head1 NAME\n\nPerl::Critic::Config - Load Perl::Critic user-preferences\n\n=head1 DESCRIPTION\n...\n<\/code><\/pre>\n\n<p><\/p>\n\n<pre><code>...\n1;\n__END__\n\n=pod\n\n=for stopwords PBP PERLCRITIC\n\n=head1 NAME\n\nPerl::Critic::Config - Load Perl::Critic user-preferences\n\n=head1 DESCRIPTION\n...\n<\/code><\/pre>\n\n<p><\/p>\n\n<p><\/p>\n\n<pre><code>% perl Build test test_files=t\/00_local_spelling.t verbose=1\n...\nok 3 - POD spelling for blib\/lib\/Perl\/Critic\/Config.pm\n...\nFailed 1\/1 test scripts, 0.00% okay. 33\/56 subtests failed, 41.07% okay.\n<\/code><\/pre>\n\n<p><\/p>\n\n<p><\/p>\n\n<h3><\/h3>\n\n<p><\/p>\n\n<p><\/p>\n\n<p><\/p>\n\n<pre><code>...\nmy $tests = 2 + @testdocs * 33 + @testpages * 4 + @impages * 4;\nplan tests =&gt; $tests;\n...\n<\/code><\/pre>\n\n<p><\/p>\n\n<h3><\/h3>\n\n<p><\/p>\n\n<ol>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ol>\n\n<p><\/p>\n\n<p><\/p>\n\n<pre><code>use Test::More;\neval { require Test::Distribution; };\nplan skip_all =&gt; 'Optional Test::Distribution not installed' if ($@);\nimport Test::Distribution;\n<\/code><\/pre>\n\n<p><\/p>\n\n<p><\/p>\n\n<p><\/p>\n\n<p><\/p>\n\n<h3><\/h3>\n\n<p><\/p>\n\n<p><\/p>\n\n<p><\/p>\n\n<pre><code>use warnings;\nuse strict;\nuse File::Find;\nuse File::Slurp;\nuse Test::More qw(no_plan);\n\nmy $last_version = undef;\nfind({wanted =&gt; \\&amp;check_version, no_chdir =&gt; 1}, 'blib');\nif (! defined $last_version) {\n    fail('Failed to find any files with $VERSION');\n}\n\nsub check_version {\n    # $_ is the full path to the file\n    return if (! m{blib\/script\/}xms &amp;&amp; ! m{\\.pm \\z}xms);\n\n    my $content = read_file($_);\n\n    # only look at perl scripts, not sh scripts\n    return if (m{blib\/script\/}xms &amp;&amp; $content !~ m\/\\A \\#![^\\r\\n]+?perl\/xms);\n\n    my @version_lines = $content =~ m\/ ( [^\\n]* \\$VERSION [^\\n]* ) \/gxms;\n    if (@version_lines == 0) {\n       fail($_);\n    }\n    for my $line (@version_lines) {\n        if (!defined $last_version) {\n            $last_version = shift @version_lines;\n            pass($_);\n        }\n        else {\n            is($line, $last_version, $_);\n        }\n    }\n}\n<\/code><\/pre>\n\n<p><\/p>\n\n<h3><\/h3>\n\n<p><\/p>\n\n<p><\/p>\n\n<p><\/p>\n\n<pre><code>#!perl -w\n\nuse warnings;\nuse strict;\nuse File::Find;\nuse File::Slurp;\nuse Test::More qw(no_plan);\n\nmy $this_year = [localtime]-&gt;[5]+1900;\nmy $copyrights_found = 0;\nfind({wanted =&gt; \\&amp;check_file, no_chdir =&gt; 1}, 'blib');\nfor (grep {\/^readme\/i} read_dir('.')) {\n    check_file();\n}\nok($copyrights_found != 0, 'found a copyright statement');\n\nsub check_file {\n    # $_ is the path to a filename, relative to the root of the\n    # distribution\n\n    # Only test plain files\n    return if (! -f $_);\n\n    # Filter the list of filenames\n    return if (! m,^(?: README.*         # docs\n                     |  .*\/scripts\/[^\/]+ # programs\n                     |  .*\/script\/[^\/]+  # programs\n                     |  .*\/bin\/[^\/]+     # programs\n                     |  .*\\.(?: pl       # program ext\n                             |  pm       # module ext\n                             |  html     # doc ext\n                             |  3pm      # doc ext\n                             |  3        # doc ext\n                             |  1        # doc ext\n                            )\n                    )$,xms);\n\n    my $content = read_file($_);\n    my @copyright_years = $content =~ m\/\n                                       (?: copyright | \\(c\\) )\n                                       \\s+\n                                       (?: \\d{4} \\- )?\n                                       (\\d{4})\n                                       \/gixms;\n    if (0 &lt; grep {$_ ne $this_year} @copyright_years) {\n        fail(\"$_ copyrights: @copyright_years\");\n    }\n    elsif (0 == @copyright_years) {\n        pass(\"$_, no copyright found\");\n    }\n    else {\n        pass($_);\n    }\n    $copyrights_found += @copyright_years;\n}\n<\/code><\/pre>\n\n<h3><\/h3>\n\n<p><\/p>\n\n<p><\/p>\n\n<p><\/p>\n\n<p><\/p>\n\n<p><\/p>\n\n<pre><code>use warnings;\nuse strict;\n\nour @pcargs;\nBEGIN\n{\n   my $rc = 't\/perlcriticrc';\n   @pcargs = -f $rc ? (-profile =&gt; $rc) : ();\n}\nuse Test::Perl::Critic (@pcargs);\nall_critic_ok();\n<\/code><\/pre>\n\n<p><\/p>\n\n<p><\/p>\n\n<pre><code>[-NamingConventions::ProhibitMixedCaseSubs]\n<\/code><\/pre>\n\n<h2><\/h2>\n\n<p><\/p>\n\n<ol>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ol>\n\n<p><\/p>\n\n<p><\/p>\n\n<p><\/p>\n\n<pre><code>t\/author.t..........1..16\nok 1 - Test::Pod\nok 2 - Test::Pod::Coverage\nok 3 - Devel::Cover 100%\nok 4 - Test::Spelling\nok 5 - Test::Perl::Critic, 57 policies in effect\nok 6 - Test::Distribution\nok 8 - Version numbers all match\nok 9 - Copyright date is 2005\nok 10 - Works on darwin\nok 11 - Works on linux\nnok 12 - Works on win32 # TODO needs some Windows lovin'!\nok 13 - Works on Perl 5.005\nok 14 - Works on Perl 5.6.1\nok 15 - Works on Perl 5.8.7\nok 16 - Works under mod_perl 1.x\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>use warnings; use strict; use Test::More; use Test::Spelling; set_spell_cmd(&#8216;aspell -l&#8217;); add_stopwords(&lt;DATA&gt;); all_pod_files_spelling_ok(); __DATA__ CGI CPAN GPL Dolan STDIN STDOUT % perl Build test test_files=t\/00_local_spelling.t verbose=1 &#8230; # Failed test &#8216;POD spelling for blib\/lib\/Perl\/Critic\/Config.pm&#8217; not ok 3 &#8211; POD spelling for blib\/lib\/Perl\/Critic\/Config.pm # in \/Users\/chris\/perl\/lib\/perl5\/site_perl\/Test\/Spelling.pm at line 72. # Errors: # PBP # PERLCRITIC # Thalhammer &hellip; <a href=\"https:\/\/chrisdolan.net\/talk\/2005\/11\/14\/private-regression-tests\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Private Regression Tests<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5,16],"tags":[],"_links":{"self":[{"href":"https:\/\/chrisdolan.net\/talk\/wp-json\/wp\/v2\/posts\/31"}],"collection":[{"href":"https:\/\/chrisdolan.net\/talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chrisdolan.net\/talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chrisdolan.net\/talk\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/chrisdolan.net\/talk\/wp-json\/wp\/v2\/comments?post=31"}],"version-history":[{"count":0,"href":"https:\/\/chrisdolan.net\/talk\/wp-json\/wp\/v2\/posts\/31\/revisions"}],"wp:attachment":[{"href":"https:\/\/chrisdolan.net\/talk\/wp-json\/wp\/v2\/media?parent=31"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chrisdolan.net\/talk\/wp-json\/wp\/v2\/categories?post=31"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chrisdolan.net\/talk\/wp-json\/wp\/v2\/tags?post=31"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}