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 = "";
20 open(AUTHFILE, "/home/testflip/.testswarm");
21 my $AUTH_TOKEN = <AUTHFILE>;
24 # The maximum number of times you want the tests to be run.
28 # The type of revision control system being used.
29 # Currently "svn" or "git" are supported.
33 # The URL from which a copy will be checked out.
35 my $RCS_URL = "/home/testflip/bookreader/.git";
37 # The directory in which the checkouts will occur.
39 my $BASE_DIR = "/home/testflip/public_html/changeset";
41 # A script tag loading in the TestSwarm injection script will
42 # be added at the bottom of the <head> in the following file.
44 my $INJECT_FILE = "BookReaderIA/test/index.html";
46 # Any build commands that need to happen.
48 my $BUILD = "(cd BookReaderIA; make test)";
50 # The name of the job that will be submitted
51 # (pick a descriptive, but short, name to make it easy to search)
53 # Note: The string {REV} will be replaced with the current
56 my $JOB_NAME = "BookReader Commit #{REV}";
58 # The browsers you wish to run against. Options include:
59 # - "all" all available browsers.
60 # - "popular" the most popular browser (99%+ of all browsers in use)
61 # - "current" the current release of all the major browsers
62 # - "gbs" the browsers currently supported in Yahoo's Graded Browser Support
63 # - "beta" upcoming alpha/beta of popular browsers
64 # - "popularbeta" the most popular browser and their upcoming releases
66 my $BROWSERS = "popularbeta";
68 # All the suites that you wish to run within this job
69 # (can be any number of suites)
71 #my %SUITES = ('first' => 'http://test.archive.org/changeset/{REV}/test/index.html');
74 # Comment these out if you wish to define a custom set of SUITES above
75 #my $SUITE = "http://dev.jquery.com/~john/changeset/{REV}";
76 my $SUITE = "http://home.us.archive.org/~testflip/changeset/{REV}/BookReaderIA";
78 %SUITES = map { /(\w+).js$/; $1 => "$SUITE/test/?$1%20module"; } glob("BookReaderIA/test/unit/*.js");
81 ########### NO NEED TO CONFIGURE BELOW HERE ############
85 my $co_dir = "tmp-$curdate";
87 print "chdir $BASE_DIR\n" if ( $DEBUG );
90 # Check out a specific revision
91 if ( $RCS_TYPE eq "svn" ) {
92 print "svn co $RCS_URL $co_dir\n" if ( $DEBUG );
93 `svn co $RCS_URL $co_dir`;
94 } elsif ( $RCS_TYPE eq "git" ) {
95 print "git clone $RCS_URL $co_dir\n" if ( $DEBUG );
96 `git clone $RCS_URL $co_dir`;
100 die "Problem checking out source.";
103 print "chdir $co_dir\n" if ( $DEBUG );
108 # Figure out the revision of the checkout
109 if ( $RCS_TYPE eq "svn" ) {
110 print "svn info | grep Revision\n" if ( $DEBUG );
111 $rev = `svn info | grep Revision`;
112 $rev =~ s/Revision: //;
113 } elsif ( $RCS_TYPE eq "git" ) {
114 my $cmd = "git rev-parse --short HEAD";
115 print "$cmd\n" if ( $DEBUG );
121 print "Revision: $rev\n" if ( $DEBUG );
125 die "Revision information not found.";
127 } elsif ( ! -e "../$rev" ) {
128 print "chdir $BASE_DIR\n" if ( $DEBUG );
131 print "rename $co_dir $rev\n" if ( $DEBUG );
132 rename( $co_dir, $rev );
134 print "chdir $rev\n" if ( $DEBUG );
138 print "$BUILD\n" if ( $DEBUG );
142 if ( exists &BUILD_SUITES ) {
146 foreach my $file ( glob($INJECT_FILE) ) {
147 my $inject_file = `cat $file`;
149 # Inject the TestSwarm injection script into the test suite
150 $inject_file =~ s/<\/head>/<script>document.write("<scr" + "ipt src='$SWARM$SWARM_INJECT?" + (new Date).getTime() + "'><\/scr" + "ipt>");<\/script><\/head>/;
152 open( my $fh, '>', $file ) or die "$file : $!";
153 print $fh $inject_file;
162 "job_name" => $JOB_NAME,
163 "browsers" => $BROWSERS,
164 "auth" => $AUTH_TOKEN
169 foreach my $prop ( keys %props ) {
170 $query .= ($query ? "&" : "") . $prop . "=" . clean($props{$prop});
173 foreach my $suite ( sort keys %SUITES ) {
174 $query .= "&suites[]=" . clean($suite) .
175 "&urls[]=" . clean($SUITES{$suite});
178 # XXX hacking in host header for now
179 #print "curl -d \"$query\" $SWARM\n" if ( $DEBUG );
180 #my $results = `curl -d "$query" $SWARM`;
181 my $cmd = 'curl -H "Host: test.archive.org" -d "' . $query . '" ' . $SWARM;
182 print $cmd . '\n' if ( $DEBUG );
183 my $results = `$cmd`;
185 print "Results: $results\n" if ( $DEBUG );
188 open( my $fh, '>', "$rev/results.txt" ) or die "$rev/results.txt : $!";
189 print $fh "$SWARM$results";
193 die "Job not submitted properly.";
196 # Otherwise, give up and clean up
208 $str =~ s/{REV}/$rev/g;
209 $str =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;