<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>jmblog.jp &#187; Catalyst</title>
	<atom:link href="http://jmblog.jp/archives/tag/catalyst/feed" rel="self" type="application/rss+xml" />
	<link>http://jmblog.jp</link>
	<description></description>
	<lastBuildDate>Fri, 12 Aug 2011 05:18:47 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Catalyst::Plugin::FillInForm の install に失敗したときの対応</title>
		<link>http://jmblog.jp/archives/409</link>
		<comments>http://jmblog.jp/archives/409#comments</comments>
		<pubDate>Thu, 02 Jul 2009 16:55:08 +0000</pubDate>
		<dc:creator>Yoshihide</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[Catalyst]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://jmblog.jp/?p=409</guid>
		<description><![CDATA[仕事の関係で、1ヶ月ほど前から、5年ぶりぐらいに Perl の世界に戻ってきてます。5年も離れていると、すっかり浦島太郎状態で、DBIC って何？DBI じゃないの？というレベルなのですが、とにかく、Catalyst やら Moose やらの「モダンPerl」に日々格闘中です。
で、このエントリの本題ですが、Catalyst::Plugin::FillInForm のバージョン0.11 をインストールしようとしたら、テストに失敗してしまったけど、何とか対応できた、というお話です。久々のブログ更新でいきなり技術的な濃いエントリですが、気にしない、気にしない。

CPAN からインストールしようとすると、以下のようにテストに失敗してしまいました。

$ sudo cpan Catalyst::Plugin::FillInForm
Running install for module 'Catalyst::Plugin::FillInForm'
Running make for F/FL/FLORA/Catalyst-Plugin-FillInForm-0.11.tar.gz
  Has already been unwrapped into directory /Users/Yoshihide/.cpan/build/Catalyst-Plugin-FillInForm-0.11-RwmONZ
  Has already been made
Running make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'inc', 'blib/lib', 'blib/arch')" t/*.t
t/01use.t .......... ok
t/02pod.t .......... skipped: set TEST_POD to enable this test
t/03podcoverage.t .. [...]]]></description>
			<content:encoded><![CDATA[<p>仕事の関係で、1ヶ月ほど前から、5年ぶりぐらいに Perl の世界に戻ってきてます。5年も離れていると、すっかり浦島太郎状態で、DBIC って何？DBI じゃないの？というレベルなのですが、とにかく、Catalyst やら Moose やらの「モダンPerl」に日々格闘中です。</p>
<p>で、このエントリの本題ですが、<a href="http://search.cpan.org/~flora/Catalyst-Plugin-FillInForm-0.11/">Catalyst::Plugin::FillInForm</a> のバージョン0.11 をインストールしようとしたら、テストに失敗してしまったけど、何とか対応できた、というお話です。久々のブログ更新でいきなり技術的な濃いエントリですが、気にしない、気にしない。</p>
<p><span id="more-409"></span></p>
<p>CPAN からインストールしようとすると、以下のようにテストに失敗してしまいました。</p>
<pre>
$ sudo cpan Catalyst::Plugin::FillInForm
Running install for module 'Catalyst::Plugin::FillInForm'
Running make for F/FL/FLORA/Catalyst-Plugin-FillInForm-0.11.tar.gz
  Has already been unwrapped into directory /Users/Yoshihide/.cpan/build/Catalyst-Plugin-FillInForm-0.11-RwmONZ
  Has already been made
Running make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'inc', 'blib/lib', 'blib/arch')" t/*.t
t/01use.t .......... ok
t/02pod.t .......... skipped: set TEST_POD to enable this test
t/03podcoverage.t .. skipped: set TEST_POD to enable this test
t/04fillform1.t .... [error] No default action defined
t/04fillform1.t .... 1/3
#   Failed test 'OK status code'
#   at t/04fillform1.t line 22.
#          got: '500'
#     expected: '200'
Parsing of undecoded UTF-8 will give garbage when decoding entities at t/04fillform1.t line 23.

#   Failed test 'Re-Parsed HTML'
#   at t/04fillform1.t line 24.
#          got: undef
#     expected: 'form1:aaa|one|bbb|two|ccc|three|ddd|four|form2:aaa|one|bbb|two|ccc|three|ddd|four|'
# Looks like you failed 2 tests of 3.
t/04fillform1.t .... Dubious, test returned 2 (wstat 512, 0x200)
Failed 2/3 subtests
t/04fillform2.t .... [error] No default action defined
t/04fillform2.t .... 1/3
#   Failed test 'OK status code'
#   at t/04fillform2.t line 22.
#          got: '500'
#     expected: '200'
Parsing of undecoded UTF-8 will give garbage when decoding entities at t/04fillform2.t line 23.

#   Failed test 'Re-Parsed HTML'
#   at t/04fillform2.t line 24.
#          got: undef
#     expected: 'form1:aaa||bbb|two|ccc|three|ddd|four|form2:aaa||bbb|two|ccc|three|ddd|four|'
# Looks like you failed 2 tests of 3.
t/04fillform2.t .... Dubious, test returned 2 (wstat 512, 0x200)
Failed 2/3 subtests
t/04fillform3.t .... [error] No default action defined
t/04fillform3.t .... 1/3
#   Failed test 'OK status code'
#   at t/04fillform3.t line 22.
#          got: '500'
#     expected: '200'
Parsing of undecoded UTF-8 will give garbage when decoding entities at t/04fillform3.t line 23.

#   Failed test 'Re-Parsed HTML'
#   at t/04fillform3.t line 24.
#          got: undef
#     expected: 'form1:aaa||bbb||ccc||ddd||form2:aaa|one|bbb|two|ccc|three|ddd|four|'
# Looks like you failed 2 tests of 3.
t/04fillform3.t .... Dubious, test returned 2 (wstat 512, 0x200)
Failed 2/3 subtests
t/04fillform4.t .... [error] No default action defined
t/04fillform4.t .... 1/3
#   Failed test 'OK status code'
#   at t/04fillform4.t line 22.
#          got: '500'
#     expected: '200'
Parsing of undecoded UTF-8 will give garbage when decoding entities at t/04fillform4.t line 23.

#   Failed test 'Re-Parsed HTML'
#   at t/04fillform4.t line 24.
#          got: undef
#     expected: 'form1:aaa|one|bbb|two|ccc|three|ddd||form2:aaa|one|bbb|two|ccc|three|ddd||'
# Looks like you failed 2 tests of 3.
t/04fillform4.t .... Dubious, test returned 2 (wstat 512, 0x200)
Failed 2/3 subtests 

Test Summary Report
-------------------
t/04fillform1.t  (Wstat: 512 Tests: 3 Failed: 2)
  Failed tests:  2-3
  Non-zero exit status: 2
t/04fillform2.t  (Wstat: 512 Tests: 3 Failed: 2)
  Failed tests:  2-3
  Non-zero exit status: 2
t/04fillform3.t  (Wstat: 512 Tests: 3 Failed: 2)
  Failed tests:  2-3
  Non-zero exit status: 2
t/04fillform4.t  (Wstat: 512 Tests: 3 Failed: 2)
  Failed tests:  2-3
  Non-zero exit status: 2
Files=7, Tests=13,  4 wallclock secs ( 0.04 usr  0.02 sys +  3.37 cusr  0.29 csys =  3.72 CPU)
Result: FAIL
Failed 4/7 test programs. 8/13 subtests failed.
make: *** [test_dynamic] Error 2
  FLORA/Catalyst-Plugin-FillInForm-0.11.tar.gz
  /usr/bin/make test -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
  reports FLORA/Catalyst-Plugin-FillInForm-0.11.tar.gz
Running make install
  make test had returned bad status, won't install without force
Failed during this command:
 FLORA/Catalyst-Plugin-FillInForm-0.11.tar.gz : make_test NO
</pre>
<p>「Parsing of undecoded UTF-8 will give garbage when decoding entities」というエラーメッセージからいろいろググってみて、HTML::Parser あたりの問題かと思ったのですが、原因がいまいちはっきりしません。もう一度テスト結果をよく見てみると、どうやら HTTPステータスが 200 を返さずに 500 を返しているようです。tar ファイルをローカルに落としてきて、t/04fillform1.t を見てみると、テスト用のCatalystアプリ（t/lib/TestApp1.pm）を動かしているらしい。つまり、Catalyst のサーバーが  Internal Server Error を吐いているのがテストが失敗している原因のようです。というわけで、$response->content の中身をHTMLファイルに書き出してみました。すると、Catalyst の見慣れたエラー画面が。</p>
<blockquote><p>
No default action defined
</p></blockquote>
<p>t/lib/TestApp1.pm のソースを見てみると、確かに default アクションが定義されていない。なので、以下のコードを追加してみました。</p>
<div class="codecolorer-container perl twitlight" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="perl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">sub</span> default <span style="color: #339933;">:</span>Path <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">my</span> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">$self</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$c</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">@_</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; <span style="color: #0000ff;">$c</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">res</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">body</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$html</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>そしてテストを実行してみると・・・</p>
<pre>
t/04fillform1.t .. ok
All tests successful.
Files=1, Tests=3,  1 wallclock secs ( 0.03 usr  0.00 sys +  0.81 cusr  0.06 csys =  0.90 CPU)
Result: PASS
</pre>
<p>ひゃっほい！通った！他の、t/lib/TestApp*.pm も同じ改修をしたら、テストはすべて通り、無事インストールすることができました。</p>
<p>というわけで、最初は依存モジュールをいろいろ疑ったのですが、どうやらテストコードに問題があったようです。なので、force installしちゃってもよさそうですね。</p>
<p>ちなみに、私の環境では、Catalyst 5.80007 を使いました。たぶん、 <a href="http://cpansearch.perl.org/src/FLORA/Catalyst-Plugin-FillInForm-0.11/Makefile.PL">Catalyst::Plugin::FillInForm の Makefile.PL</a> を見ると</p>
<div class="codecolorer-container text twitlight" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">requires 'Catalyst' =&gt; '5.7012';</div></div>
<p>とあったので、5.8系に対応したテストコードになっていなかったんじゃないかと思うんですが、本当のところはどうなんでしょうか？教えて、えらい人！</p>
<p>もし、同じ症状でお困りの方のお役に立てれば幸いです。</p>
]]></content:encoded>
			<wfw:commentRss>http://jmblog.jp/archives/409/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

