Skip to content

Commit

Permalink
add empty testname tests (#496)
Browse files Browse the repository at this point in the history
* add empty testname tests
* fix compiler error check python code
* add vs experimental preprocessor test on Azp
* fix vs traditional pp detect
  • Loading branch information
srz-zumix committed Sep 6, 2020
1 parent dfe56eb commit b6bb669
Show file tree
Hide file tree
Showing 23 changed files with 433 additions and 64 deletions.
21 changes: 21 additions & 0 deletions .ci/azure_pipelines/template-cmake-steps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# optional cmake test steps template

parameters:
generator_name: 'Visual Studio 2019'
platform: 'x64'
cmake_options: ''
TEST_CONFIGURATION: 'Debug'

steps:
- bash: |
mkdir build && cd build
cmake ../projects/cmake -G "${{ parameters.generator_name}}" -A ${{ parameters.platform }} ${{ parameters.cmake_options }}
displayName: 'generate'

- bash: |
cd build && cmake --build .
displayName: 'build'

- bash: |
cd build && ctest -C ${{ parameters.TEST_CONFIGURATION }} -V --output-on-failure
displayName: 'test'
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ script:
- |
if [ "${COVERITY_SCAN}" != '1' ] && [ "${USE_CMAKE}" != '1' ]; then
make -j4 showcxxversion ${USE_FUSED} default &&
make test ${USE_FUSED}
make test ${USE_FUSED} &&
make report
fi
- |
Expand Down Expand Up @@ -132,6 +132,7 @@ env:
global:
# COVERITY_SCAN_TOKEN
- secure: "R+KDlvwR4+5JbW/Ahm9HHkGHfe3MdU7VPpqxOpbAMc95KFIHLsRcMaJBNCBZMUWXGEjXNsTy6gBR4ZI/XQvTnlYMxabzNbJgMMO6YmI7czXw8yt7zR1+UnVaWE7KEA3d9suZ4jnwIUsIw0AtYZYbCHnDNuOUbpRf+8DrpXsSa/sPqYAvHcvDg4rRtEcLii0lsygcQHNzz0vUivDEiZtBVFlJTo+BkxicVH/Jkv/30KYcFD6Ao9wpJCMC4ysvlTeytTQj0s59PLVkfhYEc3VFQL1BLVGZoesS0BFNY/ZJ8n61Dvu8yNjg/tEMYht0H8278okc59RM2a2MUM5OSs+qC59pGsbsGpm9ScrIoLPi7YzaH6dxpm5iAIcKCVCiOFUdBjqNramfg+X0SMVV1hxPbaQEwQTX9M74QxPj7iue7W9MAYzqrcGJguDZYt/+m/SaM6rzOzI10GY+gNzlyp0aPOQZkp1Mw63NttCatr7Klw2yVP7CE+UuB648AVGrIFgfLAuugSCw3OVCFSnThhXfSjH57v0+3HTivsm3QHLYbTtyHymQOtfG7AB/FgvKF9nxCnDkzP3d5ijNEVWEfL8dF8+QqM8AFZGFHHjXHeopK22myzfuyRVZI8LIbcRAT1MCddmp2hgrRFJRX/Hl29QvGumZtU45xOKJwyKQorxXlfU="
- IUTEST_REQUIRE_PYTHON: yes

matrix:
- STDFLAG=-std=c++98
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ for:
before_build:
cmd: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\vsdevcmd.bat"'
build_script:
cmd: cd test && nmake
cmd: cd test && nmake all_tests && all_tests --spec && nmake
test_script:
cmd: nmake test
# Prefast
Expand Down
16 changes: 16 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,22 @@ stages:
- template: .ci/azure_pipelines/template-make-mix-test.yml
parameters:
name: mix
- stage: VisualStudioExperimental
dependsOn: Precheck
jobs:
- job: visual_studio_test
strategy:
matrix:
USE_EXPERIMENTAL:
CMAKE_OPTIONS: -Dbuild_gtest_samples=ON -Dbuild_use_experimental=ON
pool:
vmImage: windows-2019
steps:
- template: .ci/azure_pipelines/template-cmake-steps.yml
parameters:
generator_name: Visual Studio 16 2019
platform: x64
cmake_options: "${CMAKE_OPTIONS}"
# - stage: Publish
# dependsOn:
# Test
Expand Down
17 changes: 11 additions & 6 deletions include/internal/iutest_internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

#define IIUT_TO_NAME_(name_) IIUT_TO_NAME_I( (IIUT_ALIAS_TESTNAME_PP_##name_, name_, name_, dummy_) )
#define IIUT_TO_NAME_I(tuple_) IUTEST_PP_EXPAND( IIUT_TO_NAME_I_ tuple_ )
#define IIUT_TO_NAME_I_(dummy, dummy_2, name_, ...) name_
#define IIUT_TO_NAME_I_(d1_, d2_, name_, ...) name_

#define IIUT_TO_NAME_STR_(name_) IUTEST_PP_TOSTRING( IIUT_TO_NAME_(name_) )

Expand Down Expand Up @@ -139,6 +139,9 @@
* @brief Test class defined macro
*/
#define IUTEST_TEST_(testsuite_, testname_, parent_class_, type_id_) \
IUTEST_STATIC_ASSERT_MSG(sizeof(IUTEST_PP_TOSTRING(testsuite_)) > 1, "testsuite_ must not be empty"); \
IUTEST_STATIC_ASSERT_MSG(sizeof(IUTEST_PP_TOSTRING(testname_)) > 1, "testname_ must not be empty"); \
IUTEST_STATIC_ASSERT_MSG(sizeof(IUTEST_PP_TOSTRING(IIUT_TO_NAME_(testsuite_))) > 1, "testsuite alias name must not be empty"); \
class IUTEST_TEST_CLASS_NAME_(testsuite_, testname_) : public parent_class_ { \
IUTEST_PP_DISALLOW_COPY_AND_ASSIGN(IUTEST_TEST_CLASS_NAME_(testsuite_, testname_)); \
public: IUTEST_TEST_CLASS_NAME_(testsuite_, testname_)() {} \
Expand Down Expand Up @@ -613,26 +616,28 @@

/**
* @brief コンパイルエラーチェックタグ
* @param e = error message regexp
*/
#if defined(_MSC_VER) && !defined(__clang__)
# define IUTEST_TEST_COMPILEERROR(e) \
IUTEST_PRAGMA_MESSAGE(__FILE__ "(" IUTEST_PP_TOSTRING(__LINE__) "): note : " "IUTEST_TEST_COMPILEERROR( " #e " )")
IUTEST_PRAGMA_MESSAGE(__FILE__ "(" IUTEST_PP_TOSTRING(__LINE__) "): note : " "IUTEST_TEST_COMPILEERROR( " e " )")
#else
# define IUTEST_TEST_COMPILEERROR(e) \
IUTEST_PRAGMA_MESSAGE("IUTEST_TEST_COMPILEERROR( " #e " )")
IUTEST_PRAGMA_MESSAGE("IUTEST_TEST_COMPILEERROR( " e " )")
#endif

/**
* @brief static_assert チェックタグ
* @{
* @brief static_assert チェックタグ
* @param e = error message regexp
* @{
*/
#if IUTEST_HAS_STATIC_ASSERT
# define IUTEST_TEST_STATICASSERT(e) IUTEST_TEST_COMPILEERROR(e)
#else
# define IUTEST_TEST_STATICASSERT(e) IUTEST_TEST_COMPILEERROR("static_assert")
#endif
/**
* @}
* @}
*/

#endif // INCG_IRIS_IUTEST_INTERNAL_HPP_A5BD9FBB_B57A_4C1D_B205_0ADB7798DBF9_
13 changes: 11 additions & 2 deletions include/internal/iutest_pp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* @author t.shirayanagi
* @par copyright
* Copyright (C) 2011-2018, Takazumi Shirayanagi\n
* Copyright (C) 2011-2020, Takazumi Shirayanagi\n
* This software is released under the new BSD License,
* see LICENSE
*/
Expand All @@ -18,6 +18,12 @@
//======================================================================
// define

#if defined(_MSC_VER) && !defined(__clang__)
# if !defined(_MSVC_TRADITIONAL) || _MSVC_TRADITIONAL
# define IUTEST_PP_MSVC_TRADITIONAL
# endif
#endif

/**
* @brief コピー禁止定義
*/
Expand Down Expand Up @@ -714,6 +720,9 @@
#define IIUT_PP_EMPTY_TAG() , 0
#define IIUT_PP_EMPTY_TAG_IIUT_PP_EMPTY_TAG 1, 1 IUTEST_PP_EMPTY

// IF EMPTY
#define IUTEST_PP_IF_EMPTY(x, t, f) IUTEST_PP_IF(IUTEST_PP_IS_EMPTY(x), t, f)

// IDENTITY
#define IUTEST_PP_IDENTITY(x) x IUTEST_PP_EMPTY

Expand All @@ -726,7 +735,7 @@

#endif

#if defined(_MSC_VER) && !defined(__clang__)
#if defined(IUTEST_PP_MSVC_TRADITIONAL)
#define IIUT_PP_VD_CAT(a, b) IIUT_PP_VD_CAT_I(a, b)
#define IIUT_PP_VD_CAT_I(a, b) IIUT_PP_VD_CAT_II(a ## b)
#define IIUT_PP_VD_CAT_II(res) res
Expand Down
4 changes: 0 additions & 4 deletions include/iutest_body.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,7 @@ class Test

protected:
virtual void SetUp() {} //!< 実行前処理
#if IUTEST_HAS_AUTOFIXTURE_PARAM_TEST
virtual void Body() {} //!< テスト実装部
#else
virtual void Body() = 0; //!< テスト実装部
#endif
virtual void TearDown() {} //!< 実行後処理

public:
Expand Down
1 change: 1 addition & 0 deletions include/iutest_param_tests.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ class ParamTestInstance : public IParamTestInfoData
TestInfo m_info;
};
public:
ParamTestInstance() : IParamTestInfoData("") {} // allow empty name
explicit ParamTestInstance(const char* testsuite_name) : IParamTestInfoData(testsuite_name) {}

private:
Expand Down
2 changes: 2 additions & 0 deletions include/iutest_typed_tests.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@
#endif

#define IIUT_TYPED_TEST_I(classname_, testsuite_, testsuitename_, testname_) \
IUTEST_STATIC_ASSERT_MSG(sizeof(IUTEST_PP_TOSTRING(testsuite_)) > 1, "testsuite_ must not be empty"); \
IUTEST_STATIC_ASSERT_MSG(sizeof(IUTEST_PP_TOSTRING(testname_)) > 1, "testname_ must not be empty"); \
template<typename iutest_TypeParam> class classname_ : public testsuite_<iutest_TypeParam> { \
typedef testsuite_<iutest_TypeParam> TestFixture; \
typedef iutest_TypeParam TypeParam; \
Expand Down
2 changes: 2 additions & 0 deletions projects/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ if (build_tests)
cxx_executable_test(csvparams_tests)
cxx_executable_test(cxx_feature_tests)
cxx_executable_test(disabled_tests)
cxx_executable_test(empty_testname_tests)
cxx_executable_test(env_var_gtest_tests)
cxx_executable_test(environment_tests)
cxx_executable_test(exception_assertion_tests)
Expand Down Expand Up @@ -280,6 +281,7 @@ if (build_tests)
cxx_add_test(commandline_tests)
cxx_add_test(csvparams_tests)
cxx_add_test(disabled_tests)
cxx_add_test(empty_testname_tests)
cxx_add_test(env_var_gtest_tests)
cxx_add_test(environment_tests)
cxx_add_test(exception_assertion_tests)
Expand Down
7 changes: 7 additions & 0 deletions projects/cmake/internal_utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ macro(fix_default_compiler_settings_)
)
message(STATUS "${flag_var}=${${flag_var}}")
endforeach()

# experimental
if (build_use_experimental)
if(NOT (MSVC_VERSION LESS 1910))
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /experimental:preprocessor /Wv:18")
endif()
endif()
endif()
set(CMAKE_CXX_FLAGS_DEBUG_GTEST "${CMAKE_CXX_FLAGS_DEBUG} -DIUTEST_USE_GTEST")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG_GTEST ${CMAKE_EXE_LINKER_FLAGS_DEBUG})
Expand Down
2 changes: 2 additions & 0 deletions test/CommonMakefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ TARGETS1= \
$(OUTDIR)/csvparams_tests \
$(OUTDIR)/cxx_feature_tests \
$(OUTDIR)/disabled_tests \
$(OUTDIR)/empty_testname_tests \
$(OUTDIR)/env_var_gtest_tests \
$(OUTDIR)/environment_tests \
$(OUTDIR)/exception_assertion_tests \
Expand Down Expand Up @@ -186,6 +187,7 @@ TARGETS_IUTEST_ONLY = \

COMPILEERROR_TARGETS=\
$(OUTDIR)/check_strict_tests \
$(OUTDIR)/empty_testname_failure_tests \
$(OUTDIR)/static_assertion_failure_tests \

BUILD_ONLY = $(OUTDIR)/break_on_failure_tests \
Expand Down
9 changes: 8 additions & 1 deletion test/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ ifeq ($(IUTEST_USE_PYTHON),1)
ifeq ($(USE_GTEST)$(USE_GMOCK)$(USE_COVERAGE)$(USE_SCANBUILD),)
ERR_TARGETS = $(COMPILEERROR_TARGETS)
endif
else
ifdef IUTEST_REQUIRE_PYTHON
$(warning detected python ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.${PYTHON_VERSION_PATCH})
$(error iutest test require python 2.7 or later)
endif
endif

BUILD_TARGETS = $(RUN_TARGETS) $(BUILD_ONLY)
Expand Down Expand Up @@ -407,8 +412,10 @@ ifeq ($(CI),true)
IUTEST_COMPILE_ERROR_TEST_OPTION+= --verbose
endif

CXX_ERROR_TEST_FLAGS:=-ferror-limit=100

$(ERR_TARGETS) : $(OUTDIR)/% : %.cpp $(IUTEST_HEADERS) $(MAKEFILE)
$(CXX) $(IUTEST_INCLUDE) $(CXXFLAGS) -o $@ $< $(LDFLAGS) 2>&1 | python $(PY_COMPILEERROR_TEST_TOOL) $(IUTEST_COMPILE_ERROR_TEST_OPTION)
$(CXX) $(IUTEST_INCLUDE) $(CXXFLAGS) $(CXX_ERROR_TEST_FLAGS) -o $@ $< $(LDFLAGS) 2>&1 | python $(PY_COMPILEERROR_TEST_TOOL) $(IUTEST_COMPILE_ERROR_TEST_OPTION)

else

Expand Down
4 changes: 3 additions & 1 deletion test/check_strict_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* @author t.shirayanagi
* @par copyright
* Copyright (C) 2015-2016, Takazumi Shirayanagi\n
* Copyright (C) 2015-2020, Takazumi Shirayanagi\n
* This software is released under the new BSD License,
* see LICENSE
*/
Expand All @@ -29,10 +29,12 @@ class TestFixture : public ::iutest::Test
virtual void SetUp() {}
};

#if IUTEST_HAS_IF_EXISTS || !defined(IUTEST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(IUTEST_NO_FUNCTION_TEMPLATE_ORDERING)
IUTEST_TEST_STATICASSERT("TestFixture is fixture class, mistake the IUTEST_F?")
IUTEST(TestFixture, Test)
{
}
#endif

#ifdef UNICODE
int wmain(int argc, wchar_t* argv[])
Expand Down

0 comments on commit b6bb669

Please sign in to comment.