[Tarantool-patches] [PATCH 1/2] test: update unit test lib to produce TAP-compliant output

Sergey Bronnikov sergeyb at tarantool.org
Tue Jun 2 12:20:18 MSK 2020


Vladislav,

please join to review as we discussed.

On 12:59 Thu 21 May , sergeyb at tarantool.org wrote:
> From: Alexander Turenko <alexander.turenko at tarantool.org>
> 
> Closes #5000
> ---
>  test/unit/CMakeLists.txt | 49 +++++++++++++++++++++-------------------
>  test/unit/unit.c         |  3 +++
>  test/unit/unit.h         | 13 ++++++++---
>  3 files changed, 39 insertions(+), 26 deletions(-)
> 
> diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt
> index 84eb066bd..0704d10f0 100644
> --- a/test/unit/CMakeLists.txt
> +++ b/test/unit/CMakeLists.txt
> @@ -23,46 +23,48 @@ target_link_libraries(stailq.test unit)
>  add_executable(uri.test uri.c unit.c)
>  target_link_libraries(uri.test uri unit)
>  add_executable(queue.test queue.c)
> +target_link_libraries(queue.test unit)
>  add_executable(mhash.test mhash.c)
>  target_link_libraries(mhash.test unit)
>  add_executable(mhash_bytemap.test mhash_bytemap.c)
>  target_link_libraries(mhash_bytemap.test unit)
>  add_executable(rope_basic.test rope_basic.c)
> -target_link_libraries(rope_basic.test salad)
> +target_link_libraries(rope_basic.test salad unit)
>  add_executable(rope_avl.test rope_avl.c)
> -target_link_libraries(rope_avl.test salad)
> +target_link_libraries(rope_avl.test salad unit)
>  add_executable(rope_stress.test rope_stress.c)
> -target_link_libraries(rope_stress.test salad)
> +target_link_libraries(rope_stress.test salad unit)
>  add_executable(rope.test rope.c)
> -target_link_libraries(rope.test salad)
> +target_link_libraries(rope.test salad unit)
>  add_executable(int96.test int96.cc)
> +target_link_libraries(int96.test unit)
>  add_executable(bit.test bit.c bit.c)
> -target_link_libraries(bit.test bit)
> +target_link_libraries(bit.test bit unit)
>  add_executable(bitset_basic.test bitset_basic.c)
> -target_link_libraries(bitset_basic.test bitset)
> +target_link_libraries(bitset_basic.test bitset unit)
>  add_executable(bitset_iterator.test bitset_iterator.c)
> -target_link_libraries(bitset_iterator.test bitset)
> +target_link_libraries(bitset_iterator.test bitset unit)
>  add_executable(bitset_index.test bitset_index.c)
> -target_link_libraries(bitset_index.test bitset)
> +target_link_libraries(bitset_index.test bitset unit)
>  add_executable(base64.test base64.c)
>  target_link_libraries(base64.test misc unit)
>  add_executable(uuid.test uuid.c)
>  target_link_libraries(uuid.test uuid unit)
>  
>  add_executable(bps_tree.test bps_tree.cc)
> -target_link_libraries(bps_tree.test small misc)
> +target_link_libraries(bps_tree.test small misc unit)
>  add_executable(bps_tree_iterator.test bps_tree_iterator.cc)
> -target_link_libraries(bps_tree_iterator.test small misc)
> +target_link_libraries(bps_tree_iterator.test small misc unit)
>  add_executable(rtree.test rtree.cc)
> -target_link_libraries(rtree.test salad small)
> +target_link_libraries(rtree.test salad small unit)
>  add_executable(rtree_iterator.test rtree_iterator.cc)
> -target_link_libraries(rtree_iterator.test salad small)
> +target_link_libraries(rtree_iterator.test salad small unit)
>  add_executable(rtree_multidim.test rtree_multidim.cc)
> -target_link_libraries(rtree_multidim.test salad small)
> +target_link_libraries(rtree_multidim.test salad small unit)
>  add_executable(light.test light.cc)
> -target_link_libraries(light.test small)
> +target_link_libraries(light.test small unit)
>  add_executable(bloom.test bloom.cc)
> -target_link_libraries(bloom.test salad)
> +target_link_libraries(bloom.test salad unit)
>  add_executable(vclock.test vclock.cc)
>  target_link_libraries(vclock.test vclock unit)
>  add_executable(xrow.test xrow.cc)
> @@ -87,19 +89,19 @@ if (NOT ENABLE_GCOV)
>  endif ()
>  
>  add_executable(fiber_stress.test fiber_stress.cc)
> -target_link_libraries(fiber_stress.test core)
> +target_link_libraries(fiber_stress.test core unit)
>  
>  add_executable(fiber_cond.test fiber_cond.c unit.c)
> -target_link_libraries(fiber_cond.test core)
> +target_link_libraries(fiber_cond.test core unit)
>  
>  add_executable(fiber_channel.test fiber_channel.cc unit.c)
> -target_link_libraries(fiber_channel.test core)
> +target_link_libraries(fiber_channel.test core unit)
>  
>  add_executable(fiber_channel_stress.test fiber_channel_stress.cc)
> -target_link_libraries(fiber_channel_stress.test core)
> +target_link_libraries(fiber_channel_stress.test core unit)
>  
>  add_executable(cbus_stress.test cbus_stress.c)
> -target_link_libraries(cbus_stress.test core stat)
> +target_link_libraries(cbus_stress.test core stat unit)
>  
>  add_executable(cbus.test cbus.c)
>  target_link_libraries(cbus.test core unit stat)
> @@ -129,21 +131,22 @@ if (ENABLE_BUNDLED_MSGPUCK)
>  endif ()
>  
>  add_executable(scramble.test scramble.c)
> -target_link_libraries(scramble.test scramble)
> +target_link_libraries(scramble.test scramble unit)
>  
>  add_executable(guava.test guava.c)
> -target_link_libraries(guava.test salad small)
> +target_link_libraries(guava.test salad small unit)
>  
>  add_executable(find_path.test find_path.c
>      ${CMAKE_SOURCE_DIR}/src/find_path.c
>  )
> +target_link_libraries(find_path.test unit)
>  
>  add_executable(reflection_c.test reflection_c.c unit.c
>      ${CMAKE_SOURCE_DIR}/src/lib/core/reflection.c)
>  add_executable(reflection_cxx.test reflection_cxx.cc unit.c
>      ${CMAKE_SOURCE_DIR}/src/lib/core/reflection.c)
>  add_executable(csv.test csv.c)
> -target_link_libraries(csv.test csv)
> +target_link_libraries(csv.test csv unit)
>  
>  add_executable(json.test json.c)
>  target_link_libraries(json.test json unit ${ICU_LIBRARIES})
> diff --git a/test/unit/unit.c b/test/unit/unit.c
> index d12b66f91..302dce2ef 100644
> --- a/test/unit/unit.c
> +++ b/test/unit/unit.c
> @@ -26,6 +26,9 @@ plan(int count)
>  	tests_done[level] = 0;
>  	tests_failed[level] = 0;
>  
> +	if (level == 0)
> +		printf("TAP version 13\n");
> +
>  	_space(stdout);
>  	printf("%d..%d\n", 1, plan_test[level]);
>  }
> diff --git a/test/unit/unit.h b/test/unit/unit.h
> index 43c301b28..27879ea98 100644
> --- a/test/unit/unit.h
> +++ b/test/unit/unit.h
> @@ -33,9 +33,6 @@
>  #include <stdio.h>
>  #include <stdlib.h> /* exit() */
>  
> -#define header() printf("\t*** %s ***\n", __func__)
> -#define footer() printf("\t*** %s: done ***\n", __func__)
> -
>  #define fail(expr, result) do {					\
>  	fprintf(stderr, "Test failed: %s is %s at %s:%d, in function '%s'\n",\
>  		expr, result, __FILE__, __LINE__, __func__);		\
> @@ -129,6 +126,16 @@ int check_plan(void);
>  	}						\
>  }
>  
> +#define header() do {				\
> +	_space(stdout);				\
> +	printf("# *** %s ***\n", __func__);	\
> +} while(0)
> +
> +#define footer() do {					\
> +	_space(stdout);					\
> +	printf("# *** %s: done ***\n", __func__);	\
> +} while(0)
> +
>  #if defined(__cplusplus)
>  }
>  #endif /* defined(__cplusplus) */
> -- 
> 2.23.0
> 

-- 
sergeyb@


More information about the Tarantool-patches mailing list