Add "Unknown error" check
Rafael Kitover [Tue, 21 Apr 2009 06:56:29 +0000 (06:56 +0000)]
Makefile.PL
t/lib/UnknownError.pm [new file with mode: 0644]

index b57759f..4adfd44 100644 (file)
@@ -15,6 +15,48 @@ requires 'parent'; # as of 1.04
 requires 'Path::Class' => '0.09';
 requires 'Template'    => '2.14';
 
+if (!$ENV{CATALYST_DEVEL_NO_510_CHECK}) {
+    use Symbol 'gensym';
+    use IPC::Open3;
+    use File::Spec;
+    open NULL, '>', File::Spec->devnull;
+    my $err = gensym;
+    my $pid = open3(gensym, '&>NULL', $err, "$^X -It/lib -MUnknownError -e 1");
+    
+    my $unknown_error = 0;
+
+    while (<$err>) {
+        $unknown_error = 1 if /^Unknown error/;
+    }
+
+    waitpid $pid, 0;
+
+    if ($unknown_error) {
+        warn <<EOE;
+############################### WARNING #################################
+#                                                                       #
+# You are using perl 5.10.0 with the "Unknown error" bug. This can make #
+# developing Catalyst applications much more painful, as it will come   # 
+# up with no details every time you have a syntax error in a Controller.#
+#                                                                       #
+# For more information see:                                             #
+#                                                                       #
+#  * http://rt.perl.org/rt3/Public/Bug/Display.html?id=49472            #
+#                                                                       #
+# It is highly recommended that you patch your perl, or use a different #
+# version for Catalyst development.                                     #
+#                                                                       #
+# To skip this check, set the CATALYST_DEVEL_NO_510_CHECK environment   #
+# variable.                                                             #
+#                                                                       #
+#########################################################################
+
+EOE
+        my $ans = prompt('Do you want to continue?', 'no');
+        exit 0 unless $ans =~ /^y(es)?\z/i;
+    }
+}
+
 auto_install;
 
 WriteAll;
diff --git a/t/lib/UnknownError.pm b/t/lib/UnknownError.pm
new file mode 100644 (file)
index 0000000..c14415b
--- /dev/null
@@ -0,0 +1,8 @@
+# thanks kd
+package UnknownError;
+use strict;
+sub MODIFY_CODE_ATTRIBUTES {}
+sub  check : Blah {
+$error = "please explode" ; # deliberate syntax error
+}
+1;