combine repetitive code into convenience function

This commit is contained in:
Axel Kohlmeyer
2021-03-01 20:07:19 -05:00
parent 74713be4a2
commit 205b45423c
8 changed files with 71 additions and 252 deletions

View File

@ -38,7 +38,6 @@
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <mpi.h>
#include <map>
@ -235,48 +234,8 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
YamlWriter writer(outfile);
// lammps_version
writer.emit("lammps_version", lmp->version);
// date_generated
std::time_t now = time(NULL);
block = utils::trim(ctime(&now));
writer.emit("date_generated", block);
// epsilon
writer.emit("epsilon", config.epsilon);
// skip tests
block.clear();
for (auto &skip_tests : config.skip_tests) {
if (block.empty()) block = skip_tests;
else block += " " + skip_tests;
}
writer.emit("skip_tests", block);
// prerequisites
block.clear();
for (auto &prerequisite : config.prerequisites) {
block += prerequisite.first + " " + prerequisite.second + "\n";
}
writer.emit_block("prerequisites", block);
// pre_commands
block.clear();
for (auto &command : config.pre_commands) {
block += command + "\n";
}
writer.emit_block("pre_commands", block);
// post_commands
block.clear();
for (auto &command : config.post_commands) {
block += command + "\n";
}
writer.emit_block("post_commands", block);
// input_file
writer.emit("input_file", config.input_file);
// write yaml header
write_yaml_header(&writer, &test_config, lmp->version);
// improper_style
writer.emit("improper_style", config.improper_style);