#! /bin/sh

# run all possible examples to test for regressions

test -f $CEXAM/toxd/toxd.mtz || (cd $CEXAM/toxd; ./na4tomtz.exam; ./completedata.exam)

test -f $CEXAM/rnase/rnase18.mtz || (cd $CEXAM/rnase; ./rnase_na4tomtz.exam; ./rnase_completedata.exam)

mkdir $CCP4_SCR/test-results 2>/dev/null

CCP4_SCR=$CCP4_SCR/test-results
export CCP4_SCR

for prog in mlphare.exam 3fo2fcmap act.exam scala.exam \
  almn.exam angles.exam arp_warp.exam axissearch.exam baverage.exam bplot.exam cad.exam \
  cavenv.exam refmac.exam compar.exam contact.exam coordconv.exam \
  crossec.exam areaimol.exam scalepack2mtz.exam surface.exam\
  distang.exam dm.exam dyndom.exam ecalc.exam sf_calc extend.exam mtz2various.exam \
  f2mtz.exam fft.exam fhscal.exam findncs.exam fofcmap fractional-orthogonal \
  freerflag.exam gensym.exam geomcalc.exam havecs.exam helixang.exam \
  hgen.exam hklplot.exam icoefl.exam lsqkab.exam mapcorrelation_procedures \
  scaleit.exam makedict.exam mapmask.exam mir_steps molrep.exam mtzdump.exam \
  mtzmnf.exam mtztona4.exam mtzutils.exam \
  ncsmask.exam npo.exam oasis_oas.exam oasis_sir.exam overlapmap.exam \
  patterson pdbset.exam phase_analysis \
  phased_translation_calc phistats.exam polarrfn.exam \
  polypose.exam protin.exam \
  protin_substrate rebatch.exam reindex.exam revise.exam \
  rotmat.exam solomon.exam tffc_procedure \
  rsearch.exam rsps.exam rwcontents.exam rwdict.exam \
  sigmaa.exam sortmtz.exam sortwater.exam stereo.exam surface-volume-calc tracer.exam \
  truncate.exam unique-free-R vecref.exam vectors.exam waterpeaks watpeak.exam \
  watertidy-3shells wilson.exam hbond.exam refmac5_tls.exam ; do

echo -n "$prog"

# I don't know a way round using the o/p file.  Something like a=`foo|tail`
# always returns success...
if $CEXAM/unix/runnable/$prog >$CCP4_SCR/log 2>&1; then
  echo -n ","
else
  echo; echo
  echo "*** $prog failed"
  tail $CCP4_SCR/log
  echo
fi

done

#omit.exam     # long
#restrain.exam     # long
#toxd-RF-Es ; MR-with-amore ; RF-with-Es     # long
#procheck.exam                     # runs ghostscript

rm -rf $CCP4_SCR   # clean up
