Skip to content

Commit

Permalink
Merge d76b299 into 2abc10b
Browse files Browse the repository at this point in the history
  • Loading branch information
srz-zumix committed Feb 7, 2021
2 parents 2abc10b + d76b299 commit 1f0df47
Show file tree
Hide file tree
Showing 48 changed files with 413 additions and 139 deletions.
7 changes: 6 additions & 1 deletion .ci/msvc-wine-build.bat
Expand Up @@ -5,5 +5,10 @@ mkdir build
cd build

cmake %~dp0/../projects/cmake
cmake --build .
echo ==== finish cmake generate ====
ls
echo ==== start cmake build ====
cmake --build .
echo ==== finish cmake build ====
ctest -V --output-on-failure
echo ==== finish ctest ====
10 changes: 8 additions & 2 deletions .circleci/config.yml
Expand Up @@ -176,13 +176,19 @@ jobs:
- docker/pull:
images: 'madduci/docker-wine-msvc:16.7-2019'
- run:
name: test
name: docker setup
command: |
docker run --rm -d -i --name iutest-work -w /home/wine/.wine/drive_c/ madduci/docker-wine-msvc:16.7-2019
docker cp . iutest-work:/home/wine/.wine/drive_c/iutest_
docker exec iutest-work wine64 cmd /C xcopy /Y /I /H /S /Q iutest_ iutest
- run:
name: test
command: |
docker exec iutest-work /home/wine/.wine/drive_c/iutest_/.ci/msvc-wine-entrypoint iutest/.ci/msvc-wine-build.bat
echo == test end ==
no_output_timeout: 15m
- run:
name: docker teardown
command: |
docker stop iutest-work
workflows:
Expand Down
3 changes: 2 additions & 1 deletion .cirrus.yml
Expand Up @@ -56,11 +56,12 @@ cirrus_freebsd_clang_test_task:
only_if: *default-condition
freebsd_instance:
image_family: freebsd-12-1-snap
# image_family: freebsd-13-0-snap
env:
matrix:
- STDFLAG: -std=c++14
- STDFLAG: -std=c++17
#- STDFLAG: -std=c++2a
- STDFLAG: -std=c++2a
install_script: pkg install -y gmake
version_script: gmake --version && gmake -C test showcxxversion
build_script: gmake -C test -j4
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -35,6 +35,7 @@ libs
.vs
.vscode
.tox
.DS_Store
env.*/

# Build results
Expand Down
2 changes: 1 addition & 1 deletion include/impl/iutest_env.ipp
Expand Up @@ -440,7 +440,7 @@ IUTEST_IPP_INLINE bool TestEnv::ParseOutputOption(const char* option)
get_vars().m_output_option = "";
return false;
}
get_vars().m_output_option = option;
set_output_option(option);
return true;
}

Expand Down
25 changes: 25 additions & 0 deletions include/internal/iutest_compiler.hpp
Expand Up @@ -78,6 +78,7 @@
#define IUTEST_CPLUSPLUS_CXX11 201103L
#define IUTEST_CPLUSPLUS_CXX14 201402L
#define IUTEST_CPLUSPLUS_CXX17 201703L
#define IUTEST_CPLUSPLUS_CXX20 202002L

// __cplusplus
#if defined(_MSVC_LANG)
Expand All @@ -90,6 +91,30 @@

// c++2a

#if !defined(IUTEST_HAS_CXX2B)
# if IUTEST_CPLUSPLUS > IUTEST_CPLUSPLUS_CXX20
# define IUTEST_HAS_CXX2B 1
# endif
#endif

#if !defined(IUTEST_HAS_CXX2B)
# define IUTEST_HAS_CXX2B 0
#endif

// c++20

#if !defined(IUTEST_HAS_CXX20)
# if IUTEST_CPLUSPLUS >= IUTEST_CPLUSPLUS_CXX20
# define IUTEST_HAS_CXX20 1
# endif
#endif

#if !defined(IUTEST_HAS_CXX20)
# define IUTEST_HAS_CXX20 0
#endif

// c++2a

#if !defined(IUTEST_HAS_CXX2A)
# if IUTEST_CPLUSPLUS > IUTEST_CPLUSPLUS_CXX17
# define IUTEST_HAS_CXX2A 1
Expand Down
7 changes: 1 addition & 6 deletions include/internal/iutest_filepath.hpp
Expand Up @@ -65,13 +65,8 @@ class iuFilePath
#endif

public:
iuFilePath & operator = (const iuFilePath& rhs) { m_path = rhs.m_path; return *this; }
iuFilePath& operator = (const iuFilePath& rhs) { m_path = rhs.m_path; return *this; }

