regression_test_data.h
Go to the documentation of this file.
1 
9 #pragma once
10 #include <string>
11 #include <vector>
13 
14 namespace illumina{ namespace interop { namespace unittest
15 {
19  {
20  private:
21  regression_test_data() : m_rebaseline(false)
22  {
23  }
24 
26  {}
27 
28  public:
34  {
35  static regression_test_data regression_test_data_instance;
36  return regression_test_data_instance;
37  }
38 
39  public:
44  void baseline(const std::string &filename)
45  {
46  m_baseline = filename;
47  }
48 
53  const std::string &baseline() const
54  {
55  return m_baseline;
56  }
57 
62  void add_file(const std::string &filename)
63  {
64  m_files.push_back(filename);
65  }
66 
71  const std::vector <std::string> &files() const
72  {
73  return m_files;
74  }
75 
82  void rebaseline(const bool rebase)
83  {
84  m_rebaseline = rebase;
85  }
86 
91  bool rebaseline() const
92  {
93  return m_rebaseline;
94  }
95 
100  void add_subdir(const std::string& path)
101  {
102  m_sub_dirs.push_back(path);
103  }
106  void finalize()
107  {
108  if(!m_rebaseline) return;
109  io::mkdir(m_baseline);
110  for(std::vector <std::string>::const_iterator fit = m_files.begin();fit != m_files.end();++fit)
111  {
112  const std::string run_folder = io::combine(m_baseline, io::basename(*fit));
113  io::mkdir(run_folder);
114  for (std::vector<std::string>::const_iterator sit = m_sub_dirs.begin(); sit != m_sub_dirs.end(); ++sit)
115  {
116  io::mkdir(io::combine(run_folder, *sit));
117  }
118  }
119  }
120 
121  private:
122  std::string m_baseline;
123  std::vector <std::string> m_files;
124  std::vector <std::string> m_sub_dirs;
125  bool m_rebaseline;
126  };
127 }}}
128 
Definition: enum_description.h:15
std::string basename(std::string const &source)
Definition: filesystem.cpp:95
std::string combine(const std::string &path, const std::string &name)
Definition: filesystem.cpp:39
bool rebaseline() const
Definition: regression_test_data.h:91
static regression_test_data & instance()
Definition: regression_test_data.h:33
void baseline(const std::string &filename)
Definition: regression_test_data.h:44
bool mkdir(const std::string &path, const int mode=0733)
Definition: filesystem.cpp:139
void add_subdir(const std::string &path)
Definition: regression_test_data.h:100
const std::vector< std::string > & files() const
Definition: regression_test_data.h:71
void finalize()
Definition: regression_test_data.h:106
const std::string & baseline() const
Definition: regression_test_data.h:53
void add_file(const std::string &filename)
Definition: regression_test_data.h:62
Definition: regression_test_data.h:18
void rebaseline(const bool rebase)
Definition: regression_test_data.h:82