#!/bin/sh

# XXX consider using lastStableBuild
BUILD=`wget http://deadlock.nbextras.org/hudson/job/trunk/lastSuccessfulBuild/buildNumber -O -`

TESTDIST="http://deadlock.netbeans.org/job/test-compilation/lastSuccessfulBuild/artifact/nbbuild/build/testdist.zip"
PLATFORM="http://deadlock.netbeans.org/job/trunk/lastSuccessfulBuild/artifact/nbbuild/dist/zip/netbeans-hudson-trunk-$BUILD-platform.zip"

[ -f `basename $TESTDIST` ] || wget $TESTDIST
[ -f `basename $PLATFORM` ] || wget $PLATFORM


rm -rf testdist
mkdir testdist
unzip testdist.zip -d testdist

rm -rf netbeans
mkdir netbeans
unzip netbeans*platform*.zip -d netbeans
mkdir netbeans/etc
echo >netbeans/etc/netbeans.conf

#-ant -f testdist/build.xml unit -Dnetbeans.dest.dir=`pwd`/netbeans
ant -f testdist/unit/unit-all-unit.xml runtests -Dnetbeans.dest.dir=`pwd`/netbeans $*