iuFilePath& operator == (const iuFilePath& rhs)
{
m_path = rhs.m_path;
return *this;
}
bool operator == (const iuFilePath& rhs) const
{
return IsStringCaseEqual(m_path, rhs.m_path);
Expand Down
6 changes: 6 additions & 0 deletions include/internal/iutest_internal_defs.hpp
Expand Up @@ -330,6 +330,12 @@ inline ::std::string GetTypeName()
int status=1;
char* const read_name = __cxa_demangle(name, 0, 0, &status);
::std::string str(status == 0 ? read_name : name);
#if defined(_IUTEST_DEBUG)
if( status != 0 ) {
fprintf(stderr, "Unable to demangle \"%s\" -> \"%s\". (status=%d)\n", name, read_name ? read_name : "", status);
fflush(stderr);
}
#endif
free(read_name);
return str;
#else
Expand Down
2 changes: 2 additions & 0 deletions include/internal/iutest_option_message.hpp
Expand Up @@ -215,6 +215,8 @@ inline void iuOptionMessage::ShowSpec()
IIUT_SHOW_MACRO(IUTEST_HAS_CXX1Z);
IIUT_SHOW_MACRO(IUTEST_HAS_CXX17);
IIUT_SHOW_MACRO(IUTEST_HAS_CXX2A);
IIUT_SHOW_MACRO(IUTEST_HAS_CXX20);
IIUT_SHOW_MACRO(IUTEST_HAS_CXX2B);
IIUT_SHOW_MACRO(IUTEST_HAS_DECLTYPE);
IIUT_SHOW_MACRO(IUTEST_HAS_DEFAULT_FUNCTIONS);
IIUT_SHOW_MACRO(IUTEST_HAS_DELETED_FUNCTIONS);
Expand Down
59 changes: 36 additions & 23 deletions include/iutest.hpp
Expand Up @@ -6,7 +6,7 @@
*
* @author t.shirayanagi
* @par copyright
* Copyright (C) 2011-2020, Takazumi Shirayanagi\n
* Copyright (C) 2011-2021, Takazumi Shirayanagi\n
* This software is released under the new BSD License,
* see LICENSE
*
Expand Down Expand Up @@ -1859,6 +1859,7 @@ class UnitTestSource
void Initialize()
{
UnitTest::instance().Initialize();
SetUpDefaultListener();
}

/**
Expand All @@ -1871,35 +1872,47 @@ class UnitTestSource
}

private:
void SetUpDefaultListener()
void SetUpDefaultXmlListener()
{
if( TestEnv::has_output_option() )
if( TestEnv::is_output_option_dirty() )
{
do
if( TestEnv::has_output_option() )
{
#if defined(__WANDBOX__)
if( StderrXmlGeneratorListener::SetUp() )
TestEnv::flush_output_option();
do
{
break;
}
if( StderrJunitXmlGeneratorListener::SetUp() )
{
break;
}
#if defined(__WANDBOX__)
if( StderrXmlGeneratorListener::SetUp() )
{
break;
}
if( StderrJunitXmlGeneratorListener::SetUp() )
{
break;
}
#else
if( DefaultXmlGeneratorListener::SetUp() )
{
break;
}
if( JunitXmlGeneratorListener::SetUp() )
{
break;
}
#endif
IUTEST_LOG_(WARNING) << "unrecognized output format \"" << TestEnv::get_output_option() << "\" ignored.";
} while( detail::AlwaysFalse() );
if( DefaultXmlGeneratorListener::SetUp() )
{
break;
}
if( JunitXmlGeneratorListener::SetUp() )
{
break;
}
#endif
IUTEST_LOG_(WARNING) << "unrecognized output format \"" << TestEnv::get_output_option() << "\" ignored.";
} while( detail::AlwaysFalse() );
}
else
{
TestEnv::event_listeners().Release(TestEnv::event_listeners().default_xml_generator());
}
}
}

void SetUpDefaultListener()
{
SetUpDefaultXmlListener();
#if IUTEST_HAS_STREAM_RESULT
StreamResultListener::SetUp();
#endif
Expand Down
54 changes: 46 additions & 8 deletions include/iutest_env.hpp
Expand Up @@ -6,7 +6,7 @@
*
* @author t.shirayanagi
* @par copyright
* Copyright (C) 2011-2020, Takazumi Shirayanagi\n
* Copyright (C) 2011-2021, Takazumi Shirayanagi\n
* This software is released under the new BSD License,
* see LICENSE
*/
Expand Down Expand Up @@ -295,6 +295,21 @@ class TestEnv
friend class RepeatCountSet;
#endif

template<typename T>
class StateVariable
{
bool m_dirty;
T m_value;
public:
StateVariable& operator = (const T& rhs) { m_value = rhs; m_dirty = true; return *this; }
operator const T& () const { return m_value; }
const T& operator ()() const { return m_value; }
bool is_dirty() const { return m_dirty; }
void flush() { m_dirty = false; }
T& get() { return m_value; }
const T& get() const { return m_value; }
};

private:
struct Variable
{
Expand All @@ -309,11 +324,11 @@ class TestEnv
unsigned int m_current_random_seed;
unsigned int m_before_origin_random_seed;
int m_repeat_count;
::std::string m_output_option;
StateVariable< ::std::string > m_output_option;
::std::string m_test_filter;
::std::string m_flagfile;
#if IUTEST_HAS_STREAM_RESULT
::std::string m_stream_result_to;
StateVariable< ::std::string > m_stream_result_to;
#endif
::std::string m_default_package_name;
detail::iuRandom m_genrand;
Expand All @@ -328,17 +343,23 @@ class TestEnv

static Variable& get_vars() { static Variable sVars; return sVars; }

private:
static const char* get_output_option_c_str() { return get_vars().m_output_option.get().c_str(); }
#if IUTEST_HAS_STREAM_RESULT
static const char* get_stream_result_to_c_str() { return get_vars().m_stream_result_to.get().c_str(); }
#endif

public:
static detail::iuRandom& genrand() { return get_vars().m_genrand; } //!< 乱数生成器
static unsigned int get_random_seed() { return get_vars().m_random_seed; } //!< 乱数シード
static unsigned int current_random_seed() { return get_vars().m_current_random_seed; } //!< 乱数シード
static int get_repeat_count() { return get_vars().m_repeat_count; } //!< 繰り返し回数
static const char* get_output_option() { return get_vars().m_output_option.c_str(); } //!< 出力オプション
static const StateVariable< ::std::string >& get_output_option() { return get_vars().m_output_option; } //!< 出力オプション
static const char* get_default_package_name() { return get_vars().m_default_package_name.c_str(); } //!< root package オプション
static const char* test_filter() { return get_vars().m_test_filter.c_str(); } //!< フィルター文字列
static const char* get_flagfile() { return get_vars().m_flagfile.c_str(); } //!< flag file
#if IUTEST_HAS_STREAM_RESULT
static const char* get_stream_result_to() { return get_vars().m_stream_result_to.c_str(); }
static const StateVariable< ::std::string >& get_stream_result_to() { return get_vars().m_stream_result_to; }
#endif
#if IUTEST_HAS_STRINGSTREAM || IUTEST_HAS_STRSTREAM
static void global_ostream_copyfmt(iu_ostream& os) { os.copyfmt(get_vars().m_ostream_formatter); } // NOLINT
Expand Down Expand Up @@ -370,7 +391,17 @@ class TestEnv
/** @private */
static bool has_output_option()
{
return !get_vars().m_output_option.empty();
return !get_vars().m_output_option.get().empty();
}
/** @private */
static bool is_output_option_dirty()
{
return get_vars().m_output_option.is_dirty();
}
/** @private */
static void flush_output_option()
{
get_vars().m_output_option.flush();
}

private:
Expand Down Expand Up @@ -544,14 +575,14 @@ class TestEnv
* @private
* @brief 出力オプション設定用オブジェクト
*/
typedef OptionString<get_output_option, set_output_option> output;
typedef OptionString<get_output_option_c_str, set_output_option> output;

#if IUTEST_HAS_STREAM_RESULT
/**
* @private
* @brief stream resultオプション設定用オブジェクト
*/
typedef OptionString<get_stream_result_to, set_stream_result_to> stream_result_to;
typedef OptionString<get_stream_result_to_c_str, set_stream_result_to> stream_result_to;
#endif

/**
Expand Down Expand Up @@ -833,6 +864,13 @@ class iu_global_format_stringstream : public iu_stringstream
}
};

template<typename T>
inline iu_ostream& operator << (iu_ostream& os, const TestEnv::StateVariable<T>& value)
{
return os << value.get();
}


} // end of namespace iutest

#if !IUTEST_HAS_LIB
Expand Down
4 changes: 2 additions & 2 deletions include/iutest_printers.hpp
Expand Up @@ -6,7 +6,7 @@
*
* @author t.shirayanagi
* @par copyright
* Copyright (C) 2011-2020, Takazumi Shirayanagi\n
* Copyright (C) 2011-2021, Takazumi Shirayanagi\n
* This software is released under the new BSD License,
* see LICENSE
*/
Expand Down Expand Up @@ -459,7 +459,7 @@ inline ::std::string FileSystemFileTypeToString(const ::std::filesystem::file_ty
return PrintToString(static_cast<int>(value));
}
template<>
inline void PrintTo<::std::filesystem::path>(const ::std::filesystem::path& value, iu_ostream* os)
inline void PrintTo< ::std::filesystem::path >(const ::std::filesystem::path& value, iu_ostream* os)
{
*os << value.generic_string();
}
Expand Down
17 changes: 15 additions & 2 deletions include/iutest_util.hpp
Expand Up @@ -6,7 +6,7 @@
*
* @author t.shirayanagi
* @par copyright
* Copyright (C) 2012-2020, Takazumi Shirayanagi\n
* Copyright (C) 2012-2021, Takazumi Shirayanagi\n
* This software is released under the new BSD License,
* see LICENSE
*/
Expand All @@ -31,7 +31,20 @@
/**
* @brief iutest utility namespace
*/
namespace iuutil {}
namespace iuutil
{

/**
* @ingroup IUTEST_UTIL
* @brief Xml Generator の解放
*/
inline void ReleaseDefaultXmlGenerator()
{
::iutest::TestEventListeners& listeners = ::iutest::UnitTest::GetInstance()->listeners();
listeners.Release(listeners.default_xml_generator());
}

} // end of namespace iuutil

/**
* @ingroup IUTEST_UTIL
Expand Down

0 comments on commit 1f0df47

Please sign in to comment.