8 # The location of the TestSwarm that you're going to run against.
10 my $SWARM = "http://dev01.sf.archive.org:8080";
11 my $SWARM_INJECT = "/js/inject.js";
13 # Your TestSwarm username.
15 my $USER = "testflip";
17 # Your authorization token.
19 my $AUTH_TOKEN = ""; # $$$ Fill this in
21 # The maximum number of times you want the tests to be run.
25 # The type of revision control system being used.
26 # Currently "svn" or "git" are supported.
30 # The URL from which a copy will be checked out.
32 my $RCS_URL = "/home/testflip/bookreader/.git";
34 # The directory in which the checkouts will occur.
36 my $BASE_DIR = "/home/testflip/public_html/changeset";
38 # A script tag loading in the TestSwarm injection script will
39 # be added at the bottom of the <head> in the following file.
41 my $INJECT_FILE = "BookReaderIA/test/index.html";
43 # Any build commands that need to happen.
45 my $BUILD = "(cd BookReaderIA; make test)";
47 # The name of the job that will be submitted
48 # (pick a descriptive, but short, name to make it easy to search)
50 # Note: The string {REV} will be replaced with the current
53 my $JOB_NAME = "BookReader Commit #{REV}";
55 # The browsers you wish to run against. Options include:
56 # - "all" all available browsers.
57 # - "popular" the most popular browser (99%+ of all browsers in use)
58 # - "current" the current release of all the major browsers
59 # - "gbs" the browsers currently supported in Yahoo's Graded Browser Support
60 # - "beta" upcoming alpha/beta of popular browsers
61 # - "popularbeta" the most popular browser and their upcoming releases
63 my $BROWSERS = "popularbeta";
65 # All the suites that you wish to run within this job
66 # (can be any number of suites)
68 #my %SUITES = ('first' => 'http://test.archive.org/changeset/{REV}/test/index.html');
71 # Comment these out if you wish to define a custom set of SUITES above
72 #my $SUITE = "http://dev.jquery.com/~john/changeset/{REV}";
73 my $SUITE = "http://home.us.archive.org/~testflip/changeset/{REV}";
75 %SUITES = map { /(\w+).js$/; $1 => "$SUITE/test/?$1%20module"; } glob("test/unit/*.js");
78 ########### NO NEED TO CONFIGURE BELOW HERE ############
82 my $co_dir = "tmp-$curdate";
84 print "chdir $BASE_DIR\n" if ( $DEBUG );
87 # Check out a specific revision
88 if ( $RCS_TYPE eq "svn" ) {
89 print "svn co $RCS_URL $co_dir\n" if ( $DEBUG );
90 `svn co $RCS_URL $co_dir`;
91 } elsif ( $RCS_TYPE eq "git" ) {
92 print "git clone $RCS_URL $co_dir\n" if ( $DEBUG );
93 `git clone $RCS_URL $co_dir`;
97 die "Problem checking out source.";
100 print "chdir $co_dir\n" if ( $DEBUG );
105 # Figure out the revision of the checkout
106 if ( $RCS_TYPE eq "svn" ) {
107 print "svn info | grep Revision\n" if ( $DEBUG );
108 $rev = `svn info | grep Revision`;
109 $rev =~ s/Revision: //;
110 } elsif ( $RCS_TYPE eq "git" ) {
111 my $cmd = "git rev-parse --short HEAD";
112 print "$cmd\n" if ( $DEBUG );
118 print "Revision: $rev\n" if ( $DEBUG );
122 die "Revision information not found.";
124 } elsif ( ! -e "../$rev" ) {
125 print "chdir $BASE_DIR\n" if ( $DEBUG );
128 print "rename $co_dir $rev\n" if ( $DEBUG );
129 rename( $co_dir, $rev );
131 print "chdir $rev\n" if ( $DEBUG );
135 print "$BUILD\n" if ( $DEBUG );
139 if ( exists &BUILD_SUITES ) {
143 foreach my $file ( glob($INJECT_FILE) ) {
144 my $inject_file = `cat $file`;
146 # Inject the TestSwarm injection script into the test suite
147 $inject_file =~ s/<\/head>/<script>document.write("<scr" + "ipt src='$SWARM$SWARM_INJECT?" + (new Date).getTime() + "'><\/scr" + "ipt>");<\/script><\/head>/;
149 open( my $fh, '>', $file ) or die "$file : $!";
150 print $fh $inject_file;
159 "job_name" => $JOB_NAME,
160 "browsers" => $BROWSERS,
161 "auth" => $AUTH_TOKEN
166 foreach my $prop ( keys %props ) {
167 $query .= ($query ? "&" : "") . $prop . "=" . clean($props{$prop});
170 foreach my $suite ( sort keys %SUITES ) {
171 $query .= "&suites[]=" . clean($suite) .
172 "&urls[]=" . clean($SUITES{$suite});
175 # XXX hacking in host header for now
176 #print "curl -d \"$query\" $SWARM\n" if ( $DEBUG );
177 #my $results = `curl -d "$query" $SWARM`;
178 my $cmd = 'curl -H "Host: test.archive.org" -d "' . $query . '" ' . $SWARM;
179 print $cmd . '\n' if ( $DEBUG );
180 my $results = `$cmd`;
182 print "Results: $results\n" if ( $DEBUG );
185 open( my $fh, '>', "$rev/results.txt" ) or die "$rev/results.txt : $!";
186 print $fh "$SWARM$results";
190 die "Job not submitted properly.";
193 # Otherwise, give up and clean up
205 $str =~ s/{REV}/$rev/g;
206 $str =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;