aboutsummaryrefslogtreecommitdiffstats
path: root/Scripts
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2011-01-11 20:28:40 +0000
committerstuconnolly <stuart02@gmail.com>2011-01-11 20:28:40 +0000
commit481ef5b0206604715449cbf6b1df83841ab4f2e5 (patch)
tree16df60ae379e2f6d37baa16d375e662c1aea3eb9 /Scripts
parent7d2238af04e18999b4dc83a92d82ac1944c0916d (diff)
downloadsequelpro-481ef5b0206604715449cbf6b1df83841ab4f2e5.tar.gz
sequelpro-481ef5b0206604715449cbf6b1df83841ab4f2e5.tar.bz2
sequelpro-481ef5b0206604715449cbf6b1df83841ab4f2e5.zip
Tidy up scripts and add create-test-stubs.pl to generate test stubs for the specified header. Run create-test-stubs.pl -h for usage.
Diffstat (limited to 'Scripts')
-rwxr-xr-xScripts/build-mysql-client.sh42
-rwxr-xr-xScripts/build-version.pl62
-rwxr-xr-xScripts/build.sh38
-rwxr-xr-xScripts/create-test-stubs.pl191
-rwxr-xr-xScripts/localize.sh38
-rwxr-xr-xScripts/package-application.sh33
-rwxr-xr-xScripts/run-tests.sh34
-rwxr-xr-xScripts/trim-application.sh60
8 files changed, 413 insertions, 85 deletions
diff --git a/Scripts/build-mysql-client.sh b/Scripts/build-mysql-client.sh
index 1641053c..fbaef809 100755
--- a/Scripts/build-mysql-client.sh
+++ b/Scripts/build-mysql-client.sh
@@ -1,16 +1,36 @@
#! /bin/ksh
-## $Id: build-mysql-client.sh 1044 2009-07-17 14:30:58Z stuart02 $
-##
-## Author: Stuart Connolly (stuconnolly.com)
-## Copyright (c) 2009 Stuart Connolly. All rights reserved.
-##
-## Paramters: -s -- The path to the MySQL source directory.
-## -q -- Quiet. Don't output any compiler messages.
-## -c -- Clean the source after build completes.
-## -d -- Debug. Output the build statements.
-##
-## Description: Builds the MySQL client libraries for distrubution in Sequel Pro's MCPKit MySQL framework.
+#
+# $Id$
+#
+# build-mysql-client.sh
+# sequel-pro
+#
+# Created by Stuart Connolly (stuconnolly.com)
+# Copyright (c) 2009 Stuart Connolly. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# More info at <http://code.google.com/p/sequel-pro/>
+
+# Builds the MySQL client libraries for distrubution in Sequel Pro's MCPKit MySQL framework.
+#
+# Paramters: -s -- The path to the MySQL source directory.
+# -q -- Quiet. Don't output any compiler messages.
+# -c -- Clean the source after build completes.
+# -d -- Debug. Output the build statements.
QUIET='NO'
DEBUG='NO'
diff --git a/Scripts/build-version.pl b/Scripts/build-version.pl
index fa12bfdb..92dcc15b 100755
--- a/Scripts/build-version.pl
+++ b/Scripts/build-version.pl
@@ -1,22 +1,42 @@
-#! /usr/bin/perl -w
-
-## $Id$
-##
-## Author: Stuart Connolly (stuconnolly.com)
-## Copyright (c) 2009 Stuart Connolly. All rights reserved.
-##
-## Paramters: <none>
-##
-## Description: Updates the application/bundle's Info.plist CFBundleVersion to match that of the current
-## Subversion revision.
+#! /usr/bin/perl
+
+#
+# $Id$
+#
+# build-version.pl
+# sequel-pro
+#
+# Created by Stuart Connolly (stuconnolly.com)
+# Copyright (c) 2009 Stuart Connolly. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# More info at <http://code.google.com/p/sequel-pro/>
+
+# Updates the application/bundle's Info.plist CFBundleVersion to match that of the current
+# Subversion revision.
use strict;
use warnings;
+use Carp;
+
die "$0: Must be run from within Xcode. Exiting..." unless $ENV{"BUILT_PRODUCTS_DIR"};
my $revision = `svnversion -n ./`;
-my $info_plist = "$ENV{BUILT_PRODUCTS_DIR}/$ENV{INFOPLIST_PATH}";
+my $plist_path = "$ENV{BUILT_PRODUCTS_DIR}/$ENV{INFOPLIST_PATH}";
my $version = $revision;
@@ -24,12 +44,18 @@ my $version = $revision;
die "$0: No Subversion revision found. Exiting..." unless $version;
-open(INFO_FH, "$info_plist") or die "$0: $info_plist: $!";
-my $info = join("", <INFO_FH>);
-close(INFO_FH);
+open(my $plist, $plist_path) || croak "Unable to open plist file for reading: $!";
+
+my $info = join('', <$plist>);
+
+close($plist);
$info =~ s/([\t ]+<key>CFBundleVersion<\/key>\n[\t ]+<string>).*?(<\/string>)/$1$version$2/;
-open(INFO_FH, ">$info_plist") or die "$0: $info_plist: $!";
-print INFO_FH $info;
-close(INFO_FH);
+open($plist, '>', $plist_path) || croak "Unable to open plist file for writing: $!";
+
+print $plist $info;
+
+close($plist);
+
+exit 0
diff --git a/Scripts/build.sh b/Scripts/build.sh
index a9291abb..51ae052c 100755
--- a/Scripts/build.sh
+++ b/Scripts/build.sh
@@ -1,15 +1,33 @@
#! /bin/ksh
-## $Id$
-##
-## Author: Stuart Connolly (stuconnolly.com)
-## Copyright (c) 2009 Stuart Connolly. All rights reserved.
-##
-## Paramters: <none>
-##
-## Description: Generic Sequel Pro build script. This script is intended to replace entering lots of code
-## into Xcode's 'Run Scripts' build phase to make it easier to work with. As such this script
-## can only be run by Xcode.
+#
+# $Id$
+#
+# build.sh
+# sequel-pro
+#
+# Created by Stuart Connolly (stuconnolly.com).
+# Copyright (c) 2009 Stuart Connolly. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# More info at <http://code.google.com/p/sequel-pro/>
+
+# Generic Sequel Pro build script. This script is intended to replace entering lots of code
+# into Xcode's 'Run Scripts' build phase to make it easier to work with. As such this script
+# can only be run by Xcode.
if [ "${BUILT_PRODUCTS_DIR}x" == 'x' ]
then
diff --git a/Scripts/create-test-stubs.pl b/Scripts/create-test-stubs.pl
new file mode 100755
index 00000000..ac4193ca
--- /dev/null
+++ b/Scripts/create-test-stubs.pl
@@ -0,0 +1,191 @@
+#! /usr/bin/perl
+
+#
+# $Id$
+#
+# create-test-stubs.sh
+# sequel-pro
+#
+# Created by Stuart Connolly (stuconnolly.com) on January 8, 2011
+# Copyright (c) 2011 Stuart Connolly. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# More info at <http://code.google.com/p/sequel-pro/>
+
+use strict;
+use warnings;
+
+use Carp;
+use Getopt::Long;
+
+use constant PROJECT_NAME => 'sequel-pro';
+use constant PROJECT_URL => 'http://code.google.com/p/sequel-pro/';
+
+#
+# Print this script's usage.
+#
+sub usage
+{
+ print << "EOF";
+Usage: perl $0 [options]
+
+Possible options are:
+
+ --header (-h) Source header file path (required)
+ --output (-c) The output path (required)
+ --author (-a) The author of the eventual test cases (required)
+ --help (-h) Print this help message
+
+EOF
+
+ exit 0;
+}
+
+#
+# Writes the standard license/copyright header to the supplied file handle;
+#
+sub write_header_to_file
+{
+ my ($handle, $filename, $author, $is_header) = @_;
+
+ my @date = localtime(time);
+
+ my @months = qw(January February March April May June July August September October November December);
+
+ my $year = ($date[5] + 1900);
+ my $month = $months[$date[4]];
+
+ my $project = PROJECT_NAME;
+ my $project_url = PROJECT_URL;
+
+ $filename = ($is_header) ? "${filename}.h" : "${filename}.m";
+
+ my $content = << "EOF";
+//
+// \$Id\$
+//
+// $filename
+// $project
+//
+// Created by $author on $month $date[3], $year
+// Copyright (c) $year ${author}. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// More info at <${project_url}>
+
+EOF
+
+ print $handle $content;
+}
+
+my ($header, $output, $author, $comments, $help);
+
+# Get options
+GetOptions('header|s=s' => \$header,
+ 'output|o=s' => \$output,
+ 'author|a=s' => \$author,
+ 'comments|c' => \$comments,
+ 'help|h' => \$help);
+
+usage if $help;
+usage if ((!$header) && (!$output) && (!$author));
+
+open(my $header_handle, $header) || croak "Unable to open source header file: $!";
+
+my @methods;
+my $class_name;
+my $category_name;
+
+# Extract all the methods (both instance and class) from the source header
+while (<$header_handle>)
+{
+ ($_ =~ /^\s*\@interface\s*([a-zA-z0-9_-]+)\s*\(([a-zA-z0-9_-]+)\)\s*$/) && ($class_name = $1, $category_name = $2);
+ ($_ =~ /^\s*[-|+]\s*\([a-zA-Z\s*\*_-]+\)(.*)$/) && (my $method_sig = $1);
+
+ $class_name =~ s/^\s+// if $class_name;
+ $class_name =~ s/\s+$// if $class_name;
+
+ $category_name =~ s/^\s+// if $category_name;
+ $category_name =~ s/\s+$// if $category_name;
+
+ push(@methods, $method_sig) if $method_sig;
+}
+
+close($header_handle);
+
+my $filename = ($category_name) ? $category_name : $class_name;
+my $new_filename = "${filename}Tests";
+
+my $header_file = "${output}/${new_filename}.h";
+my $imp_file = "${output}/${new_filename}.m";
+
+# Create the new header and implementation files
+open(my $output_header_handle, '>', $header_file) || croak "Unable to open output file: $!";
+open(my $output_imp_handle, '>', $imp_file) || croak "Unable to open output file: $!";
+
+print "Creating file '${header_file}'...\n";
+print "Creating file '${imp_file}'...\n";
+
+# Write the license header to the new files
+write_header_to_file($output_header_handle, $new_filename, $author, 1);
+write_header_to_file($output_imp_handle, $new_filename, $author, 0);
+
+print $output_header_handle "#import <SenTestingKit/SenTestingKit.h>\n\n\@interface $new_filename : SenTestCase\n{\n\n}\n\n\@end\n";
+print $output_imp_handle "#import \"${new_filename}.h\"\n#import \"${filename}.h\"\n\n\@implementation $new_filename\n\n";
+
+# Write the setup and tear down methods
+print $output_imp_handle "/**\n * Test case setup.\n */\n" if $comments;
+print $output_imp_handle "- (void)setUp\n{\n\n}\n\n";
+print $output_imp_handle "/**\n * Test case tear down.\n */\n" if $comments;
+print $output_imp_handle "- (void)tearDown\n{\n\n}\n\n";
+
+# For each of the extracted methods write a test case stub to the new test implementation file
+foreach (@methods)
+{
+ $_ =~ s/\([a-zA-Z\s*\*_-]*\)\s*[a-zA-z0-9_-]+//gi;
+ $_ =~ s/:\s*([a-zA-z0-9_-]+)\s*/\u$1/gi;
+ $_ =~ s/://;
+ $_ =~ s/;//;
+
+ my $method = "test\u$_";
+
+ print "Writing test case stub: $method\n";
+
+ print $output_imp_handle "/**\n * $_ test case.\n */\n" if $comments;
+ print $output_imp_handle "- (void)${method}\n{\n\n}\n\n";
+}
+
+print $output_imp_handle "\@end\n\n";
+
+close($output_header_handle);
+close($output_imp_handle);
+
+print "Test case stub generation complete for class '${filename}'\n";
+
+exit 0
diff --git a/Scripts/localize.sh b/Scripts/localize.sh
index e3de6957..0c74a01f 100755
--- a/Scripts/localize.sh
+++ b/Scripts/localize.sh
@@ -1,13 +1,31 @@
-#! /bin/ksh
-
-## $Id$
-##
-## Author: Created by Rowan Beentje.
-## Copyright (c) 2010 Sequel Pro Team. All rights reserved.
-##
-## Paramters: <none>
-##
-## Description: Localizes all of the application's NIB files. This script should only be run by Xcode.
+#! /bin/ksh
+
+#
+# $Id$
+#
+# localize.sh
+# sequel-pro
+#
+# Created by Rowan Beentje.
+# Copyright (c) 2010 Sequel Pro Team. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# More info at <http://code.google.com/p/sequel-pro/>
+
+# Localizes all of the application's NIB files. This script should only be run by Xcode.
if [ "${BUILT_PRODUCTS_DIR}x" == 'x' ]
then
diff --git a/Scripts/package-application.sh b/Scripts/package-application.sh
index 69e14058..7bc402b9 100755
--- a/Scripts/package-application.sh
+++ b/Scripts/package-application.sh
@@ -1,17 +1,34 @@
#!/bin/sh
-# $Id$
#
-# package-application.sh
-# sequel-pro
+# $Id$
#
-# A very basic script to build and sign a disk image for Sequel Pro; based on better work by Stuart Connolly.
+# package-application.sh
+# sequel-pro
#
-# Created by Rowan Beentje on 25/03/2009.
-# Copyright 2009 Sequel Pro Team. All rights reserved.
+# Created by Rowan Beentje on March 25, 2009.
+# Copyright (c) 2009 Sequel Pro Team. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# More info at <http://code.google.com/p/sequel-pro/>
-# Ensure the path to the application has been supplied - should have occurred when the
-# script was run by selecting "Distribution" target and building.
+# A very basic script to build and sign a disk image for Sequel Pro; based on better work by Stuart Connolly.
+#
+# Ensure the path to the application has been supplied - should have occurred when the
+# script was run by selecting 'Distribution' target and building.
if [ $# -eq 0 ]
then
diff --git a/Scripts/run-tests.sh b/Scripts/run-tests.sh
index d1472f5e..22ed51dd 100755
--- a/Scripts/run-tests.sh
+++ b/Scripts/run-tests.sh
@@ -1,13 +1,31 @@
#! /bin/ksh
-## $Id$
-##
-## Author: Stuart Connolly (stuconnolly.com)
-## Copyright (c) 2011 Stuart Connolly. All rights reserved.
-##
-## Paramters: <none>
-##
-## Description: Runs Sequel Pro's unit tests. This script should only be run by Xcode.
+#
+# $Id$
+#
+# run-tests.sh
+# sequel-pro
+#
+# Created by Stuart Connolly (stuconnolly.com)
+# Copyright (c) 2011 Stuart Connolly. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# More info at <http://code.google.com/p/sequel-pro/>
+
+# Runs Sequel Pro's unit tests. This script should only be run by Xcode.
# Add the unit test bundle's Frameworks/ path to the search paths for dynamic libraries
export DYLD_FRAMEWORK_PATH="${CONFIGURATION_BUILD_DIR}/${FULL_PRODUCT_NAME}/Contents/Frameworks"
diff --git a/Scripts/trim-application.sh b/Scripts/trim-application.sh
index a8194060..bc6a99ec 100755
--- a/Scripts/trim-application.sh
+++ b/Scripts/trim-application.sh
@@ -1,23 +1,43 @@
-#! /bin/ksh
-
-## $Id$
-##
-## Author: Stuart Connolly (stuconnolly.com)
-## Copyright (c) 2009 Stuart Connolly. All rights reserved.
-##
-## Largely based on 'trim-app' by Ankur Kothari ( http://lipidity.com/downloads/trim-app/ )
-##
-## Paramters: -p -- The path to the application that is to be trimmed
-## -d -- Remove unnecessary files (i.e. .DS_Store files, etc) (optional).
-## -n -- Trim nib files (i.e. remove .info.nib, classes.nib, data.dependency and designable.nib) (optional).
-## -s -- Strip debug symbols from application binary (optional).
-## -t -- Compress tiff images using LZW compression (optional).
-## -f -- Remove framework headers (optional).
-## -r -- Remove resource forks (optional).
-## -a -- All of above optional options. Equivalent to '-d -n -s -t -f -r'.
-##
-## Description: Trims an application bundle of unnecessary files and resources that are generally not required and otherwise
-## waste disk space.
+#! /bin/ksh
+
+#
+# $Id$
+#
+# trim-application.sh
+# sequel-pro
+#
+# Created by Stuart Connolly (stuconnolly.com)
+# Copyright (c) 2009 Stuart Connolly. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# More info at <http://code.google.com/p/sequel-pro/>
+
+# Trims an application bundle of unnecessary files and resources that are generally not required and otherwise
+# waste disk space.
+#
+# Largely based on 'trim-app' by Ankur Kothari ( http://lipidity.com/downloads/trim-app/ )
+#
+# Parameters: -p -- The path to the application that is to be trimmed
+# -d -- Remove unnecessary files (i.e. .DS_Store files, etc) (optional).
+# -n -- Trim nib files (i.e. remove .info.nib, classes.nib, data.dependency and designable.nib) (optional).
+# -s -- Strip debug symbols from application binary (optional).
+# -t -- Compress tiff images using LZW compression (optional).
+# -f -- Remove framework headers (optional).
+# -r -- Remove resource forks (optional).
+# -a -- All of above optional options. Equivalent to '-d -n -s -t -f -r'.
usage()
{