<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre, #msg p { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[32951] trunk/WebKitTools</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/32951">32951</a></dd>
<dt>Author</dt> <dd>ddkilzer@apple.com</dd>
<dt>Date</dt> <dd>2008-05-07 02:50:58 -0700 (Wed, 07 May 2008)</dd>
</dl>

<h3>Log Message</h3>
<pre>        Use File::Find and Getopt::Long in make-js-test-wrappers

        Reviewed by Darin.

        * Scripts/make-js-test-wrappers:
        - Updated Apple copyright statement.
        - Added command-line switch parsing and -h|--help switch.
        - Allowed user to pass list of files/directories on which to do
          a restricted search for TEMPLATE.html files.  The default
          behavior is still to search the entire LayoutTests directory.
        - Removed duplicate 'use strict' statement.
        - Replaced use of `find` statements with File::Find::find().
        - Remove unneeded chomp() calls now that we use File::Find.
        (directoryFilter): Added.  Filters .svn directories when used
        with File::Find::find().
        (findTemplateFiles): Added.  Returns a list of TEMPLATE.html
        files found.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkWebKitToolsChangeLog">trunk/WebKitTools/ChangeLog</a></li>
<li><a href="#trunkWebKitToolsScriptsmakejstestwrappers">trunk/WebKitTools/Scripts/make-js-test-wrappers</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkWebKitToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebKitTools/ChangeLog (32950 => 32951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKitTools/ChangeLog        2008-05-07 09:37:29 UTC (rev 32950)
+++ trunk/WebKitTools/ChangeLog        2008-05-07 09:50:58 UTC (rev 32951)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2008-05-07  David Kilzer  &lt;ddkilzer@apple.com&gt;
+
+        Use File::Find and Getopt::Long in make-js-test-wrappers
+
+        Reviewed by Darin.
+
+        * Scripts/make-js-test-wrappers:
+        - Updated Apple copyright statement.
+        - Added command-line switch parsing and -h|--help switch.
+        - Allowed user to pass list of files/directories on which to do
+          a restricted search for TEMPLATE.html files.  The default
+          behavior is still to search the entire LayoutTests directory.
+        - Removed duplicate 'use strict' statement.
+        - Replaced use of `find` statements with File::Find::find().
+        - Remove unneeded chomp() calls now that we use File::Find.
+        (directoryFilter): Added.  Filters .svn directories when used
+        with File::Find::find().
+        (findTemplateFiles): Added.  Returns a list of TEMPLATE.html
+        files found.
+
</ins><span class="cx"> 2008-05-05  Steve Falkenburg  &lt;sfalken@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Copy dependencies of ImageDiff, DumpRenderTree in post-build step.
</span></span></pre></div>
<a id="trunkWebKitToolsScriptsmakejstestwrappers"></a>
<div class="modfile"><h4>Modified: trunk/WebKitTools/Scripts/make-js-test-wrappers (32950 => 32951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKitTools/Scripts/make-js-test-wrappers        2008-05-07 09:37:29 UTC (rev 32950)
+++ trunk/WebKitTools/Scripts/make-js-test-wrappers        2008-05-07 09:50:58 UTC (rev 32951)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> #!/usr/bin/perl -w
</span><span class="cx"> 
</span><del>-# Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
</del><ins>+# Copyright (C) 2006, 2007, 2008 Apple Inc.  All rights reserved.
</ins><span class="cx"> #
</span><span class="cx"> # Redistribution and use in source and binary forms, with or without
</span><span class="cx"> # modification, are permitted provided that the following conditions
</span><span class="lines">@@ -29,23 +29,38 @@
</span><span class="cx"> # Script to generate HTML wrappers for JavaScript tests from templates
</span><span class="cx"> 
</span><span class="cx"> use strict;
</span><ins>+
</ins><span class="cx"> use FindBin;
</span><span class="cx"> use lib $FindBin::Bin;
</span><ins>+
+use File::Basename;
+use File::Find;
+use Getopt::Long;
</ins><span class="cx"> use webkitdirs;
</span><span class="cx"> 
</span><ins>+sub directoryFilter;
+sub findTemplateFiles(@);
+
+my $showHelp;
+
+my $result = GetOptions(
+    &quot;help&quot;       =&gt; \$showHelp,
+);
+
+if (!$result || $showHelp) {
+    print STDERR basename($0) . &quot; [-h|--help] [path ...]\n&quot;;
+    exit 1;
+}
+
</ins><span class="cx"> setConfiguration();
</span><span class="cx"> my $productDir = productDir();
</span><span class="cx"> 
</span><del>-use strict;
-
</del><span class="cx"> chdirWebKit();
</span><span class="cx"> 
</span><del>-my @templates = `find LayoutTests -name &quot;TEMPLATE.html&quot;`;
</del><ins>+my @templates = findTemplateFiles(@ARGV);
</ins><span class="cx"> 
</span><span class="cx"> for my $tfile (@templates) {
</span><span class="cx"> 
</span><del>-    chomp $tfile;
-
</del><span class="cx">     my $tpath = $tfile;
</span><span class="cx">     $tpath =~ s:/resources/TEMPLATE.html$::;
</span><span class="cx"> 
</span><span class="lines">@@ -54,7 +69,11 @@
</span><span class="cx">     chdirWebKit();
</span><span class="cx">     chdir($tpath);
</span><span class="cx"> 
</span><del>-    my @files = `find resources -name &quot;*.js&quot;`;
</del><ins>+    my @files;
+    my $fileFilter = sub {
+        push @files, $File::Find::name if substr($_, -3) eq &quot;.js&quot;;
+    };
+    find({ preprocess =&gt; \&amp;directoryFilter, wanted =&gt; $fileFilter }, &quot;resources&quot;);
</ins><span class="cx"> 
</span><span class="cx">     open TEMPLATE, &quot;&lt;resources/TEMPLATE.html&quot;;
</span><span class="cx">     my $template = do { local $/; &lt;TEMPLATE&gt; };
</span><span class="lines">@@ -68,7 +87,6 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     for my $file (@files) {
</span><del>-        chomp $file;
</del><span class="cx">         next if $file =~ /js-test-.*\.js$/;
</span><span class="cx">         next if $file =~ /SVGTestCase\.js/;
</span><span class="cx">         next if $file =~ m:resources/attr-case-sensitivity\.js$:;
</span><span class="lines">@@ -101,3 +119,28 @@
</span><span class="cx">         close HTML;
</span><span class="cx">     }
</span><span class="cx"> }
</span><ins>+
+exit 0;
+
+sub directoryFilter
+{
+    return () if basename($File::Find::dir) eq &quot;.svn&quot;;
+    return @_;
+}
+
+sub findTemplateFiles(@) {
+    my @args = @_;
+    my @templateFiles;
+
+    push @args, &quot;LayoutTests&quot; if scalar(@args) == 0;
+
+    my @paths = map { -f $_ ? dirname($_) : $_ } @args;
+
+    my $fileFilter = sub {
+        push @templateFiles, $File::Find::name if $_ eq &quot;TEMPLATE.html&quot;;
+    };
+
+    find({ preprocess =&gt; \&amp;directoryFilter, wanted =&gt; $fileFilter }, @paths);
+
+    return @templateFiles;
+}
</ins></span></pre>
</div>
</div>

</body>
</html>