---
ChangeLog | 5 +
build-aux/build_unit_test.sh | 192 +++++++++++++++++++++++++++++++++---------
2 files changed, 157 insertions(+), 40 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ec948cc..dfa1ef6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-08-10 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ * build-aux/build_unit_test.sh: Add support for conditional
+ unit-tests.
+
2010-08-03 Guillaume Lazzara <z(a)lrde.epita.fr>
* configure.ac: Improve configure's outputs for external library
diff --git a/build-aux/build_unit_test.sh b/build-aux/build_unit_test.sh
index 8080ef2..15310ff 100755
--- a/build-aux/build_unit_test.sh
+++ b/build-aux/build_unit_test.sh
@@ -1,6 +1,6 @@
#! /bin/sh
-# Copyright (C) 2007, 2009 EPITA Research and Development Laboratory
+# Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
# (LRDE)
#
# This file is part of Olena.
@@ -17,6 +17,25 @@
# You should have received a copy of the GNU General Public License
# along with Olena. If not, see <http://www.gnu.org/licenses/>.
+## Build a list of unit tests.
+##
+## Conditional tests (external dependencies) can be handled
+## automaticaly. For each dependency, a file named
+## "cond_tests_{DEPS}" must contain the list of files which need the
+## dependency. If a test needs more than one dependency, several
+## dependency names can be used in the file name.
+##
+## Ex: cond_tests_qt_tesseract
+##
+## All the tests listed in this file will need both qt and tesseract
+## to be compiled.
+##
+## "cond_tests_*" files must be created in the directory where
+## unit-test.mk is generated (usually the unit-tests directory).
+##
+## WARNING: don't forget to add "cond_tests_*" files in the COND_TESTS
+## variable in the right Makefile.am.
+
## FIXME: Don't use `echo -n', as echo's options are not portable.
##
## http://www.gnu.org/software/autoconf/manual/html_node/Limitations-of-Builti…
@@ -25,44 +44,38 @@
## would be to only emit lines ended with newlines.
ECHO_N=printf
-# Use the C locale to have a deterministic sort.
-export LC_ALL=C
-test $# -eq 3 || { echo "Usage: $0 <scanned dir> <output_dir> <disabled_tests>" && exit 1; }
+add_targets()
+{
+ HEADERS_="$1"
+ output_dir="$2"
+ output="$3"
+ IFDEF="$4"
-scanned_dir=$1
-output_dir=$2
-disabled_tests=$3
+ if ! (test -z "$IFDEF"); then
+ echo "# Starting a conditional unit test list." >> "$output"
+ else
+ echo "# Starting non-conditional unit test list." >> "$output"
+ fi
-## FIXME: We do not include these directories
-##
-## mln/io/dicom
-## mln/io/fits
-## mln/io/magick
-## mln/io/tiff
-##
-## because they contain files depending on optional (external)
-## libraries. We should test them conditionally.
-HEADERS=$(find $scanned_dir -type f -name "*.hh" \
- | sort \
- | sed -e 's/.*\/mln\/\(.*\)/mln\/\1/g' | sed 's/\.\.\/\.\.\///g' \
- | comm -23 - "$disabled_tests")
+ # Start conditions if necessary
-output="$output_dir/unit-tests.mk"
+ # Construct a list of conditions in reverse order to write valid
+ # endif further.
+ IFDEF_TMP=""
+ for i in $IFDEF; do
+ echo "if HAVE_$i" >>"$output"
+ IFDEF_TMP="$i $IFDEF_TMP"
+ done
+ IFDEF="$IFDEF_TMP"
-rm -f "$output"
-rm -f mln_*.cc
+ $ECHO_N "check_PROGRAMS += " >>"$output"
-# Build unit-tests.mk.
-echo "## Generated by $0, do not modify." >"$output"
-echo >>"$output"
-$ECHO_N "check_PROGRAMS = " >>"$output"
-
-for i in $HEADERS; do
- FILE_CC=`echo $i | sed 's/[/.]/_/g' | sed 's/_hh/\.cc/g'`
+ for i in $HEADERS_; do
+ FILE_CC=`echo $i | sed 's/[/.]/_/g' | sed 's/_hh/\.cc/g'`
# Build .cc.
- cat > $output_dir/$FILE_CC << EOF
+ cat > $output_dir/$FILE_CC << EOF
// Unit test for $i.
// Generated by $0, do not modify.
@@ -77,16 +90,115 @@ int main()
EOF
# Build unit-tests.mk.
- TARGET=`echo "${FILE_CC}" | sed 's/\.cc//'`
- echo " \\" >>"$output"
- $ECHO_N "${TARGET}" >>"$output"
+ TARGET=`echo "${FILE_CC}" | sed 's/\.cc//'`
+ echo " \\" >>"$output"
+ $ECHO_N "${TARGET}" >>"$output"
+ done
+
+ # Build "$output".
+ echo "" >>"$output"
+ echo "" >>"$output"
+ for i in $HEADERS_; do
+ FILE_CC=`echo $i | sed 's/[/.]/_/g' | sed 's/_hh/\.cc/g'`
+ NAME=`echo $FILE_CC | sed 's/\.cc//g'`
+
+ # Write specific flags if there are dependencies.
+ if ! (test -z "$IFDEF"); then
+ cppflags="${NAME}_CPPFLAGS="
+ ldflags="${NAME}_LDFLAGS="
+ for i in $IFDEF; do
+ cppflags="${cppflags} \${${i}_CPPFLAGS} "
+ ldflags="${ldflags} \${${i}_LDFLAGS} "
+ done
+ echo "$cppflags \${AM_CPPFLAGS}" >>"$output"
+ echo "$ldflags \${AM_LDFLAGS}" >>"$output"
+ fi
+
+ echo "${NAME}_SOURCES = $FILE_CC" >>"$output"
+ done
+
+ # End conditions if necessary
+ for i in $IFDEF; do
+ echo "endif HAVE_$i" >>"$output"
+ done
+
+ echo "" >>"$output"
+}
+
+
+
+# Use the C locale to have a deterministic sort.
+export LC_ALL=C
+
+test $# -eq 4 || { echo "Usage: $0 <scanned dir> <output_dir> <disabled_tests> <base include dir>" && exit 1; }
+
+scanned_dir=$1
+output_dir=$2
+disabled_tests=$3
+base_inc_dir=$4
+
+# Create a list of tests to be disabled or considered as conditional.
+ignored_list="$output_dir/ignored_list.tmp"
+cat "$disabled_tests" > $ignored_list
+COND_TESTS=$(find $output_dir -type f -name "cond_tests_*" | sort)
+for f in $COND_TESTS; do
+ cat "$f" >> "$ignored_list"
done
+cat "$ignored_list" | sort > "$ignored_list.tmp"
+mv -f "$ignored_list.tmp" "$ignored_list"
-# Build "$output".
-echo "" >>"$output"
+HEADERS=$(find $scanned_dir -type f -name "*.hh" \
+ | sort \
+ | sed -e "s/.*\/${base_inc_dir}\/\(.*\)/${base_inc_dir}\/\1/g" \
+ | sed 's/\.\.\/\.\.\///g' \
+ | comm -23 - "$ignored_list")
+
+output="$output_dir/unit-tests.mk"
+
+# Cleanup previously generated data.
+rm -f "$output"
+rm -f ${base_inc_dir}_*.cc
+
+# Build unit-tests.mk.
+echo "## Generated by $0, do not modify." > "$output"
+echo >>"$output"
+
+echo "check_PROGRAMS =" >>"$output"
echo "" >>"$output"
-for i in $HEADERS; do
- FILE_CC=`echo $i | sed 's/[/.]/_/g' | sed 's/_hh/\.cc/g'`
- NAME=`echo $FILE_CC | sed 's/\.cc//g'`
- echo "${NAME}_SOURCES = $FILE_CC" >>"$output"
+
+
+#-----------------------------------
+# Insert lists of conditional tests.
+#-----------------------------------
+
+for f in $COND_TESTS; do
+ # Generate the list of conditions.
+ fpostfix="`echo \"$f\" | sed -e 's/.*\/cond_tests_//g'`_"
+ i=1
+ COND_LIST=""
+ while true; do
+ name=`echo $fpostfix | cut -s -d '_' -f $i \
+ | tr "[:lower:]" "[:upper:]"`
+ i=$(($i+1))
+ if (test -z "$name"); then
+ break;
+ fi
+ COND_LIST="${COND_LIST} $name"
+ done
+
+ COND_HEADERS=$(cat $f)
+
+ # Writing conditional targets
+ add_targets "$COND_HEADERS" "$output_dir" "$output" "$COND_LIST"
done
+
+
+#-------------------------------------
+# Insert list of non-conditional tests
+#-------------------------------------
+
+add_targets "$HEADERS" "$output_dir" "$output" ""
+
+
+# Remove temporary files
+rm -f "$ignored_list"
\ No newline at end of file
--
1.5.6.5
* core/object_image.hh: Remove.
* filter/object_groups_size_ratio.hh,
* filter/object_links_bbox_w_ratio.hh,
* filter/object_links_left_aligned.hh,
* filter/object_links_right_aligned.hh,
* primitive/extract/lines_h_thick_and_single.hh,
* primitive/extract/lines_v_thick_and_single.hh,
* primitive/link/internal/find_several_links.hh,
* primitive/link/internal/link_several_dmax_base.hh,
* primitive/link/with_single_up_link.hh,
* src/debug/show_links_left_right_links_validation.cc,
* src/primitive/find/find_discontinued_lines.cc,
* src/primitive/find/find_pattern_lines.cc,
* tests/filter/small_and_large_bboxes.cc,
* src/primitive/group/group_from_double_link_filter_non_aligned.cc:
Remove include of object_image.hh.
---
scribo/ChangeLog | 22 +++++++++++
scribo/core/object_image.hh | 38 --------------------
scribo/filter/object_groups_size_ratio.hh | 1 -
scribo/filter/object_links_bbox_w_ratio.hh | 1 -
scribo/filter/object_links_left_aligned.hh | 1 -
scribo/filter/object_links_right_aligned.hh | 1 -
.../primitive/extract/lines_h_thick_and_single.hh | 1 -
.../primitive/extract/lines_v_thick_and_single.hh | 1 -
.../primitive/link/internal/find_several_links.hh | 4 +-
.../link/internal/link_several_dmax_base.hh | 1 -
scribo/primitive/link/with_single_up_link.hh | 1 -
.../show_links_left_right_links_validation.cc | 1 -
.../src/primitive/find/find_discontinued_lines.cc | 1 -
scribo/src/primitive/find/find_pattern_lines.cc | 1 -
.../src/primitive/group/group_from_double_link.cc | 1 -
scribo/tests/filter/small_and_large_bboxes.cc | 3 --
16 files changed, 24 insertions(+), 55 deletions(-)
delete mode 100644 scribo/core/object_image.hh
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 7197f41..9882ea6 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,27 @@
2010-08-09 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Remove deprecated references to object_image.
+
+ * core/object_image.hh: Remove.
+
+ * filter/object_groups_size_ratio.hh,
+ * filter/object_links_bbox_w_ratio.hh,
+ * filter/object_links_left_aligned.hh,
+ * filter/object_links_right_aligned.hh,
+ * primitive/extract/lines_h_thick_and_single.hh,
+ * primitive/extract/lines_v_thick_and_single.hh,
+ * primitive/link/internal/find_several_links.hh,
+ * primitive/link/internal/link_several_dmax_base.hh,
+ * primitive/link/with_single_up_link.hh,
+ * src/debug/show_links_left_right_links_validation.cc,
+ * src/primitive/find/find_discontinued_lines.cc,
+ * src/primitive/find/find_pattern_lines.cc,
+ * tests/filter/small_and_large_bboxes.cc,
+ * src/primitive/group/group_from_double_link_filter_non_aligned.cc:
+ Remove include of object_image.hh.
+
+2010-08-09 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Cleanup Makefiles.
* src/Makefile.am: Disable tests and remove deprecated ones.
diff --git a/scribo/core/object_image.hh b/scribo/core/object_image.hh
deleted file mode 100644
index 7f672b2..0000000
--- a/scribo/core/object_image.hh
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
-//
-// This file is part of Olena.
-//
-// Olena is free software: you can redistribute it and/or modify it under
-// the terms of the GNU General Public License as published by the Free
-// Software Foundation, version 2 of the License.
-//
-// Olena is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Olena. If not, see <http://www.gnu.org/licenses/>.
-//
-// As a special exception, you may use this file as part of a free
-// software project without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to produce
-// an executable, this file does not by itself cause the resulting
-// executable to be covered by the GNU General Public License. This
-// exception does not however invalidate any other reasons why the
-// executable file might be covered by the GNU General Public License.
-
-#ifndef SCRIBO_CORE_OBJECT_IMAGE_HH
-# define SCRIBO_CORE_OBJECT_IMAGE_HH
-
-/// \file
-///
-/// FIXME.
-
-# include <mln/core/image/imorph/labeled_image.hh>
-
-# define object_image(L) \
- mln::labeled_image<L>
-
-#endif // ! SCRIBO_CORE_OBJECT_IMAGE_HH
diff --git a/scribo/filter/object_groups_size_ratio.hh b/scribo/filter/object_groups_size_ratio.hh
index 94d9b1b..fa59e7f 100644
--- a/scribo/filter/object_groups_size_ratio.hh
+++ b/scribo/filter/object_groups_size_ratio.hh
@@ -35,7 +35,6 @@
# include <scribo/core/macros.hh>
# include <scribo/core/object_groups.hh>
-# include <scribo/core/object_image.hh>
namespace scribo
{
diff --git a/scribo/filter/object_links_bbox_w_ratio.hh b/scribo/filter/object_links_bbox_w_ratio.hh
index 0bb373f..215413c 100644
--- a/scribo/filter/object_links_bbox_w_ratio.hh
+++ b/scribo/filter/object_links_bbox_w_ratio.hh
@@ -39,7 +39,6 @@
# include <scribo/core/macros.hh>
# include <scribo/core/object_links.hh>
-# include <scribo/core/object_image.hh>
# include <scribo/filter/object_links_bbox_ratio.hh>
namespace scribo
diff --git a/scribo/filter/object_links_left_aligned.hh b/scribo/filter/object_links_left_aligned.hh
index 059b423..82d4185 100644
--- a/scribo/filter/object_links_left_aligned.hh
+++ b/scribo/filter/object_links_left_aligned.hh
@@ -38,7 +38,6 @@
# include <scribo/core/macros.hh>
# include <scribo/core/object_links.hh>
-# include <scribo/core/object_image.hh>
# include <scribo/filter/object_links_non_aligned_simple.hh>
diff --git a/scribo/filter/object_links_right_aligned.hh b/scribo/filter/object_links_right_aligned.hh
index dfb06c7..07ca309 100644
--- a/scribo/filter/object_links_right_aligned.hh
+++ b/scribo/filter/object_links_right_aligned.hh
@@ -37,7 +37,6 @@
# include <scribo/core/macros.hh>
# include <scribo/core/object_links.hh>
-# include <scribo/core/object_image.hh>
# include <scribo/filter/object_links_non_aligned_simple.hh>
diff --git a/scribo/primitive/extract/lines_h_thick_and_single.hh b/scribo/primitive/extract/lines_h_thick_and_single.hh
index 551e5d8..dd495a4 100644
--- a/scribo/primitive/extract/lines_h_thick_and_single.hh
+++ b/scribo/primitive/extract/lines_h_thick_and_single.hh
@@ -38,7 +38,6 @@
# include <mln/morpho/opening/structural.hh>
-# include <scribo/core/object_image.hh>
# include <scribo/core/macros.hh>
# include <scribo/primitive/extract/lines_h_thick.hh>
diff --git a/scribo/primitive/extract/lines_v_thick_and_single.hh b/scribo/primitive/extract/lines_v_thick_and_single.hh
index c19ba5a..44f7a9e 100644
--- a/scribo/primitive/extract/lines_v_thick_and_single.hh
+++ b/scribo/primitive/extract/lines_v_thick_and_single.hh
@@ -38,7 +38,6 @@
# include <mln/morpho/opening/structural.hh>
-# include <scribo/core/object_image.hh>
# include <scribo/core/macros.hh>
# include <scribo/primitive/extract/lines_v_thick.hh>
diff --git a/scribo/primitive/link/internal/find_several_links.hh b/scribo/primitive/link/internal/find_several_links.hh
index 8cca3bd..4d9404e 100644
--- a/scribo/primitive/link/internal/find_several_links.hh
+++ b/scribo/primitive/link/internal/find_several_links.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -42,7 +43,6 @@
# include <scribo/core/concept/link_functor.hh>
# include <scribo/core/tag/anchor.hh>
-# include <scribo/core/object_image.hh>
# include <scribo/core/object_links.hh>
diff --git a/scribo/primitive/link/internal/link_several_dmax_base.hh b/scribo/primitive/link/internal/link_several_dmax_base.hh
index 3b4ec4b..e5b9ce2 100644
--- a/scribo/primitive/link/internal/link_several_dmax_base.hh
+++ b/scribo/primitive/link/internal/link_several_dmax_base.hh
@@ -43,7 +43,6 @@
# include <scribo/core/macros.hh>
# include <scribo/core/tag/anchor.hh>
-# include <scribo/core/object_image.hh>
# include <scribo/core/object_links.hh>
# include <scribo/primitive/link/internal/find_link.hh>
diff --git a/scribo/primitive/link/with_single_up_link.hh b/scribo/primitive/link/with_single_up_link.hh
index 4062275..eccf1fb 100644
--- a/scribo/primitive/link/with_single_up_link.hh
+++ b/scribo/primitive/link/with_single_up_link.hh
@@ -44,7 +44,6 @@
# include <scribo/core/macros.hh>
-# include <scribo/core/object_image.hh>
# include <scribo/core/object_links.hh>
# include <scribo/primitive/link/internal/find_link.hh>
diff --git a/scribo/src/debug/show_links_left_right_links_validation.cc b/scribo/src/debug/show_links_left_right_links_validation.cc
index e022fa5..450232a 100644
--- a/scribo/src/debug/show_links_left_right_links_validation.cc
+++ b/scribo/src/debug/show_links_left_right_links_validation.cc
@@ -38,7 +38,6 @@
#include <mln/value/label_16.hh>
#include <scribo/core/object_links.hh>
-#include <scribo/core/object_image.hh>
#include <scribo/primitive/extract/components.hh>
diff --git a/scribo/src/primitive/find/find_discontinued_lines.cc b/scribo/src/primitive/find/find_discontinued_lines.cc
index 244cae5..eec579a 100644
--- a/scribo/src/primitive/find/find_discontinued_lines.cc
+++ b/scribo/src/primitive/find/find_discontinued_lines.cc
@@ -35,7 +35,6 @@
#include <scribo/debug/usage.hh>
-#include <scribo/core/object_image.hh>
#include <scribo/primitive/extract/lines_h_discontinued.hh>
#include <scribo/primitive/extract/lines_v_discontinued.hh>
diff --git a/scribo/src/primitive/find/find_pattern_lines.cc b/scribo/src/primitive/find/find_pattern_lines.cc
index 540328b..88d22c0 100644
--- a/scribo/src/primitive/find/find_pattern_lines.cc
+++ b/scribo/src/primitive/find/find_pattern_lines.cc
@@ -35,7 +35,6 @@
#include <scribo/debug/usage.hh>
-#include <scribo/core/object_image.hh>
#include <scribo/primitive/extract/lines_h_pattern.hh>
#include <scribo/primitive/extract/lines_v_pattern.hh>
diff --git a/scribo/src/primitive/group/group_from_double_link.cc b/scribo/src/primitive/group/group_from_double_link.cc
index 00c68df..39b1bb9 100644
--- a/scribo/src/primitive/group/group_from_double_link.cc
+++ b/scribo/src/primitive/group/group_from_double_link.cc
@@ -36,7 +36,6 @@
#include <mln/value/label_16.hh>
#include <scribo/core/object_links.hh>
-#include <scribo/core/object_image.hh>
#include <scribo/primitive/extract/components.hh>
#include <scribo/primitive/group/apply.hh>
diff --git a/scribo/tests/filter/small_and_large_bboxes.cc b/scribo/tests/filter/small_and_large_bboxes.cc
index adae46f..653a8ca 100644
--- a/scribo/tests/filter/small_and_large_bboxes.cc
+++ b/scribo/tests/filter/small_and_large_bboxes.cc
@@ -32,9 +32,6 @@
#include <mln/value/label_16.hh>
#include <mln/io/pbm/load.hh>
#include <mln/literal/colors.hh>
-
-#include <scribo/core/object_image.hh>
-
#include <scribo/primitive/extract/components.hh>
#include <scribo/primitive/group/apply.hh>
#include <scribo/primitive/link/with_single_left_link.hh>
--
1.5.6.5