#!/usr/bin/perl # CONFIGURE # The location of the TestSwarm that you're going to run against. my $SWARM = "http://testswarm.com"; my $SWARM_INJECT = "/js/inject.js"; # Your TestSwarm username. my $USER = "mootools"; # Your authorization token. my $AUTH_TOKEN = ""; # The maximum number of times you want the tests to be run. my $MAX_RUNS = 1; # The type of revision control system being used. # Currently "svn" or "git" are supported. my $RCS_TYPE = "git"; # The URL from which a copy will be checked out. my $RCS_URL = "git://github.com/mootools/mootools-core.git"; # The directory in which the checkouts will occur. my $BASE_DIR = "/home/john/public_html/changeset/mootools"; # A script tag loading in the TestSwarm injection script will # be added at the bottom of the in the following file. my $INJECT_FILE = "Specs/index.html"; # Any build commands that need to happen. my $BUILD = "cp ../Builder.js Specs/Assets/Scripts/"; # The name of the job that will be submitted # (pick a descriptive, but short, name to make it easy to search) # Note: The string {REV} will be replaced with the current # commit number/hash. my $JOB_NAME = "MooTools Commit #{REV}"; # The browsers you wish to run against. Options include: # - "all" all available browsers. # - "popular" the most popular browser (99%+ of all browsers in use) # - "current" the current release of all the major browsers # - "gbs" the browsers currently supported in Yahoo's Graded Browser Support # - "beta" upcoming alpha/beta of popular browsers # - "popularbeta" the most popular browser and their upcoming releases my $BROWSERS = "popularbeta"; # All the suites that you wish to run within this job # (can be any number of suites) my %SUITES = (); # Comment these out if you wish to define a custom set of SUITES above my $SUITE = "http://dev.jquery.com/~john/changeset/mootools/{REV}/Specs/"; sub BUILD_SUITES { my $index = `cat $INJECT_FILE`; $index =~ s/.*Specs:\s*{(.*?)}.*/$1/s; $index =~ s/'\w+'\s*://g; %SUITES = map { my $file = (glob("Specs/*/$_.js"))[0]; if ( `grep describe $file` ) { $_ => "$SUITE?file=$_"; } } ($index =~ /'([\w.]+)'/g); } ########### NO NEED TO CONFIGURE BELOW HERE ############ my $DEBUG = 1; my $curdate = time; my $co_dir = "tmp-$curdate"; print "chdir $BASE_DIR\n" if ( $DEBUG ); chdir( $BASE_DIR ); # Check out a specific revision if ( $RCS_TYPE eq "svn" ) { print "svn co $RCS_URL $co_dir\n" if ( $DEBUG ); `svn co $RCS_URL $co_dir`; } elsif ( $RCS_TYPE eq "git" ) { print "git clone $RCS_URL $co_dir\n" if ( $DEBUG ); `git clone $RCS_URL $co_dir`; } if ( ! -e $co_dir ) { die "Problem checking out source."; } print "chdir $co_dir\n" if ( $DEBUG ); chdir( $co_dir ); my $rev; # Figure out the revision of the checkout if ( $RCS_TYPE eq "svn" ) { print "svn info | grep Revision\n" if ( $DEBUG ); $rev = `svn info | grep Revision`; $rev =~ s/Revision: //; } elsif ( $RCS_TYPE eq "git" ) { print "git log --abbrev-commit | head -1\n" if ( $DEBUG ); $rev = `git log --abbrev-commit | head -1`; $rev =~ s/commit.*?(\w+).*$/$1/; } $rev =~ s/\s*//g; print "Revision: $rev\n" if ( $DEBUG ); if ( ! $rev ) { remove_tmp(); die "Revision information not found."; } elsif ( ! -e "../$rev" ) { print "chdir $BASE_DIR\n" if ( $DEBUG ); chdir( $BASE_DIR ); print "rename $co_dir $rev\n" if ( $DEBUG ); rename( $co_dir, $rev ); print "chdir $rev\n" if ( $DEBUG ); chdir ( $rev ); if ( $BUILD ) { print "$BUILD\n" if ( $DEBUG ); `$BUILD`; } if ( exists &BUILD_SUITES ) { &BUILD_SUITES(); } foreach my $file ( glob($INJECT_FILE) ) { my $inject_file = `cat $file`; # Inject the TestSwarm injection script into the test suite $inject_file =~ s/<\/head>/