-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Squashed 'externals/coda-oss/' changes from f70b4202f..e2472acfc
e2472acfc build in NITRO and SIX (#703) 32ccf9105 Use same build paths as Visual Studio (#701) 366ac9f43 Another round of removing compiler warnings (#702) a7f8ef260 Fix compile warnings from building CODA (#700) git-subtree-dir: externals/coda-oss git-subtree-split: e2472acfc1b31119a1dfbeaced003bfdffe80118
- Loading branch information
Dan Smith
authored and
Dan Smith
committed
Jul 18, 2023
1 parent
3b07146
commit 069ec60
Showing
56 changed files
with
464 additions
and
387 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,8 +36,7 @@ jobs: | |
cd .. | ||
cd target-Debug | ||
cmake --build . --config Debug -j | ||
- name: test | ||
# should run w/o install | ||
- name: test # should run w/o install | ||
run: | | ||
cd target-Release | ||
ctest -C Release --output-on-failure | ||
|
@@ -52,17 +51,43 @@ jobs: | |
cd target-Debug | ||
cmake --build . --config Debug --target install | ||
cd .. | ||
build-msbuild-windows: | ||
strategy: | ||
matrix: | ||
os: [windows-latest] | ||
platform: [x64] | ||
configuration: [Debug] # Debug turns on more compiler warnings | ||
name: ${{ matrix.os }}-msbuild | ||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: configure | ||
run: | | ||
ls env: | ||
mkdir out | ||
cd out | ||
cmake .. -DCMAKE_INSTALL_PREFIX=install\${{ matrix.platform }}-${{ matrix.configuration }} -DENABLE_PYTHON=OFF | ||
- name: build | ||
run: | | ||
cd out | ||
cmake --build . --config ${{ matrix.configuration }} -j | ||
cmake --build . --config ${{ matrix.configuration }} --target install | ||
- name: Add msbuild to PATH | ||
uses: microsoft/setup-msbuild@v1.1 | ||
uses: microsoft/setup-msbuild@v1 # https://github.com/marketplace/actions/setup-msbuild | ||
with: | ||
msbuild-architecture: x64 | ||
- name: msbuild | ||
run: | | ||
msbuild coda-oss.sln /p:configuration=Release | ||
msbuild coda-oss.sln /p:configuration=Debug | ||
#- name: mstest | ||
# run: | | ||
# mstest /testcontainer:${RUNNER_WORKSPACE}\coda-oss\x64\Debug\UnitTest.dll | ||
msbuild coda-oss.sln /p:configuration=${{ matrix.configuration }} | ||
# Can't figure out how to make this work :-( | ||
#- name: vstest | ||
# uses: microsoft/[email protected] # https://github.com/marketplace/actions/vstest-action | ||
# with: | ||
# testAssembly: UnitTest.dll | ||
# searchFolder: D:\a\nitro\nitro\${{ matrix.platform }}\${{ matrix.configuration }} | ||
# runInParallel: true | ||
|
||
build-linux-cmake: | ||
strategy: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,5 @@ | ||
#include "pch.h" | ||
#include "TestCase.h" | ||
|
||
#include "str/EncodedStringView.h" | ||
|
||
using namespace Microsoft::VisualStudio::CppUnitTestFramework; | ||
|
||
// EQUALS_MESSAGE() wants ToString() specializations (or overloads) for our types, which is a nusiance. | ||
// This hooks up our existing str::toString() into the VC++ unit-test infrastructure | ||
|
||
// C++ hack to call private methods | ||
// https://stackoverflow.com/a/71578383/8877 | ||
|
||
using FailOnCondition_t = void(bool condition, const unsigned short* message, const __LineInfo* pLineInfo); // declare method's type | ||
using GetAssertMessage_t = std::wstring(bool equality, const std::wstring& expected, const std::wstring& actual, const wchar_t *message); // declare method's type | ||
template <FailOnCondition_t fFailOnCondition, GetAssertMessage_t fGetAssertMessage> | ||
struct caller final // helper structure to inject call() code | ||
{ | ||
friend void FailOnCondition(bool condition, const unsigned short* message, const __LineInfo* pLineInfo) | ||
{ | ||
fFailOnCondition(condition, message, pLineInfo); | ||
} | ||
|
||
friend std::wstring GetAssertMessage(bool equality, const std::wstring& expected, const std::wstring& actual, const wchar_t *message) | ||
{ | ||
return fGetAssertMessage(equality, expected, actual, message); | ||
} | ||
}; | ||
template struct caller<&Assert::FailOnCondition, &Assert::GetAssertMessage>; // even instantiation of the helper | ||
|
||
void FailOnCondition(bool condition, const unsigned short* message, const __LineInfo* pLineInfo); // declare caller | ||
void test::Assert::FailOnCondition(bool condition, const unsigned short* message, const __LineInfo* pLineInfo) | ||
{ | ||
::FailOnCondition(condition, message, pLineInfo); // and call! | ||
} | ||
|
||
std::wstring GetAssertMessage(bool equality, const std::wstring& expected, const std::wstring& actual, const wchar_t *message); // declare caller | ||
std::wstring test::Assert::GetAssertMessage(bool equality, const std::string& expected, const std::string& actual, const wchar_t *message) | ||
{ | ||
const str::EncodedStringView vExpected(expected); | ||
const str::EncodedStringView vActual(actual); | ||
return ::GetAssertMessage(equality, vExpected.wstring(), vActual.wstring(), message); // and call! | ||
} | ||
// Can't get this to build in the **coda-oss** project. | ||
#include "sys/source/CppUnitTestAssert_.cpp_" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,138 +1,3 @@ | ||
#pragma once | ||
|
||
#include <stdint.h> | ||
#include <string> | ||
|
||
#include "CppUnitTest.h" | ||
#include <include/TestCase.h> | ||
#include <str/EncodedStringView.h> | ||
|
||
#undef TEST_CHECK | ||
#undef TEST_ASSERT | ||
#undef TEST_ASSERT_NULL | ||
#undef TEST_ASSERT_NOT_NULL | ||
#undef TEST_ASSERT_TRUE | ||
#undef TEST_ASSERT_FALSE | ||
#undef TEST_MAIN | ||
#undef TEST_CASE | ||
#define TEST_CHECK(X) | ||
#define TEST_MAIN(X) | ||
#define TEST_ASSERT_NULL(X) testName, Microsoft::VisualStudio::CppUnitTestFramework::Assert::IsNull(X) | ||
#define TEST_ASSERT_NOT_NULL(X) testName, Microsoft::VisualStudio::CppUnitTestFramework::Assert::IsNotNull(X) | ||
#define TEST_ASSERT_TRUE(X) testName, Microsoft::VisualStudio::CppUnitTestFramework::Assert::IsTrue(X) | ||
#define TEST_ASSERT_FALSE(X) testName, Microsoft::VisualStudio::CppUnitTestFramework::Assert::IsFalse(X) | ||
#define TEST_ASSERT(X) TEST_ASSERT_TRUE(X) | ||
#define CODA_OSS_testMethod_(X) testMethod ## _ ## X | ||
#define TEST_CASE(X) TEST_METHOD(X) { CODA_OSS_testMethod_(X)(#X); } void CODA_OSS_testMethod_(X)(std::string testName) | ||
|
||
namespace test | ||
{ | ||
struct Assert final | ||
{ | ||
static void FailOnCondition(bool condition, const unsigned short* message, const Microsoft::VisualStudio::CppUnitTestFramework::__LineInfo* pLineInfo); | ||
static std::wstring GetAssertMessage(bool equality, const std::string& expected, const std::string& actual, const wchar_t *message); | ||
}; | ||
#define CODA_OSS_equals_message_(expected, actual, message) reinterpret_cast<const unsigned short*>(test::Assert::GetAssertMessage(true, test::toString(expected), test::toString(actual), message).c_str()) | ||
#define CODA_OSS_not_equals_message_(notExpected, actual, message) reinterpret_cast<const unsigned short*>(test::Assert::GetAssertMessage(false, test::toString(notExpected), test::toString(actual), message).c_str()) | ||
#define CODA_OSS_message_(message) reinterpret_cast<const unsigned short*>(test::Assert::GetAssertMessage(false, "", "", message).c_str()) | ||
|
||
// see Assert::AreEqual<> | ||
template<typename TExpected, typename TActual> | ||
inline void diePrintf_eq(const TExpected& expected, const TActual& actual, | ||
const wchar_t* message = NULL, const Microsoft::VisualStudio::CppUnitTestFramework::__LineInfo* pLineInfo = NULL) | ||
{ | ||
Assert::FailOnCondition(expected == actual, CODA_OSS_equals_message_(expected, actual, message), pLineInfo); | ||
} | ||
|
||
// see Assert::AreNotEqual<> | ||
template<typename TExpected, typename TActual> | ||
inline void diePrintf_ne(const TExpected& notExpected, const TActual& actual, | ||
const wchar_t* message = NULL, const Microsoft::VisualStudio::CppUnitTestFramework::__LineInfo* pLineInfo = NULL) | ||
{ | ||
Assert::FailOnCondition(notExpected != actual, CODA_OSS_not_equals_message_(notExpected, actual, message), pLineInfo); | ||
} | ||
|
||
template <typename TX1, typename TX2> | ||
inline void diePrintf_ge(const TX1& X1, const TX2& X2, | ||
const wchar_t* message = NULL, const Microsoft::VisualStudio::CppUnitTestFramework::__LineInfo* pLineInfo = NULL) | ||
{ | ||
Assert::FailOnCondition(X1 >= X2, CODA_OSS_message_(message), pLineInfo); | ||
} | ||
template <typename TX1, typename TX2> | ||
inline void diePrintf_gt(const TX1& X1, const TX2& X2, | ||
const wchar_t* message = NULL, const Microsoft::VisualStudio::CppUnitTestFramework::__LineInfo* pLineInfo = NULL) | ||
{ | ||
Assert::FailOnCondition(X1 > X2, CODA_OSS_message_(message), pLineInfo); | ||
} | ||
template <typename TX1, typename TX2> | ||
inline void diePrintf_le(const TX1& X1, const TX2& X2, | ||
const wchar_t* message = NULL, const Microsoft::VisualStudio::CppUnitTestFramework::__LineInfo* pLineInfo = NULL) | ||
{ | ||
Assert::FailOnCondition(X1 <= X2, CODA_OSS_message_(message), pLineInfo); | ||
} | ||
template <typename TX1, typename TX2> | ||
inline void diePrintf_lt(const TX1& X1, const TX2& X2, | ||
const wchar_t* message = NULL, const Microsoft::VisualStudio::CppUnitTestFramework::__LineInfo* pLineInfo = NULL) | ||
{ | ||
Assert::FailOnCondition(X1 < X2, CODA_OSS_message_(message), pLineInfo); | ||
} | ||
|
||
} | ||
#undef CODA_OSS_test_diePrintf_eq_ | ||
#undef CODA_OSS_test_diePrintf_not_eq_ | ||
#define CODA_OSS_test_diePrintf_eq_(X1, X2) testName, ::test::diePrintf_eq(X1, X2) | ||
#define CODA_OSS_test_diePrintf_not_eq_(X1, X2) testName, ::test::diePrintf_ne(X1, X2) | ||
|
||
#undef CODA_OSS_test_diePrintf_greater_eq_ | ||
#undef CODA_OSS_test_diePrintf_greater_ | ||
#undef CODA_OSS_test_diePrintf_lesser_eq_ | ||
#undef CODA_OSS_test_diePrintf_lesser_ | ||
#define CODA_OSS_test_diePrintf_greater_eq_(X1, X2) testName, ::test::diePrintf_ge(X1, X2) | ||
#define CODA_OSS_test_diePrintf_greater_(X1, X2) testName, ::test::diePrintf_gt(X1, X2) | ||
#define CODA_OSS_test_diePrintf_lesser_eq_(X1, X2) testName, ::test::diePrintf_le(X1, X2) | ||
#define CODA_OSS_test_diePrintf_lesser_(X1, X2) testName, ::test::diePrintf_lt(X1, X2) | ||
|
||
template <typename TX1, typename TX2> | ||
inline void test_assert_greater_(const TX1& X1, const TX2& X2) | ||
{ | ||
Microsoft::VisualStudio::CppUnitTestFramework::Assert::IsTrue(X1 > X2); | ||
} | ||
#undef TEST_ASSERT_GREATER | ||
#define TEST_ASSERT_GREATER(X1, X2) testName, test_assert_greater_(X1, X2) | ||
|
||
#undef TEST_ASSERT_ALMOST_EQ_EPS | ||
#define TEST_ASSERT_ALMOST_EQ_EPS(X1, X2, EPS) { (void)testName; Microsoft::VisualStudio::CppUnitTestFramework::Assert::AreEqual(X1, X2, EPS); Microsoft::VisualStudio::CppUnitTestFramework::Assert::AreEqual(X2, X1, EPS); } | ||
namespace test | ||
{ | ||
inline void assert_almost_eq(const std::string& testName, float X1, float X2) | ||
{ | ||
constexpr auto EPS = static_cast<float>(0.0001); | ||
TEST_ASSERT_ALMOST_EQ_EPS(X1, X2, EPS); | ||
} | ||
inline void assert_almost_eq(const std::string& testName, double X1, double X2) | ||
{ | ||
constexpr auto EPS = static_cast<double>(0.0001); | ||
TEST_ASSERT_ALMOST_EQ_EPS(X1, X2, EPS); | ||
} | ||
inline void assert_almost_eq(const std::string& testName, long double X1, long double X2) | ||
{ | ||
assert_almost_eq(testName, static_cast<double>(X1), static_cast<double>(X2)); | ||
} | ||
} | ||
|
||
#undef TEST_ASSERT_ALMOST_EQ | ||
#define TEST_ASSERT_ALMOST_EQ(X1, X2) test::assert_almost_eq(testName, X1, X2) | ||
|
||
#undef TEST_ASSERT_EQ_MSG | ||
#define TEST_ASSERT_EQ_MSG(msg, X1, X2) testName, Microsoft::VisualStudio::CppUnitTestFramework::Logger::WriteMessage(msg.c_str()); TEST_ASSERT_EQ(X1, X2) | ||
|
||
#undef TEST_FAIL_MSG | ||
#define TEST_FAIL_MSG(msg) { (void)testName; const str::EncodedStringView vw(msg); Microsoft::VisualStudio::CppUnitTestFramework::Assert::Fail(vw.wstring().c_str()); } | ||
|
||
#undef TEST_EXCEPTION | ||
#undef TEST_THROWS | ||
#undef TEST_SPECIFIC_EXCEPTION | ||
#define TEST_EXCEPTION(X) (void)testName; try{ (X); TEST_FAIL(#X " should have thrown."); } CODA_OSS_TEST_EXCEPTION_catch_ | ||
#define TEST_THROWS(X) (void)testName; try{ (X); TEST_FAIL(#X " should have thrown."); } catch (...){ TEST_ASSERT_TRUE(true); } | ||
#define TEST_SPECIFIC_EXCEPTION(X, Y) testName, Microsoft::VisualStudio::CppUnitTestFramework::Assert::ExpectException<Y>([&](){(X);}) | ||
|
||
#include <include/UnitTest.h> |
Oops, something went wrong.