fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2011-02-22 09:44 am

[dw-free] Framework for JS unit tests

[commit: http://hg.dwscoalition.org/dw-free/rev/5cad96087a9a]

http://bugs.dwscoalition.org/show_bug.cgi?id=3524

Don't include in the routing table at all, if we're not a dev server.

Patch by [personal profile] fu.

Files modified:
  • cgi-bin/DW/Controller/Dev.pm
--------------------------------------------------------------------------------
diff -r 7987e36ba2a6 -r 5cad96087a9a cgi-bin/DW/Controller/Dev.pm
--- a/cgi-bin/DW/Controller/Dev.pm	Tue Feb 22 17:12:12 2011 +0800
+++ b/cgi-bin/DW/Controller/Dev.pm	Tue Feb 22 17:43:00 2011 +0800
@@ -7,7 +7,7 @@
 # Authors:
 #      Afuna <coder.dw@afunamatata.com>
 #
-# Copyright (c) 2010 by Dreamwidth Studios, LLC.
+# Copyright (c) 2010-2011 by Dreamwidth Studios, LLC.
 #
 # This program is free software; you may redistribute it and/or modify it under
 # the same terms as Perl itself. For a copy of the license, please reference
@@ -23,7 +23,8 @@ DW::Routing->register_static( '/dev/clas
 DW::Routing->register_static( '/dev/classes', 'dev/classes.tt', app => 1 );
 
 
-DW::Routing->register_regex( '/dev/tests/([^/]+)(?:/(.*))?', \&tests_handler, app => 1 );
+DW::Routing->register_regex( '/dev/tests/([^/]+)(?:/(.*))?', \&tests_handler, app => 1 )
+    if $LJ::IS_DEV_SERVER;
 
 sub tests_handler {
     my ( $opts ) = @_;
@@ -31,7 +32,6 @@ sub tests_handler {
     my $lib = $opts->subpatterns->[1] || "";
 
     my $r = DW::Request->get;
-    return $r->NOT_FOUND unless $LJ::IS_DEV_SERVER;
 
     # force a site scheme which only shows the bare content
     # but still prints out resources included using need_res
--------------------------------------------------------------------------------
sophie: A cartoon-like representation of a girl standing on a hill, with brown hair, blue eyes, a flowery top, and blue skirt. ☀ (Default)

[personal profile] sophie 2011-02-22 11:00 am (UTC)(link)
I'm not sure this is the right way to go. We still need to be able to test codepaths for when $LJ::IS_DEV_SERVER is off, don't we? (In fact, I'd say that would be quite important.)

Or am I missing something?

[edit: To make clear; I don't have an issue with the tests not being included in the main repo. But I think that if we do put them in a separate repo, then we should have the switch for whether the tests are on *in that repo*, so that when the code for tests is checked out, the tests are automatically enabled, and if the test repo isn't there, they're disabled. Then there wouldn't be an issue.]
Edited 2011-02-22 11:04 (UTC)