Avoid file name collisions in dump unit tests

This commit is contained in:
Richard Berger
2021-10-12 12:15:19 -04:00
parent a6cde11896
commit a1ff9e35b7
2 changed files with 106 additions and 69 deletions

View File

@ -37,6 +37,21 @@ public:
END_HIDE_OUTPUT();
}
std::string dump_filename(std::string ident)
{
return fmt::format("dump_{}_{}.melt", dump_style, ident);
}
std::string text_dump_filename(std::string ident)
{
return fmt::format("dump_{}_text_{}.melt", dump_style, ident);
}
std::string binary_dump_filename(std::string ident)
{
return fmt::format("dump_{}_binary_{}.melt.bin", dump_style, ident);
}
void generate_dump(std::string dump_file, std::string fields, std::string dump_modify_options,
int ntimesteps)
{
@ -87,7 +102,7 @@ public:
TEST_F(DumpCustomTest, run1)
{
auto dump_file = "dump_custom_run1.melt";
auto dump_file = dump_filename("run1");
auto fields =
"id type proc procp1 mass x y z ix iy iz xs ys zs xu yu zu xsu ysu zsu vx vy vz fx fy fz";
@ -105,7 +120,7 @@ TEST_F(DumpCustomTest, run1)
TEST_F(DumpCustomTest, thresh_run0)
{
auto dump_file = "dump_custom_thresh_run0.melt";
auto dump_file = dump_filename("thresh_run0");
auto fields = "id type x y z";
generate_dump(dump_file, fields, "units yes thresh x < 1 thresh y < 1 thresh z < 1", 0);
@ -126,7 +141,7 @@ TEST_F(DumpCustomTest, compute_run0)
command("compute comp all property/atom x y z");
END_HIDE_OUTPUT();
auto dump_file = "dump_custom_compute_run0.melt";
auto dump_file = dump_filename("compute_run0");
auto fields = "id type x y z c_comp[1] c_comp[2] c_comp[3]";
generate_dump(dump_file, fields, "units yes", 0);
@ -149,7 +164,7 @@ TEST_F(DumpCustomTest, fix_run0)
command("fix numdiff all numdiff 1 0.0001");
END_HIDE_OUTPUT();
auto dump_file = "dump_custom_compute_run0.melt";
auto dump_file = dump_filename("fix_run0");
auto fields = "id x y z f_numdiff[1] f_numdiff[2] f_numdiff[3]";
generate_dump(dump_file, fields, "units yes", 0);
@ -171,7 +186,7 @@ TEST_F(DumpCustomTest, custom_run0)
command("compute 1 all property/atom i_flag1 d_flag2");
END_HIDE_OUTPUT();
auto dump_file = "dump_custom_custom_run0.melt";
auto dump_file = dump_filename("custom_run0");
auto fields = "id x y z i_flag1 d_flag2";
generate_dump(dump_file, fields, "units yes", 0);
@ -190,8 +205,8 @@ TEST_F(DumpCustomTest, binary_run1)
{
if (!BINARY2TXT_BINARY) GTEST_SKIP();
auto text_file = "dump_custom_text_run1.melt";
auto binary_file = "dump_custom_binary_run1.melt.bin";
auto text_file = text_dump_filename("run1");
auto binary_file = binary_dump_filename("run1");
auto fields = "id type proc x y z ix iy iz xs ys zs xu yu zu xsu ysu zsu vx vy vz fx fy fz";
generate_text_and_binary_dump(text_file, binary_file, fields, "units yes", 1);
@ -210,7 +225,7 @@ TEST_F(DumpCustomTest, binary_run1)
TEST_F(DumpCustomTest, triclinic_run1)
{
auto dump_file = "dump_custom_tri_run1.melt";
auto dump_file = dump_filename("tri_run1");
auto fields = "id type proc x y z ix iy iz xs ys zs xu yu zu xsu ysu zsu vx vy vz fx fy fz";
enable_triclinic();
@ -231,8 +246,8 @@ TEST_F(DumpCustomTest, binary_triclinic_run1)
{
if (!BINARY2TXT_BINARY) GTEST_SKIP();
auto text_file = "dump_custom_tri_text_run1.melt";
auto binary_file = "dump_custom_tri_binary_run1.melt.bin";
auto text_file = text_dump_filename("tri_run1");
auto binary_file = binary_dump_filename("tri_run1");
auto fields = "id type proc x y z xs ys zs xsu ysu zsu vx vy vz fx fy fz";
enable_triclinic();
@ -258,7 +273,7 @@ TEST_F(DumpCustomTest, with_variable_run1)
command("variable p atom (c_1%10)+1");
END_HIDE_OUTPUT();
auto dump_file = "dump_custom_with_variable_run1.melt";
auto dump_file = dump_filename("with_variable_run1");
auto fields = "id type x y z v_p";
generate_dump(dump_file, fields, "units yes", 1);
@ -275,7 +290,7 @@ TEST_F(DumpCustomTest, with_variable_run1)
TEST_F(DumpCustomTest, run1plus1)
{
auto dump_file = "dump_custom_run1plus1.melt";
auto dump_file = dump_filename("run1plus1");
auto fields = "id type x y z";
generate_dump(dump_file, fields, "units yes", 1);
@ -292,7 +307,7 @@ TEST_F(DumpCustomTest, run1plus1)
TEST_F(DumpCustomTest, run2)
{
auto dump_file = "dump_custom_run2.melt";
auto dump_file = dump_filename("run2");
auto fields = "id type x y z";
generate_dump(dump_file, fields, "", 2);
@ -303,7 +318,7 @@ TEST_F(DumpCustomTest, run2)
TEST_F(DumpCustomTest, rerun)
{
auto dump_file = "dump_rerun.melt";
auto dump_file = dump_filename("rerun");
auto fields = "id type xs ys zs";
HIDE_OUTPUT([&] {