Skip to content

Commit

Permalink
CI fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed Oct 30, 2024
1 parent fe9a74c commit 92ef3ca
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 8 deletions.
18 changes: 17 additions & 1 deletion test/CoreTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,21 @@
#include <string>
#include <vector>

// On Windows, REQUIRE() might not be able to print more complex data structures
// upon failure:
// CoreTest.obj : error LNK2001: unresolved external symbol
// "class std::string const Catch::Detail::unprintableString" (...)
#ifdef _WIN32
#define OPENPMD_REQUIRE_GUARD_WINDOWS(...) \
do \
{ \
bool guarded_require_boolean = __VA_ARGS__; \
REQUIRE(guarded_require_boolean); \
} while (0);
#else
#define OPENPMD_REQUIRE_GUARD_WINDOWS(...) REQUIRE(__VA_ARGS__)
#endif

using namespace openPMD;

Dataset globalDataset(Datatype::CHAR, {1});
Expand Down Expand Up @@ -1322,7 +1337,8 @@ TEST_CASE("custom_geometries", "[core]")
{{UnitDimension::M, 1},
{UnitDimension::L, 1},
{UnitDimension::T, 2}}};
REQUIRE(unit_representations::asMaps(E.gridUnitDimension()) == compare);
OPENPMD_REQUIRE_GUARD_WINDOWS(
unit_representations::asMaps(E.gridUnitDimension()) == compare);
REQUIRE(
E.getAttribute("geometry").get<std::string>() ==
"other:customGeometry");
Expand Down
21 changes: 18 additions & 3 deletions test/SerialIOTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,21 @@
#undef max
#endif

// On Windows, REQUIRE() might not be able to print more complex data structures
// upon failure:
// CoreTest.obj : error LNK2001: unresolved external symbol
// "class std::string const Catch::Detail::unprintableString" (...)
#ifdef _WIN32
#define OPENPMD_REQUIRE_GUARD_WINDOWS(...) \
do \
{ \
bool guarded_require_boolean = __VA_ARGS__; \
REQUIRE(guarded_require_boolean); \
} while (0);
#else
#define OPENPMD_REQUIRE_GUARD_WINDOWS(...) REQUIRE(__VA_ARGS__)
#endif

using namespace openPMD;

struct BackendSelection
Expand Down Expand Up @@ -950,10 +965,10 @@ inline void constant_scalar(std::string const &file_ending)
E_mesh.setAxisLabels(axisLabels);
E_mesh.setUnitDimension(unitDimensions);
E_mesh.setTimeOffset(timeOffset);
REQUIRE(
OPENPMD_REQUIRE_GUARD_WINDOWS(
E_mesh.gridUnitSIPerDimension() == std::vector<double>{1., 1., 1.});
E_mesh.setGridUnitSI(std::vector(3, gridUnitSI));
REQUIRE(
OPENPMD_REQUIRE_GUARD_WINDOWS(
E_mesh.gridUnitSIPerDimension() ==
std::vector<double>{gridUnitSI, gridUnitSI, gridUnitSI});

Expand Down Expand Up @@ -1116,7 +1131,7 @@ inline void constant_scalar(std::string const &file_ending)
Extent{3, 2, 1});

Mesh &E_mesh = s.iterations[1].meshes["E"];
REQUIRE(
OPENPMD_REQUIRE_GUARD_WINDOWS(
E_mesh.gridUnitDimension() ==
std::vector{
std::array<double, 7>{1., 0., 0., 0., 0, .0, 0.},
Expand Down
11 changes: 7 additions & 4 deletions test/python/unittest/API/APITest.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,13 @@ def testFieldData(self):
self.assertEqual(len(i.meshes), 2)
for m in i.meshes:
self.assertTrue(m in ["E", "rho"])
self.assertEqual(i.meshes[m].unit_dimension, io.Unit_Dimension.as_array(
io.Unit_Dimension.as_map(i.meshes[m].unit_dimension)))
self.assertEqual(io.Unit_Dimension.as_maps(i.meshes[m].grid_unit_dimension), [
{io.Unit_Dimension.L: 1}, {io.Unit_Dimension.L: 1}])
self.assertEqual(
i.meshes[m].unit_dimension,
io.Unit_Dimension.as_array(
io.Unit_Dimension.as_map(i.meshes[m].unit_dimension)))
self.assertEqual(
io.Unit_Dimension.as_maps(i.meshes[m].grid_unit_dimension),
[{io.Unit_Dimension.L: 1}, {io.Unit_Dimension.L: 1}])
self.assertEqual(io.Unit_Dimension.from_index(0), io.Unit_Dimension.L)
self.assertEqual(io.Unit_Dimension.L.as_index(), 0)
for idx in range(7):
Expand Down

0 comments on commit 92ef3ca

Please sign in to comment.