#!/bin/dash
# autopkgtest check
# (C) 2014 Anton Gladky <gladk@debian.org>

set -e

export FREECAD_USER_HOME="$AUTOPKGTEST_TMP"

WORKDIR=$(mktemp -d)
trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
cd $WORKDIR


# list of tests can be extraced with the FreeCAD python command: (Reference: https://wiki.freecad.org/Testing/de#Get_a_list_of_all_top-level_test_modules)
# FreeCAD.__unit_test__
# List of all tests:
tests_ok="TestSpreadsheet BaseTests UnitTests Document Metadata UnicodeTests TestPythonSyntax TestPathApp TestPartDesignApp TestDraft TestTechDrawApp MeshTestsApp TestSurfaceApp TestSketcherApp TestFemApp TestAddonManagerApp TestPartApp TestArch"

tests_flaky=""
# Marking TestFemApp flaky for now
tests_flaky="TestFemApp"
if dpkg-architecture -e i386 || dpkg-architecture -e s390x ; then
 tests_flaky="$tests_flaky TestPathApp"
fi

for t in $tests_ok
do
  for x in $tests_flaky ; do if [ "$x" = "$t" ] ; then t=""; break; fi ; done
  if [ -z "$t" ] ; then echo "### SKIPING TEST $x ###" ; continue ; fi
  echo "### Running CLI Test $t ### "
  freecadcmd -c -t $t
done

