diff --git a/examples/C/CMakeLists.txt b/examples/C/CMakeLists.txt index 63b0adf45..b16c4a874 100644 --- a/examples/C/CMakeLists.txt +++ b/examples/C/CMakeLists.txt @@ -32,7 +32,6 @@ list( APPEND test_bins clone ) foreach( tool ${test_bins} ) - # here we use the fact that each tool has only one C file that matches its name ecbuild_add_executable( TARGET ${tool} NOINSTALL SOURCES ${tool}.c @@ -42,79 +41,29 @@ endforeach() # Now add each test ################################################# -ecbuild_add_test( TARGET c_iterator - TYPE SCRIPT - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/iterator.sh - RESOURCES include.sh -) -ecbuild_add_test( TARGET c_get - TYPE SCRIPT - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/get.sh - RESOURCES include.sh -) -ecbuild_add_test( TARGET c_print_data - TYPE SCRIPT - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/print_data.sh - RESOURCES include.sh -) -ecbuild_add_test( TARGET c_set - TYPE SCRIPT - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/set.sh - RESOURCES include.sh -) -ecbuild_add_test( TARGET c_keys_iterator - TYPE SCRIPT - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/keys_iterator.sh - RESOURCES include.sh -) -ecbuild_add_test( TARGET c_multi - TYPE SCRIPT - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/multi.sh - RESOURCES include.sh -) -ecbuild_add_test( TARGET c_multi_write - TYPE SCRIPT - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/multi_write.sh - RESOURCES include.sh -) -ecbuild_add_test( TARGET c_precision - TYPE SCRIPT - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/precision.sh - RESOURCES include.sh -) -ecbuild_add_test( TARGET c_list - TYPE SCRIPT - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/list.sh - RESOURCES include.sh -) - -ecbuild_add_test( TARGET c_large_grib1 - TYPE SCRIPT - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/large_grib1.sh - RESOURCES include.sh -) -ecbuild_add_test( TARGET c_get_data - TYPE SCRIPT - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/get_data.sh - RESOURCES include.sh -) - -ecbuild_add_test( TARGET c_set_missing - TYPE SCRIPT - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/set_missing.sh - RESOURCES include.sh -) -ecbuild_add_test( TARGET c_clone - TYPE SCRIPT - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/clone.sh - RESOURCES include.sh -) - -ecbuild_add_test( TARGET c_sections_copy - TYPE SCRIPT - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/sections_copy.sh - RESOURCES include.sh +list( APPEND tests + iterator + get + print_data + set + keys_iterator + multi + multi_write + precision + list + large_grib1 + get_data + set_missing + clone + sections_copy ) +foreach (test ${tests}) + ecbuild_add_test( TARGET c_${test} + TYPE SCRIPT + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${test}.sh + RESOURCES include.sh + ) +endforeach() ############################################# @@ -123,5 +72,6 @@ ecbuild_add_test( TARGET c_new_sample SOURCES new_sample.c LIBS grib_api ARGS "out.grib" - ENVIRONMENT "GRIB_SAMPLES_PATH=${PROJECT_SOURCE_DIR}/samples" "GRIB_DEFINITION_PATH=${PROJECT_SOURCE_DIR}/definitions" ) + ENVIRONMENT "GRIB_SAMPLES_PATH=${PROJECT_SOURCE_DIR}/samples" "GRIB_DEFINITION_PATH=${PROJECT_SOURCE_DIR}/definitions" +) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 49531ef5a..89dbb8865 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,3 +1,4 @@ add_subdirectory(C) add_subdirectory(F90) +add_subdirectory(python) diff --git a/examples/python/Makefile.am b/examples/python/Makefile.am index d85ec2967..29a7504af 100644 --- a/examples/python/Makefile.am +++ b/examples/python/Makefile.am @@ -5,11 +5,11 @@ TESTS = clone.sh count_messages.sh get.sh index.sh iterator.sh keys_iterator.sh samples.sh set.sh set_missing.sh binary_message.sh set_bitmap.sh TESTS_ENVIRONMENT = TOPBUILDDIR=$(top_builddir) PYTHON=$(PYTHON) -noinst_PROGRAMS = keys_iterator print_data iterator count_messages -keys_iterator_SOURCES = keys_iterator.c -print_data_SOURCES = print_data.c -iterator_SOURCES = iterator.c -count_messages_SOURCES = count_messages.c +noinst_PROGRAMS = p_keys_iterator p_print_data p_iterator p_count_messages +p_keys_iterator_SOURCES = keys_iterator.c +p_print_data_SOURCES = print_data.c +p_iterator_SOURCES = iterator.c +p_count_messages_SOURCES = count_messages.c INCLUDES = -I$(top_builddir)/src LDADD = $(top_builddir)/src/libgrib_api.la DEPENDENCIES = $(LDADD) diff --git a/examples/python/count_messages.sh b/examples/python/count_messages.sh index c11fdea8c..d12eef9d9 100755 --- a/examples/python/count_messages.sh +++ b/examples/python/count_messages.sh @@ -6,7 +6,7 @@ TEMP1=temp1 TEMP2=temp2 $PYTHON count_messages.py 2> $TEMP1 > $TEMP1 -./count_messages ../../data/tigge_pf_ecmwf.grib2 2> $TEMP2 > $TEMP2 +./p_count_messages ../../data/tigge_pf_ecmwf.grib2 2> $TEMP2 > $TEMP2 diff $TEMP1 $TEMP2 rm $TEMP1 $TEMP2 || true diff --git a/examples/python/include.sh b/examples/python/include.sh index 574147e56..ce02ecfef 100644 --- a/examples/python/include.sh +++ b/examples/python/include.sh @@ -1,19 +1,25 @@ -set -ea +CMAKE_INCLUDE_FILE=include.ctest.sh +if [ -f "$CMAKE_INCLUDE_FILE" ]; then + # This is the config file for Cmake tests + . ./$CMAKE_INCLUDE_FILE -echo -echo "TEST: $0" +else + set -ea + echo + echo "TEST: $0" -cpath=$TOPBUILDDIR -GRIB_DEFINITION_PATH=$cpath/definitions -export GRIB_DEFINITION_PATH -GRIB_SAMPLES_PATH=$cpath/samples -export GRIB_SAMPLES_PATH -tools_dir=$cpath/tools/ -examples_dir=$cpath/examples/python -data_dir=$cpath/data + cpath=$TOPBUILDDIR + GRIB_DEFINITION_PATH=$cpath/definitions + export GRIB_DEFINITION_PATH + GRIB_SAMPLES_PATH=$cpath/samples + export GRIB_SAMPLES_PATH + tools_dir=$cpath/tools/ + examples_dir=$cpath/examples/python + data_dir=$cpath/data -PYTHONPATH=$cpath/python:$cpath/python/.libs:$PYTHONPATH -export PYTHONPATH + PYTHONPATH=$cpath/python:$cpath/python/.libs:$PYTHONPATH + export PYTHONPATH -set -u + set -u +fi diff --git a/examples/python/iterator.sh b/examples/python/iterator.sh index cf3d0d1f5..8522aad6c 100755 --- a/examples/python/iterator.sh +++ b/examples/python/iterator.sh @@ -6,7 +6,7 @@ TEMP1=temp1 TEMP2=temp2 $PYTHON iterator.py 2> $TEMP1 > $TEMP1 -./iterator ../../data/reduced_latlon_surface.grib1 2> $TEMP2 > $TEMP2 +./p_iterator ../../data/reduced_latlon_surface.grib1 2> $TEMP2 > $TEMP2 diff $TEMP1 $TEMP2 rm $TEMP1 $TEMP2 || true diff --git a/examples/python/keys_iterator.sh b/examples/python/keys_iterator.sh index 451671b9e..55669f689 100755 --- a/examples/python/keys_iterator.sh +++ b/examples/python/keys_iterator.sh @@ -6,7 +6,7 @@ TEMP1=temp1 TEMP2=temp2 $PYTHON keys_iterator.py 2> $TEMP1 > $TEMP1 -./keys_iterator ../../data/reduced_latlon_surface.grib1 2> $TEMP2 > $TEMP2 +./p_keys_iterator ../../data/reduced_latlon_surface.grib1 2> $TEMP2 > $TEMP2 diff $TEMP1 $TEMP2 rm $TEMP1 $TEMP2 || true diff --git a/examples/python/print_data.sh b/examples/python/print_data.sh index ecc1ce15a..8164fc1f6 100755 --- a/examples/python/print_data.sh +++ b/examples/python/print_data.sh @@ -6,7 +6,7 @@ TEMP1=temp1 TEMP2=temp2 $PYTHON print_data.py 2> $TEMP1 > $TEMP1 -./print_data ../../data/regular_latlon_surface.grib1 2> $TEMP2 > $TEMP2 +./p_print_data ../../data/regular_latlon_surface.grib1 2> $TEMP2 > $TEMP2 diff $TEMP1 $TEMP2 rm $TEMP1 $TEMP2 || true