[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

RE: running server side tests

From: Mark Shead <sheadm_at_optimalinternet.com>
Date: 2005-11-30 14:55:34 CET

> I am trying to setup subversion so that when a user commits source
code
> files to a server, the server can start running some unit tests on the
> source code, and if the source code does not pass any of the tests,
the
> user can be notified, and the files are not submitted.

You'll need to use a pre-commit hook. That hook will need to use
svnlook to copy all the files from the transaction to a location on your
hard drive and then run the tests. Svnlook needs to have access to the
repository files (you can't use Apache, or svnserve with svnlook).

Here is a perl script that will copy all the files for a transaction.
It would be nice if there was a way to actually check out a transaction
instead of just revisions, but that doesn't seem to be possible.

--Mark

#!/usr/bin/perl
#set the following variable from outside
#this script. They are coded here to make it
#easy to test.

$repo = "/Users/marks/repo/repo1";
$txn = "5-1";
$directory ="/trunk";
$working_directory = "/tmp/co/";
@tree = `svnlook tree $repo $directory --transaction $txn`; my $path; my
$file; my $directory_count = 1; foreach $item (@tree) {
        $item =~s/\n//;

        if($item == "/" && 1 == length $item) {
                next;
        }

        $leading_spaces = $item;
        $item=~s/\s*(.*)/$1/;
        $leading_spaces=~s/(\s*).*/$1/;
        $indent_count = length $leading_spaces;

        if($indent_count < $directory_count) {
                $path=~s/(.*)\/.+?\//$1\//;
        }

        if($item=~/\s*.*\//) {
                $path = $path . $item;
                $directory_count++;
                `mkdir $working_directory . $path`;
        } else {
                $file = $path . $item;
                `svnlook cat $repo $file > $working_direcctory . $file`;

        };

}

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Wed Nov 30 15:24:13 2005

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.