Added a test script to auto-test the standalone server
Andy Grundman [Mon, 17 Oct 2005 17:58:09 +0000 (17:58 +0000)]
t/optional/01http-server.ot [new file with mode: 0644]

diff --git a/t/optional/01http-server.ot b/t/optional/01http-server.ot
new file mode 100644 (file)
index 0000000..3520be1
--- /dev/null
@@ -0,0 +1,37 @@
+#!perl
+
+use strict;
+use warnings;
+
+use File::Copy::Recursive;
+use File::Path;
+use FindBin;
+
+# clean up
+rmtree "$FindBin::Bin/../../t/var" if -d "$FindBin::Bin/../../t/var";
+
+# create a TestApp and copy the test libs into it
+mkdir "$FindBin::Bin/../../t/var";
+chdir "$FindBin::Bin/../../t/var";
+system "$FindBin::Bin/../../script/catalyst.pl TestApp";
+chdir "$FindBin::Bin/../..";
+File::Copy::Recursive::dircopy( 't/live/lib', 't/var/TestApp/lib' );
+
+# spawn the standalone HTTP server
+my $pid = open SERVER, 
+    "$FindBin::Bin/../../t/var/TestApp/script/testapp_server.pl 2>&1 |"
+    or die "Unable to spawn standalone HTTP server: $!";
+    
+# wait for it to start
+sleep 2;
+    
+# run the testsuite against the HTTP server
+$ENV{CATALYST_SERVER} = 'http://localhost:3000';
+system( 'prove -r -Ilib/ t/live/' );
+
+# shut it down
+kill 2, $pid;
+close SERVER;
+
+# clean up
+rmtree "$FindBin::Bin/../../t/var" if -d "$FindBin::Bin/../../t/var";