Skip to content

Commit 83dd2ad

Browse files
committed
Extend this test to variable-based
1 parent df4d106 commit 83dd2ad

File tree

3 files changed

+30
-5
lines changed

3 files changed

+30
-5
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,7 @@ if(openPMD_USE_INVASIVE_TESTS)
811811
message(WARNING "Invasive tests that redefine class signatures are "
812812
"known to fail on Windows!")
813813
endif()
814+
target_compile_definitions(openPMD PRIVATE openPMD_USE_INVASIVE_TESTS=1)
814815
endif()
815816

816817
if(openPMD_BUILD_TESTING)

src/Iteration.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,16 @@ void Iteration::read_impl(std::string const &groupPath)
549549
}
550550

551551
readAttributes(ReadMode::FullyReread);
552+
#ifdef openPMD_USE_INVASIVE_TESTS
553+
if (containsAttribute("__openPMD_internal_fail"))
554+
{
555+
throw error::ReadError(
556+
error::AffectedObject::Attribute,
557+
error::Reason::Other,
558+
{},
559+
"Deliberately failing this iteration for testing purposes");
560+
}
561+
#endif
552562
}
553563

554564
AdvanceStatus Iteration::beginStep()

test/SerialIOTest.cpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5484,12 +5484,20 @@ TEST_CASE("no_explicit_flush", "[serial]")
54845484
}
54855485
}
54865486

5487-
void unfinished_iteration_test(std::string const &file)
5487+
#ifdef openPMD_USE_INVASIVE_TESTS
5488+
void unfinished_iteration_test(
5489+
std::string const &ext, bool filebased, std::string const &config = "{}")
54885490
{
5491+
std::string file = std::string("../samples/unfinished_iteration.") +
5492+
(filebased ? "_%T." : "") + ext;
54895493
{
5490-
Series write(file, Access::CREATE);
5494+
Series write(file, Access::CREATE, config);
54915495
auto it0 = write.writeIterations()[0];
5492-
it0.setAttribute("dt", "This is wrong.");
5496+
/*
5497+
* With enabled invasive tests, this attribute will let the Iteration
5498+
* fail parsing.
5499+
*/
5500+
it0.setAttribute("__openPMD_internal_fail", "asking for trouble");
54935501
auto it10 = write.writeIterations()[10];
54945502
auto E_x = it10.meshes["E"]["x"];
54955503
auto e_density = it10.meshes["e_density"][RecordComponent::SCALAR];
@@ -5505,11 +5513,17 @@ void unfinished_iteration_test(std::string const &file)
55055513
TEST_CASE("unfinished_iteration_test", "[serial]")
55065514
{
55075515
#if openPMD_HAVE_ADIOS2
5508-
unfinished_iteration_test("../samples/unfinished_iteration.bp");
5516+
unfinished_iteration_test("bp", false);
55095517
unfinished_iteration_test(
5510-
"../samples/unfinished_iteration_filebased_%T.bp");
5518+
"bp",
5519+
false,
5520+
R"(
5521+
iteration_encoding = "variable_based"
5522+
adios2.schema = 20210209)");
5523+
unfinished_iteration_test("bp", true);
55115524
#endif
55125525
}
5526+
#endif
55135527

55145528
TEST_CASE("late_setting_of_iterationencoding", "[serial]")
55155529
{

0 commit comments

Comments
 (0)