• R/O
  • SSH
  • HTTPS

iutest: Commit


Commit MetaInfo

Revision1432 (tree)
Time2021-04-02 11:20:51
Authorsrz_zumix

Log Message

output xml (#569)

* output xml

* fix

* Bitrise/update android stack (#570)

* update bitrise.yml

* fix

* clean

* clean

* override CXXFLAGS

* all test result
git@30ee53e39d7bea7bf8a7fdd03fe7f15940265560
https://github.com/srz-zumix/iutest/commit/30ee53e39d7bea7bf8a7fdd03fe7f15940265560


Merge pull request #568 from srz-zumix/feature/nowran_flag

/IUTEST_CXX_WARN_FLAGS/IUTEST_CXX_NOWARN_FLAGS/
git@9ed8f4a9847a0bcb01772f0a92818e9aaff39e0c


/IUTEST_CXX_WARN_FLAGS/IUTEST_CXX_NOWARN_FLAGS/

git@f7b436d0eda89340379c638a6a5f128fcb3c17f5


AppVeyor: push junit test result (#558)

* push junit test result #239

* ls

* cmd

* %

* up

* up

* up

* test

* test

* test

* test

* up

* fix on_finish override

* fix typo

* fix namke

* xunit

* Update appveyor.yml

* Update appveyor.yml

* Update appveyor.yml

* Update appveyor.yml

* Update appveyor.yml

* Update appveyor.yml

* Update appveyor.yml

* Update appveyor.yml

* test

* /skip/skipped/

* fix bug

* up

* up

* test-clean-all

* Update appveyor.yml

* debug

* test

* add test

* fix

* test io

* fix test

* fix test
git@f0a706fdd90748af3256b89e5515b45c77156e66


Feature/cppcheck update (#567)

* update cppcheck

* up

* up

* up

* update cppcheck config

* up

* add ghpages pull_request trigger

* up

* up

* up ctu
git@2677b7e5b1404ba0313247edc449cf835056eabe


add cppcheck

git@e1d08b13efd201617745555c9d39db0c1584e6eb


string_view convertible printto (#562)

* string_view convertible printto

* up

* test

* fix

* fix

* fix

* fix

* fix

* fix

* fix test

* fix

* fix
git@eb4992f51b6c2b0175c10b390ebf11e0b2bc1495

Change Summary

Incremental Difference

--- trunk/appveyor.yml (revision 1431)
+++ trunk/appveyor.yml (revision 1432)
@@ -24,19 +24,23 @@
2424 job_depends_on: VisualStudio
2525 BUILD_CYGWIN: yes
2626 USE_GNU_EXTENSION: 0
27+ OUTPUTXML_TYPE: junit
2728 - job_group: Cygwin
2829 job_depends_on: VisualStudio
2930 BUILD_CYGWIN: yes
3031 USE_GNU_EXTENSION: 1
32+ OUTPUTXML_TYPE: xml
3133 # MINGW/MINGW64
3234 - job_group: MINGW
3335 job_depends_on: VisualStudio
3436 BUILD_MINGW: yes
3537 USE_GNU_EXTENSION: 0
38+ OUTPUTXML_TYPE: xml
3639 # MINGW/MINGW64 GNU EXTENSION
3740 - job_group: MINGW
3841 job_depends_on: VisualStudio
3942 BUILD_MINGW: yes
43+ OUTPUTXML_TYPE: junit
4044 USE_GNU_EXTENSION: 1
4145 # NMAKE
4246 - job_group: VisualStudio
@@ -43,6 +47,7 @@
4347 job_depends_on: VS2017
4448 BUILD_NMAKE: yes
4549 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
50+ OUTPUTXML_TYPE: xml
4651 # Prefast
4752 - job_group: VisualStudio
4853 job_depends_on: VS2015
@@ -165,7 +170,7 @@
165170 verbosity: minimal
166171
167172 test_script:
168- cmd: cd build && ctest -C %Configuration% -V
173+ cmd: cd build && ctest -C %Configuration% -V -T Test
169174
170175 on_failure:
171176 # wait RDP connect
@@ -175,6 +180,20 @@
175180 $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
176181 }
177182
183+on_finish:
184+ ps: |
185+ $XSLInputElement = New-Object System.Xml.Xsl.XslCompiledTransform
186+ $XSLInputElement.Load("https://raw.githubusercontent.com/rpavlik/jenkins-ctest-plugin/master/ctest-to-junit.xsl")
187+ $TestXmlFile = Get-Childitem –Path "$($env:APPVEYOR_BUILD_FOLDER)\build" -Include *Test.xml -File -Recurse -ErrorAction SilentlyContinue
188+ Write-Host $TestXmlFile
189+ $XSLInputElement.Transform($TestXmlFile, (Join-Path (Resolve-Path .) "ctest-to-junit-results.xml"))
190+ $wc = New-Object 'System.Net.WebClient'
191+ $wc.UploadFile("https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\ctest-to-junit-results.xml))
192+
193+# artifacts:
194+# - path: "**/*.xml"
195+
196+
178197 for:
179198 # Build .sln (no cmake)
180199 -
@@ -191,6 +210,8 @@
191210 cd projects\%PROJECT_DIR%\%Configuration%
192211 iutest_sample.exe
193212 iutest_sample.exe --spec
213+ on_finish: &noop
214+ cmd: echo.
194215 # Cygwin
195216 -
196217 matrix:
@@ -209,15 +230,26 @@
209230 install:
210231 cmd: |
211232 %CYGWIN_PATH%\%CYGWIN_SETUP_EXE% -qnNdO -R %CYGWIN_PATH% -s http://cygwin.mirror.constant.com -l %CYGWIN_PATH%/var/cache/setup -P make -P clang
212- before_build: &noop
213- cmd: echo.
233+ before_build: *noop
214234 build_script:
215235 cmd: |
216236 cd test
217237 make showcxxmacros
218- make -j4
238+ make -j4 OUTPUTXML=%OUTPUTXML_TYPE%
219239 test_script:
220- cmd: make test && make report
240+ cmd: make test OUTPUTXML=%OUTPUTXML_TYPE% && make report
241+ on_finish: &test_result
242+ ps: |
243+ $wc = New-Object 'System.Net.WebClient'
244+ Get-ChildItem "$($env:APPVEYOR_BUILD_FOLDER)\test" -Filter *.xml |
245+ Foreach-Object {
246+ $XmlFilePath = $_.FullName
247+ Write-Host $XmlFilePath
248+ $wc.UploadFile("https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)", $XmlFilePath)
249+ }
250+# cmd: |
251+# cd %APPVEYOR_BUILD_FOLDER%/test
252+# find . -type f -name '*.xml' -print0 | xargs -0 -I '{}' curl -F 'file=@{}' "https://ci.appveyor.com/api/testresults/junit/%APPVEYOR_JOB_ID%"
221253 # MINGW
222254 -
223255 matrix:
@@ -237,9 +269,10 @@
237269 cmd: |
238270 cd test
239271 mingw32-make showcxxmacros
240- mingw32-make -j4 %MAKE_OPTIONS%
272+ mingw32-make -j4 %MAKE_OPTIONS% OUTPUTXML=%OUTPUTXML_TYPE%
241273 test_script:
242- cmd: mingw32-make test %MAKE_OPTIONS% && mingw32-make report
274+ cmd: mingw32-make test %MAKE_OPTIONS% OUTPUTXML=%OUTPUTXML_TYPE% && mingw32-make report
275+ on_finish: *test_result
243276 # NAMKE
244277 -
245278 matrix:
@@ -246,11 +279,16 @@
246279 only:
247280 - BUILD_NMAKE: yes
248281 before_build:
249- cmd: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\vsdevcmd.bat"'
282+ cmd: |
283+ "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\vsdevcmd.bat"
284+ cd test && nmake showcxxmacros
285+ nmake minimum_tests && minimum_tests.exe --spec
286+ nmake clean
250287 build_script:
251- cmd: cd test && nmake showcxxmacros && nmake minimum_tests && minimum_tests.exe --spec
288+ cmd: nmake OUTPUTXML=%OUTPUTXML_TYPE%
252289 test_script:
253- cmd: nmake test
290+ cmd: nmake test OUTPUTXML=%OUTPUTXML_TYPE%
291+ on_finish: *test_result
254292 # Prefast
255293 -
256294 matrix:
@@ -263,6 +301,7 @@
263301 build_script:
264302 cmd: msbuild "projects\%PROJECT_DIR%\iutest_sample.vcxproj" /m %MSBUILD_LOGGER_OPTION% %MSBUILD_PREFAST_OPTION%
265303 test: off
304+ on_finish: *noop
266305 # Menu
267306 -
268307 matrix:
@@ -274,6 +313,7 @@
274313 parallel: true
275314 verbosity: minimal
276315 test: off
316+ on_finish: *noop
277317 # Package Build
278318 -
279319 matrix:
@@ -283,6 +323,7 @@
283323 build_script:
284324 sh: bash ./.ci/make-package.sh
285325 test: off
326+ on_finish: *noop
286327 # NuGet
287328 -
288329 matrix:
@@ -295,3 +336,4 @@
295336 Write-Output "Building NuGet package"
296337 nuget pack $nuspecPath -OutputDirectory ".\"
297338 test: off
339+ on_finish: *noop
--- trunk/bitrise.yml (revision 1431)
+++ trunk/bitrise.yml (revision 1432)
@@ -134,7 +134,7 @@
134134 - content: |-
135135 #!/bin/bash
136136 set -ex
137- curl https://bootstrap.pypa.io/3.5/get-pip.py -o get-pip.py
137+ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
138138 sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 90
139139 python --version
140140 sudo python get-pip.py --force-reinstall
@@ -164,16 +164,21 @@
164164 $APT_CACHE_DIR
165165 meta:
166166 bitrise.io:
167- stack: linux-docker-android
167+ stack: linux-docker-android-20.04
168168 primary:
169169 steps:
170- - trigger-bitrise-workflow:
170+ - activate-ssh-key:
171+ run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
172+ - git-clone: {}
173+ - script:
174+ title: continue from repo
171175 inputs:
172- - workflow_id: Android
173- - api_token: "$IUTEST_RPIMARY_TRIGGER_KEY"
174- title: Trigger Android workflow
175- after_run:
176- - iOS
176+ - content: |-
177+ #!/bin/bash
178+ set -ex
179+ git remote rm fork || true
180+ bitrise run iOS
181+ bitrise run Android
177182 test:
178183 after_run:
179184 - iOS
--- trunk/include/internal/iutest_stdlib.hpp (revision 1431)
+++ trunk/include/internal/iutest_stdlib.hpp (revision 1432)
@@ -225,7 +225,7 @@
225225 optional(const optional& rhs) : m_init(rhs.m_init), m_value(rhs.value) {}
226226
227227 public:
228- optional& operator = (const T& rhs) { m_init = true; m_value = rhs; }
228+ optional& operator = (const T& rhs) { m_init = true; m_value = rhs; return *this; }
229229 operator bool () const { return has_value(); }
230230 const T& operator * () const { return value(); }
231231 T& operator * () { return value(); }
--- trunk/include/internal/iutest_string_stream.hpp (revision 1431)
+++ trunk/include/internal/iutest_string_stream.hpp (revision 1432)
@@ -6,7 +6,7 @@
66 *
77 * @author t.shirayanagi
88 * @par copyright
9- * Copyright (C) 2011-2020, Takazumi Shirayanagi\n
9+ * Copyright (C) 2011-2021, Takazumi Shirayanagi\n
1010 * This software is released under the new BSD License,
1111 * see LICENSE
1212 */
@@ -86,7 +86,7 @@
8686 char* endptr=NULL;
8787 const char* p = s.c_str();
8888 errno = 0;
89- const floating_point<double> v = strtod(s.c_str(), &endptr);
89+ const floating_point<double> v = strtod(p, &endptr);
9090 #if IUTEST_HAS_EXCEPTIONS
9191 if(p == endptr)
9292 {
@@ -112,7 +112,7 @@
112112 char* endptr=NULL;
113113 const char* p = s.c_str();
114114 errno = 0;
115- const floating_point<long double> v = strtold(s.c_str(), &endptr);
115+ const floating_point<long double> v = strtold(p, &endptr);
116116 #if IUTEST_HAS_EXCEPTIONS
117117 if(p == endptr)
118118 {
--- trunk/include/internal/iutest_type_traits.hpp (revision 1431)
+++ trunk/include/internal/iutest_type_traits.hpp (revision 1432)
@@ -148,6 +148,7 @@
148148
149149 using ::std::true_type;
150150 using ::std::false_type;
151+using ::std::conditional;
151152 using ::std::remove_const;
152153 using ::std::remove_volatile;
153154 using ::std::remove_reference;
@@ -211,6 +212,20 @@
211212 typedef bool_constant<true> true_type;
212213 typedef bool_constant<false> false_type;
213214
215+/**
216+ * @brief conditional
217+*/
218+template<bool B, typename T, typename U>
219+class conditional
220+{
221+ template<bool X, typename TMP>
222+ struct impl { typedef T type; };
223+ template<typename TMP>
224+ struct impl<false, TMP> { typedef U type; };
225+public:
226+ typedef typename impl<B, void>::type type;
227+};
228+
214229 #if !defined(IUTEST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
215230
216231 /**
--- trunk/include/iutest.hpp (revision 1431)
+++ trunk/include/iutest.hpp (revision 1432)
@@ -1859,7 +1859,6 @@
18591859 void Initialize()
18601860 {
18611861 UnitTest::instance().Initialize();
1862- SetUpDefaultListener();
18631862 }
18641863
18651864 /**
@@ -1871,7 +1870,7 @@
18711870 return UnitTest::instance().Run();
18721871 }
18731872
1874-private:
1873+public:
18751874 void SetUpDefaultXmlListener()
18761875 {
18771876 if( TestEnv::is_output_option_dirty() )
@@ -1879,6 +1878,7 @@
18791878 if( TestEnv::has_output_option() )
18801879 {
18811880 TestEnv::flush_output_option();
1881+
18821882 do
18831883 {
18841884 #if defined(__WANDBOX__)
@@ -1910,6 +1910,7 @@
19101910 }
19111911 }
19121912
1913+private:
19131914 void SetUpDefaultListener()
19141915 {
19151916 SetUpDefaultXmlListener();
@@ -1930,6 +1931,7 @@
19301931 UnitTestSource::GetInstance().Initialize();
19311932 TestEnv::ParseCommandLine(pargc, argv);
19321933 TestEnv::LoadFlagFile();
1934+ UnitTestSource::GetInstance().SetUpDefaultXmlListener();
19331935 }
19341936
19351937 } // end of namespace detail
@@ -1956,6 +1958,7 @@
19561958 UnitTestSource::GetInstance().Initialize();
19571959 TestEnv::ParseCommandLine(argv);
19581960 TestEnv::LoadFlagFile();
1961+ UnitTestSource::GetInstance().SetUpDefaultXmlListener();
19591962 }
19601963
19611964 /**
--- trunk/include/iutest_env.hpp (revision 1431)
+++ trunk/include/iutest_env.hpp (revision 1432)
@@ -206,7 +206,7 @@
206206 * @param [in] flag = 検査対象フラグ
207207 * @return 真偽値
208208 */
209- static bool IsEnableFlag(int flag) { return GetInstance().m_test_flags & flag ? true : false; }
209+ static bool IsEnableFlag(int flag) { return (GetInstance().m_test_flags & flag) ? true : false; }
210210
211211 private:
212212 template<int KIND>
--- trunk/include/iutest_listener.hpp (revision 1431)
+++ trunk/include/iutest_listener.hpp (revision 1432)
@@ -180,7 +180,18 @@
180180 /**
181181 * @brief リスナーの解放
182182 */
183- TestEventListener* Release(TestEventListener* listener) { return m_repeater.Release(listener); }
183+ TestEventListener* Release(TestEventListener* listener)
184+ {
185+ if( listener == m_default_result_printer )
186+ {
187+ m_default_result_printer = NULL;
188+ }
189+ if( listener == m_default_xml_generator )
190+ {
191+ m_default_xml_generator = NULL;
192+ }
193+ return m_repeater.Release(listener);
194+ }
184195
185196 public:
186197 /**
--- trunk/include/iutest_printers.hpp (revision 1431)
+++ trunk/include/iutest_printers.hpp (revision 1432)
@@ -26,6 +26,15 @@
2626 namespace iutest
2727 {
2828
29+// PrintTo (User defined)
30+// PrintTo (iutest)
31+// DefaultPrintTo
32+// container
33+// pointer
34+// ostream operator <<
35+// BiggestInt
36+// bytes
37+
2938 //======================================================================
3039 // declare
3140 template<typename T>
@@ -34,6 +43,9 @@
3443 namespace detail
3544 {
3645
46+template<typename T>
47+void UniversalPrint(const T& value, iu_ostream* os);
48+
3749 inline void PrintBytesInObjectTo(const unsigned char* buf, size_t size, iu_ostream* os)
3850 {
3951 IUTEST_PRAGMA_CONSTEXPR_CALLED_AT_RUNTIME_WARN_DISABLE_BEGIN()
@@ -66,9 +78,7 @@
6678 namespace formatter
6779 {
6880
69-/** @private */
70-template<bool convertible>
71-struct Printer
81+struct RawBytesPrinter
7282 {
7383 template<typename T>
7484 static void Print(const T& value, iu_ostream* os)
@@ -80,21 +90,40 @@
8090 }
8191 };
8292
83-template<>
84-struct Printer<true>
93+struct StringViewPrinter
8594 {
86- template<typename T>
87- static void Print(const T& value, iu_ostream* os)
95+ static void Print(iu_string_view value, iu_ostream* os)
8896 {
97+ UniversalPrint(value, os);
98+ }
99+};
100+
101+struct BiggestIntPrinter
102+{
103+ static void Print(BiggestInt value, iu_ostream* os)
104+ {
89105 #if IUTEST_HAS_BIGGESTINT_OSTREAM
90- const BiggestInt v = value;
106+ *os << value;
91107 #else
92108 const Int32 v = value;
109+ *os << v;
93110 #endif
94- *os << v;
95111 }
96112 };
97113
114+/** @private */
115+template<typename T>
116+struct PrinterTypeSelecter
117+{
118+ typedef typename iutest_type_traits::conditional<iutest_type_traits::is_convertible<T, BiggestInt>::value
119+ , BiggestIntPrinter
120+ , typename iutest_type_traits::conditional<iutest_type_traits::is_convertible<T, iu_string_view>::value
121+ , StringViewPrinter
122+ , RawBytesPrinter
123+ >::type
124+ >::type type;
125+};
126+
98127 } // end of namespace formatter
99128
100129 /** @private */
@@ -104,8 +133,8 @@
104133 template<typename T>
105134 static void PrintValue(const T& value, iu_ostream* os)
106135 {
107- formatter::Printer<
108- iutest_type_traits::is_convertible<const T&, BiggestInt>::value>::Print(value, os);
136+ typedef typename formatter::PrinterTypeSelecter<const T&>::type Printer;
137+ Printer::Print(value, os);
109138 }
110139 };
111140
@@ -149,8 +178,6 @@
149178
150179 //======================================================================
151180 // declare
152-template<typename T>
153-void UniversalPrint(const T& value, iu_ostream* os);
154181
155182 //======================================================================
156183 // function
@@ -192,7 +219,7 @@
192219 #if !defined(IUTEST_NO_ARGUMENT_DEPENDENT_LOOKUP)
193220 printer_internal2::DefaultPrintNonContainerTo(value, os);
194221 #else
195- printer_internal::formatter::Printer<false>::Print(value, os);
222+ printer_internal::formatter::RawBytesPrinter::Print(value, os);
196223 #endif
197224 }
198225 /** @overload */
@@ -386,8 +413,15 @@
386413 {
387414 *os << static_cast<unsigned int>(value);
388415 }
389-#if IUTEST_HAS_CXX_HDR_STRING_VIEW
416+#if IUTEST_USE_OWN_STRING_VIEW
390417 template<typename CharT, typename Traits>
418+inline void PrintTo(const iu_basic_string_view<CharT, Traits>& value, iu_ostream* os)
419+{
420+ const ::std::basic_string<CharT, Traits> str = value.data();
421+ UniversalTersePrint(str.c_str(), os);
422+}
423+#else
424+template<typename CharT, typename Traits>
391425 inline void PrintTo(const ::std::basic_string_view<CharT, Traits>& value, iu_ostream* os)
392426 {
393427 const ::std::basic_string<CharT, Traits> str{ value };
--- trunk/include/iutest_util.hpp (revision 1431)
+++ trunk/include/iutest_util.hpp (revision 1432)
@@ -41,7 +41,7 @@
4141 inline void ReleaseDefaultXmlGenerator()
4242 {
4343 ::iutest::TestEventListeners& listeners = ::iutest::UnitTest::GetInstance()->listeners();
44- listeners.Release(listeners.default_xml_generator());
44+ delete listeners.Release(listeners.default_xml_generator());
4545 }
4646
4747 } // end of namespace iuutil
--- trunk/include/iutest_ver.hpp (revision 1431)
+++ trunk/include/iutest_ver.hpp (revision 1432)
@@ -17,11 +17,11 @@
1717
1818 //======================================================================
1919 // define
20-#define IUTEST_VER 0x01179905u //!< iutest version 1.17.99.5
20+#define IUTEST_VER 0x01179906u //!< iutest version 1.17.99.6
2121 #define IUTEST_MAJORVER 0x01u //!< Major Version
2222 #define IUTEST_MINORVER 0x17u //!< Minor Version
2323 #define IUTEST_MICROVER 0x99u //!< Micro Version
24-#define IUTEST_REVISION 0x05u //!< Revision
24+#define IUTEST_REVISION 0x06u //!< Revision
2525
2626 #define IUTEST_BUILD IUTEST_MICROVER //!< @deprecated
2727
--- trunk/projects/cmake/CMakeLists.txt (revision 1431)
+++ trunk/projects/cmake/CMakeLists.txt (revision 1432)
@@ -251,6 +251,7 @@
251251 cxx_executable_test(throw_on_failure_tests)
252252 cxx_executable_test(tr1_tests)
253253 cxx_executable_test(uninitialize_tests)
254+ cxx_executable_test(util_release_default_xml_generator_tests)
254255 cxx_executable_test(util_tests)
255256 if (build_namespace_tests)
256257 cxx_executable_test_ns(namespace_tests
@@ -386,6 +387,7 @@
386387 cxx_add_test(throw_on_failure_tests)
387388 cxx_add_test(tr1_tests)
388389 cxx_add_test(uninitialize_tests)
390+ cxx_add_test(util_release_default_xml_generator_tests)
389391 cxx_add_test(util_tests)
390392 if (build_namespace_tests)
391393 cxx_add_test(namespace_tests)
--- trunk/projects/cmake/Makefile (revision 1431)
+++ trunk/projects/cmake/Makefile (revision 1432)
@@ -45,3 +45,11 @@
4545 mkdir -p tmp/mac && cd tmp/mac \
4646 && cmake ../../../../projects/cmake -G "Xcode" -DCMAKE_XCODE_GENERATE_SCHEME=TRUE -Dbuild_use_gtest_configuration=OFF \
4747 && xcodebuild -project iutest.xcodeproj -list
48+
49+#
50+#
51+default: ## cmake default
52+ mkdir -p tmp/default && cd tmp/default \
53+ && cmake ../../../../projects/cmake -Dbuild_use_gtest_configuration=OFF \
54+ && cmake --build . \
55+ && ctest -T Test .
--- trunk/test/CommonMakefile.in (revision 1431)
+++ trunk/test/CommonMakefile.in (revision 1432)
@@ -153,6 +153,7 @@
153153 $(OUTDIR)/throw_on_failure_tests \
154154 $(OUTDIR)/tr1_tests \
155155 $(OUTDIR)/uninitialize_tests \
156+ $(OUTDIR)/util_release_default_xml_generator_tests \
156157 $(OUTDIR)/util_tests \
157158
158159 ASSERTION_ONLY_TARGETS= \
--- trunk/test/Makefile (revision 1431)
+++ trunk/test/Makefile (revision 1432)
@@ -84,7 +84,11 @@
8484 $(RUNNER) : $(@:_tests_run=_tests)
8585 @echo $@
8686 !ifdef OUTPUTXML
87+!if "$(OUTPUTXML)" == "junit"
88+ $?.exe $(RUN_OPTION) --iutest_output=junit:$?.xml
89+!else
8790 $?.exe $(RUN_OPTION) --iutest_output=xml:$?.xml
91+!endif
8892 !else
8993 $?.exe $(RUN_OPTION)
9094 !endif
--- trunk/test/cppcheck/.gitignore (nonexistent)
+++ trunk/test/cppcheck/.gitignore (revision 1432)
@@ -0,0 +1,2 @@
1+*.xml
2+.DS_Store
--- trunk/test/cppcheck/Makefile (revision 1431)
+++ trunk/test/cppcheck/Makefile (revision 1432)
@@ -1,4 +1,4 @@
1-# Copyright (C) 2018, Takazumi Shirayanagi
1+# Copyright (C) 2018-2021, Takazumi Shirayanagi
22 # This software is released under the new BSD License,
33 # see LICENSE
44
@@ -19,23 +19,8 @@
1919 # cppcheck configuration
2020 #
2121
22-CPPCHECK_DEFINES= \
23- IUTEST_HAS_CLOCK=1 \
22+include Config.mk
2423
25-CPPCHECK_UNDEFINES= \
26- _WIN32 \
27- _MSC_VER \
28- __clang__ \
29- __CYGWIN__ \
30- __APPLE__ \
31-
32-CPPCHECK_SUPPRESS= \
33- syntaxError \
34- missingIncludeSystem \
35- ConfigurationNotChecked \
36- knownConditionTrueFalse:*/iutest_internal_defs.hpp \
37- unmatchedSuppression
38-
3924 CPPCHECK_DEFINES_OPTIONS=$(patsubst %,-D%,$(CPPCHECK_DEFINES))
4025 CPPCHECK_UNDEFINES_OPTIONS=$(patsubst %,-U%,$(CPPCHECK_UNDEFINES))
4126 CPPCHECK_SUPPRESS_OPTIONS=$(patsubst %,--suppress=%,$(CPPCHECK_SUPPRESS))
@@ -42,13 +27,26 @@
4227
4328 CPPCHECK_ENABLE_OPTION= --enable=all
4429
45-DEFAULT_OPTIONS=--inline-suppr -f -j4 --platform=unix64
30+DEFAULT_OPTIONS=--inline-suppr -j8 --platform=unix64
4631
32+ifdef FULL
33+DEFAULT_OPTIONS+= -f
34+endif
35+ifdef CTU_DEPTH
36+DEFAULT_OPTIONS+= --max-ctu-depth=$(CTU_DEPTH)
37+endif
38+ifdef USE_CLANG
39+DEFAULT_OPTIONS+= --clang
40+endif
41+
4742 OPTIONS+= $(DEFAULT_OPTIONS)
4843 OPTIONS+= $(CPPCHECK_ENABLE_OPTION)
4944 OPTIONS+= $(CPPCHECK_DEFINES_OPTIONS)
5045 OPTIONS+= $(CPPCHECK_UNDEFINES_OPTIONS)
5146 OPTIONS+= $(CPPCHECK_SUPPRESS_OPTIONS)
47+ifdef CPPCHECK_ADD_OPTIONS
48+OPTIONS+= $(CPPCHECK_ADD_OPTIONS)
49+endif
5250
5351 SRC_CPP=$(wildcard ../../src/*.cpp)
5452 SAMPLES=$(wildcard ../../samples/*.cpp)
@@ -72,7 +70,7 @@
7270 all: clean default
7371
7472 clean:
75- $(RM) $(TARGETS) check-config.xml
73+ $(RM) $(TARGETS) check-config.xml ./html
7674
7775 version:
7876 cppcheck --version
@@ -80,5 +78,11 @@
8078 check-config:
8179 cppcheck $(IUTEST_INCLUDE) $(OPTIONS) $(SRCS) --check-config --xml 2> $@.xml
8280
83-$(TARGETS): $(SRC_CPP) Makefile
81+$(TARGETS): $(SRC_CPP) $(IUTEST_HEADERS) Config.mk
8482 cppcheck $(IUTEST_INCLUDE) $(OPTIONS) $(SRCS) --xml 2> $@
83+
84+HTML_REPORT_DIR:=./html
85+html: $(TARGETS)
86+ @if [ ! -e ${HTML_REPORT_DIR} ]; then mkdir -p ${HTML_REPORT_DIR}; fi
87+ cppcheck-htmlreport --file=$< --title=iutest --report-dir=${HTML_REPORT_DIR}
88+ # cppcheck-htmlreport --file=$< --title=iutest --report-dir=./html --source-dir=$(IUTEST_DIR)/include
--- trunk/test/default_printer_listener_tests.cpp (revision 1431)
+++ trunk/test/default_printer_listener_tests.cpp (revision 1432)
@@ -2,7 +2,7 @@
22 //-----------------------------------------------------------------------
33 /**
44 * @file default_printer_listener_tests.cpp
5- * @brief QuietResultPrinter test
5+ * @brief default printer test
66 *
77 * @author t.shirayanagi
88 * @par copyright
--- trunk/test/exit_tests.cpp (revision 1431)
+++ trunk/test/exit_tests.cpp (revision 1432)
@@ -53,6 +53,11 @@
5353 listeners.Append(new ExitCheckEventListener());
5454
5555 IUTEST_INIT(&argc, argv);
56+
57+#if defined(OUTPUTXML)
58+ // 失敗テストを含むので xml 出力しない
59+ ::iuutil::ReleaseDefaultXmlGenerator();
60+#endif
5661 IUTEST_RUN_ALL_TESTS();
5762 return 1;
5863 #else
--- trunk/test/ostream_formatter_tests.cpp (revision 1431)
+++ trunk/test/ostream_formatter_tests.cpp (revision 1432)
@@ -2,7 +2,7 @@
22 //-----------------------------------------------------------------------
33 /**
44 * @file ostream_formatter_tests.cpp
5- * @brief QuietResultPrinter test
5+ * @brief ostream formatter test
66 *
77 * @author t.shirayanagi
88 * @par copyright
--- trunk/test/quiet_result_printer_tests.cpp (revision 1431)
+++ trunk/test/quiet_result_printer_tests.cpp (revision 1432)
@@ -44,11 +44,14 @@
4444 ::iutest::detail::iuConsole::SetLogger(&logger);
4545 #endif
4646
47+ ::iutest::TestEventListeners& listeners = ::iutest::UnitTest::GetInstance()->listeners();
4748 ::iutest::TestEventListener* listener = ::iuutil::QuietResultPrinter::SetUp();
4849 #if IUTEST_HAS_ASSERTION_RETURN
4950 IUTEST_ASSERT_NOTNULL( listener ) << ::iutest::AssertionReturn<int>(1);
51+ IUTEST_ASSERT_NULL( listeners.default_result_printer() ) << ::iutest::AssertionReturn<int>(1);
5052 #else
51- if( listener == NULL ) return 1;
53+ IUTEST_ASSERT_EXIT(listener != NULL);
54+ IUTEST_ASSERT_EXIT(listeners.default_result_printer() == NULL);
5255 #endif
5356
5457 if( IUTEST_RUN_ALL_TESTS() == 0 ) return 1;
@@ -57,11 +60,8 @@
5760 IUTEST_ASSERT_STRIN ("[ FAILED ]", logger.c_str()) << ::iutest::AssertionReturn<int>(1);
5861 #endif
5962
60- {
61- ::iutest::TestEventListeners& listeners = ::iutest::UnitTest::GetInstance()->listeners();
62- delete listeners.Release(listener);
63- }
6463
64+ delete listeners.Release(listener);
6565 listener = ::iuutil::QuietResultPrinter::SetUp();
6666 #if IUTEST_HAS_ASSERTION_RETURN
6767 IUTEST_ASSERT_NULL( listener ) << ::iutest::AssertionReturn<int>(1);
--- trunk/test/unit_string_view_tests.cpp (revision 1431)
+++ trunk/test/unit_string_view_tests.cpp (revision 1432)
@@ -6,7 +6,7 @@
66 *
77 * @author t.shirayanagi
88 * @par copyright
9- * Copyright (C) 2019, Takazumi Shirayanagi\n
9+ * Copyright (C) 2019-2021, Takazumi Shirayanagi\n
1010 * The new BSD License is applied to this software.
1111 * see LICENSE
1212 */
@@ -16,7 +16,48 @@
1616 //======================================================================
1717 // include
1818 #include "iutest.hpp"
19+#include "logger_tests.hpp"
1920
21+#if !defined(IUTEST_USE_GTEST)
22+
23+#define IUTEST_PRINTTOSTRING_EQ(expect, val) \
24+ IUTEST_EXPECT_STREQ(static_cast<const char*>(expect), ::iutest::PrintToString(val))
25+
26+#if !defined(IUTEST_NO_ARGUMENT_DEPENDENT_LOOKUP)
27+
28+#define IUTEST_PRINTTOSTRING_CHECK IUTEST_PRINTTOSTRING_EQ
29+
30+#else
31+
32+#define IUTEST_PRINTTOSTRING_CHECK(expect, val) \
33+ IUTEST_EXPECT_STRIN(static_cast<const char*>(expect), ::iutest::PrintToString(val))
34+
35+#endif
36+
37+#else
38+
39+#define IUTEST_PRINTTOSTRING_EQ(expect, val) \
40+ (void)(expect); \
41+ (void)(val)
42+
43+#define IUTEST_PRINTTOSTRING_CHECK(expect, val) \
44+ (void)(expect); \
45+ (void)(val)
46+
47+#endif
48+
49+#if !defined(IUTEST_USE_GTEST) && !defined(IUTEST_NO_ARGUMENT_DEPENDENT_LOOKUP)
50+
51+#define IUTEST_STREAMOUT_CHECK(val) \
52+ IUTEST_SUCCEED() << val
53+
54+#else
55+
56+#define IUTEST_STREAMOUT_CHECK(val) \
57+ IUTEST_SUCCEED() << ::iutest::PrintToString(val)
58+
59+#endif
60+
2061 IUTEST(UnitTest, StringView)
2162 {
2263 ::std::string s = "abc";
@@ -43,3 +84,37 @@
4384
4485 //IUTEST_EXPECT_STRNE("Abc", sv1);
4586 }
87+
88+IUTEST(UnitTest, PrintStringView)
89+{
90+ LogChecker ck("XYZ");
91+ ::iutest::detail::iu_string_view view = "XYZ";
92+ IUTEST_PRINTTOSTRING_EQ(ck, view);
93+ IUTEST_STREAMOUT_CHECK(view);
94+}
95+
96+struct StringViewConvertible
97+{
98+ ::std::string name;
99+ StringViewConvertible()
100+ : name("ABC")
101+ {
102+ }
103+
104+ operator ::iutest::detail::iu_string_view () const
105+ {
106+ return name;
107+ }
108+};
109+
110+IUTEST(UnitTest, PrintStringViewConvertible)
111+{
112+#if !defined(IUTEST_NO_ARGUMENT_DEPENDENT_LOOKUP)
113+ LogChecker ck("ABC");
114+#else
115+ LogChecker ck("-Byte object");
116+#endif
117+ StringViewConvertible v;
118+ IUTEST_PRINTTOSTRING_CHECK(ck, v);
119+ IUTEST_STREAMOUT_CHECK(v);
120+}
--- trunk/test/util_release_default_xml_generator_tests.cpp (nonexistent)
+++ trunk/test/util_release_default_xml_generator_tests.cpp (revision 1432)
@@ -0,0 +1,78 @@
1+//======================================================================
2+//-----------------------------------------------------------------------
3+/**
4+ * @file util_release_default_xml_generator_tests.cpp
5+ * @brief iutest util ReleaseDefaultXmlGenerator
6+ *
7+ * @author t.shirayanagi
8+ * @par copyright
9+ * Copyright (C) 2021, Takazumi Shirayanagi\n
10+ * This software is released under the new BSD License,
11+ * see LICENSE
12+*/
13+//-----------------------------------------------------------------------
14+//======================================================================
15+
16+//======================================================================
17+// include
18+#include "iutest.hpp"
19+
20+#ifdef UNICODE
21+# define DECAL_ARGV(cmd) const wchar_t* targv[] = { argv[0], L cmd }
22+#else
23+# define DECAL_ARGV(cmd) const char* targv[] = { argv[0], cmd }
24+#endif
25+
26+#if !defined(IUTEST_USE_GTEST) && IUTEST_HAS_STRINGSTREAM && IUTEST_HAS_ASSERTION_RETURN
27+
28+class FileIO IUTEST_CXX_FINAL : public ::iutest::StringStreamFile
29+{
30+public:
31+ static ::std::string s_io;
32+
33+ virtual void Close() IUTEST_CXX_OVERRIDE
34+ {
35+ s_io = ss.str();
36+ }
37+};
38+
39+::std::string FileIO::s_io;
40+
41+IUTEST_FILESYSTEM_INSTANTIATE(FileIO);
42+
43+#endif
44+
45+IUTEST(UtilReleaseXmlGeneratorTest, Fail)
46+{
47+ IUTEST_FAIL();
48+}
49+
50+#ifdef UNICODE
51+int wmain(int argc, wchar_t* argv[])
52+#else
53+int main(int argc, char* argv[])
54+#endif
55+{
56+ (void)argc;
57+ (void)argv;
58+ int targc = 2;
59+ DECAL_ARGV("--gtest_output=xml:util_release_default_xml_generator_tests.xml");
60+ IUTEST_INIT(&targc, targv);
61+
62+ ::iutest::TestEventListeners& listeners = ::iutest::UnitTest::GetInstance()->listeners();
63+ IUTEST_ASSERT_EXIT(listeners.default_xml_generator() != NULL);
64+
65+ ::iuutil::ReleaseDefaultXmlGenerator();
66+
67+ IUTEST_ASSERT_EXIT(listeners.default_xml_generator() == NULL);
68+
69+ if( IUTEST_RUN_ALL_TESTS() == 0 ) return 1;
70+
71+#if !defined(IUTEST_USE_GTEST) && IUTEST_HAS_STRINGSTREAM && IUTEST_HAS_ASSERTION_RETURN
72+ IUTEST_ASSERT_STRLNEQ(0, FileIO::s_io) << ::iutest::AssertionReturn<int>(1);
73+#endif
74+
75+ printf("*** Successful ***\n");
76+ return 0;
77+}
78+
Show on old repository browser